mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Possible fix for the NOOK Glowlight Plus
For some idiotic reason B&N only allow files to be written inside the NOOK folder on this device. So we try to special case it in the MTP driver.
This commit is contained in:
parent
a5e7d38951
commit
1809d85330
@ -22,6 +22,13 @@ class DeviceDefaults(object):
|
|||||||
'send_to': ['documents', 'books', 'kindle'],
|
'send_to': ['documents', 'books', 'kindle'],
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
# B&N devices
|
||||||
|
({'vendor':0x2080}, {
|
||||||
|
'format_map': ['epub', 'pdf'],
|
||||||
|
'send_to': ['NOOK', 'Calibre_Companion', 'Books',
|
||||||
|
'eBooks/import', 'eBooks', 'sdcard/ebooks'],
|
||||||
|
}
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __call__(self, device, driver):
|
def __call__(self, device, driver):
|
||||||
@ -47,7 +54,10 @@ class DeviceDefaults(object):
|
|||||||
matches = False
|
matches = False
|
||||||
break
|
break
|
||||||
if matches:
|
if matches:
|
||||||
return rule[1]
|
ans = rule[1]
|
||||||
|
if vid == 0x2080 and pid == 0x000a:
|
||||||
|
ans['calibre_file_paths'] = {'metadata':'NOOK/metadata.calibre', 'driveinfo':'NOOK/driveinfo.calibre'}
|
||||||
|
return ans
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ class MTP_DEVICE(BASE):
|
|||||||
self._prefs = None
|
self._prefs = None
|
||||||
self.device_defaults = DeviceDefaults()
|
self.device_defaults = DeviceDefaults()
|
||||||
self.current_device_defaults = {}
|
self.current_device_defaults = {}
|
||||||
|
self.calibre_file_paths = {'metadata':self.METADATA_CACHE, 'driveinfo':self.DRIVEINFO}
|
||||||
self.highlight_ignored_folders = False
|
self.highlight_ignored_folders = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -128,6 +129,8 @@ class MTP_DEVICE(BASE):
|
|||||||
self.prefs['history'] = h
|
self.prefs['history'] = h
|
||||||
|
|
||||||
self.current_device_defaults = self.device_defaults(device, self)
|
self.current_device_defaults = self.device_defaults(device, self)
|
||||||
|
self.calibre_file_paths = self.current_device_defaults.get(
|
||||||
|
'calibre_file_paths', {'metadata':self.METADATA_CACHE, 'driveinfo':self.DRIVEINFO})
|
||||||
|
|
||||||
def get_device_uid(self):
|
def get_device_uid(self):
|
||||||
return self.current_serial_num
|
return self.current_serial_num
|
||||||
@ -145,7 +148,7 @@ class MTP_DEVICE(BASE):
|
|||||||
from calibre.utils.date import isoformat, now
|
from calibre.utils.date import isoformat, now
|
||||||
from calibre.utils.config import from_json, to_json
|
from calibre.utils.config import from_json, to_json
|
||||||
import uuid
|
import uuid
|
||||||
f = storage.find_path((self.DRIVEINFO,))
|
f = storage.find_path((self.calibre_file_paths['driveinfo'],))
|
||||||
dinfo = {}
|
dinfo = {}
|
||||||
if f is not None:
|
if f is not None:
|
||||||
try:
|
try:
|
||||||
@ -167,7 +170,7 @@ class MTP_DEVICE(BASE):
|
|||||||
dinfo['date_last_connected'] = isoformat(now())
|
dinfo['date_last_connected'] = isoformat(now())
|
||||||
dinfo['mtp_prefix'] = storage.storage_prefix
|
dinfo['mtp_prefix'] = storage.storage_prefix
|
||||||
raw = json.dumps(dinfo, default=to_json)
|
raw = json.dumps(dinfo, default=to_json)
|
||||||
self.put_file(storage, self.DRIVEINFO, BytesIO(raw), len(raw))
|
self.put_file(storage, self.calibre_file_paths['driveinfo'], BytesIO(raw), len(raw))
|
||||||
self.driveinfo[location_code] = dinfo
|
self.driveinfo[location_code] = dinfo
|
||||||
|
|
||||||
def get_driveinfo(self):
|
def get_driveinfo(self):
|
||||||
@ -222,7 +225,7 @@ class MTP_DEVICE(BASE):
|
|||||||
self.report_progress(0, _('Reading ebook metadata'))
|
self.report_progress(0, _('Reading ebook metadata'))
|
||||||
# Read the cache if it exists
|
# Read the cache if it exists
|
||||||
storage = self.filesystem_cache.storage(sid)
|
storage = self.filesystem_cache.storage(sid)
|
||||||
cache = storage.find_path((self.METADATA_CACHE,))
|
cache = storage.find_path((self.calibre_file_paths['metadata'],))
|
||||||
if cache is not None:
|
if cache is not None:
|
||||||
json_codec = JSONCodec()
|
json_codec = JSONCodec()
|
||||||
try:
|
try:
|
||||||
@ -298,7 +301,7 @@ class MTP_DEVICE(BASE):
|
|||||||
json_codec.encode_to_file(stream, bl)
|
json_codec.encode_to_file(stream, bl)
|
||||||
size = stream.tell()
|
size = stream.tell()
|
||||||
stream.seek(0)
|
stream.seek(0)
|
||||||
self.put_file(storage, self.METADATA_CACHE, stream, size)
|
self.put_file(storage, self.calibre_file_paths['metadata'], stream, size)
|
||||||
|
|
||||||
def sync_booklists(self, booklists, end_session=True):
|
def sync_booklists(self, booklists, end_session=True):
|
||||||
debug('sync_booklists() called')
|
debug('sync_booklists() called')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user