mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add capability and option to Sony driver to sync covers during automatic management
This commit is contained in:
parent
1c15afea9f
commit
cc736d3326
@ -76,12 +76,23 @@ class PRS505(USBMS):
|
|||||||
'sending DRMed books in which you cannot change the cover.'
|
'sending DRMed books in which you cannot change the cover.'
|
||||||
' WARNING: This option should only be used with newer '
|
' WARNING: This option should only be used with newer '
|
||||||
'SONY readers: 350, 650, 950 and newer.'),
|
'SONY readers: 350, 650, 950 and newer.'),
|
||||||
|
_('Refresh separate covers when using automatic management (newer readers)') +
|
||||||
|
':::' +
|
||||||
|
_('Set this option to have separate book covers uploaded '
|
||||||
|
'every time you connect your device. Unset this option if '
|
||||||
|
'you have so many books on the reader that performance is '
|
||||||
|
'unacceptable.')
|
||||||
]
|
]
|
||||||
EXTRA_CUSTOMIZATION_DEFAULT = [
|
EXTRA_CUSTOMIZATION_DEFAULT = [
|
||||||
', '.join(['series', 'tags']),
|
', '.join(['series', 'tags']),
|
||||||
|
False,
|
||||||
False
|
False
|
||||||
]
|
]
|
||||||
|
|
||||||
|
OPT_COLLECTIONS = 0
|
||||||
|
OPT_UPLOAD_COVERS = 1
|
||||||
|
OPT_REFRESH_COVERS = 2
|
||||||
|
|
||||||
plugboard = None
|
plugboard = None
|
||||||
plugboard_func = None
|
plugboard_func = None
|
||||||
|
|
||||||
@ -171,7 +182,7 @@ class PRS505(USBMS):
|
|||||||
opts = self.settings()
|
opts = self.settings()
|
||||||
if opts.extra_customization:
|
if opts.extra_customization:
|
||||||
collections = [x.strip() for x in
|
collections = [x.strip() for x in
|
||||||
opts.extra_customization[0].split(',')]
|
opts.extra_customization[self.OPT_COLLECTIONS].split(',')]
|
||||||
else:
|
else:
|
||||||
collections = []
|
collections = []
|
||||||
debug_print('PRS505: collection fields:', collections)
|
debug_print('PRS505: collection fields:', collections)
|
||||||
@ -183,6 +194,20 @@ class PRS505(USBMS):
|
|||||||
c.update(blists, collections, pb)
|
c.update(blists, collections, pb)
|
||||||
c.write()
|
c.write()
|
||||||
|
|
||||||
|
if opts.extra_customization[self.OPT_REFRESH_COVERS]:
|
||||||
|
debug_print('PRS505: uploading covers in sync_booklists')
|
||||||
|
for idx,bl in blists.items():
|
||||||
|
prefix = self._card_a_prefix if idx == 1 else \
|
||||||
|
self._card_b_prefix if idx == 2 \
|
||||||
|
else self._main_prefix
|
||||||
|
for book in bl:
|
||||||
|
p = os.path.join(prefix, book.lpath)
|
||||||
|
self._upload_cover(os.path.dirname(p),
|
||||||
|
os.path.splitext(os.path.basename(p))[0],
|
||||||
|
book, p)
|
||||||
|
else:
|
||||||
|
debug_print('PRS505: NOT uploading covers in sync_booklists')
|
||||||
|
|
||||||
USBMS.sync_booklists(self, booklists, end_session=end_session)
|
USBMS.sync_booklists(self, booklists, end_session=end_session)
|
||||||
debug_print('PRS505: finished sync_booklists')
|
debug_print('PRS505: finished sync_booklists')
|
||||||
|
|
||||||
@ -199,11 +224,14 @@ class PRS505(USBMS):
|
|||||||
|
|
||||||
def upload_cover(self, path, filename, metadata, filepath):
|
def upload_cover(self, path, filename, metadata, filepath):
|
||||||
opts = self.settings()
|
opts = self.settings()
|
||||||
if not opts.extra_customization[1]:
|
if not opts.extra_customization[self.OPT_UPLOAD_COVERS]:
|
||||||
# Building thumbnails disabled
|
# Building thumbnails disabled
|
||||||
debug_print('PRS505: not uploading covers')
|
debug_print('PRS505: not uploading cover')
|
||||||
return
|
return
|
||||||
debug_print('PRS505: uploading covers')
|
debug_print('PRS505: uploading cover')
|
||||||
|
self._upload_cover(path, filename, metadata, filepath)
|
||||||
|
|
||||||
|
def _upload_cover(self, path, filename, metadata, filepath):
|
||||||
if metadata.thumbnail and metadata.thumbnail[-1]:
|
if metadata.thumbnail and metadata.thumbnail[-1]:
|
||||||
path = path.replace('/', os.sep)
|
path = path.replace('/', os.sep)
|
||||||
is_main = path.startswith(self._main_prefix)
|
is_main = path.startswith(self._main_prefix)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user