From 0bb10e3f812d50f2e7b4979e803fc0b27b0968d7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 9 Sep 2011 11:10:54 -0600 Subject: [PATCH] SONY driver: Remove comments from books sent to SONY readers as the reader chokes on them --- src/calibre/devices/interface.py | 6 ++++++ src/calibre/devices/prs505/driver.py | 2 ++ src/calibre/gui2/device.py | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/src/calibre/devices/interface.py b/src/calibre/devices/interface.py index 7537e18db3..507a836e37 100644 --- a/src/calibre/devices/interface.py +++ b/src/calibre/devices/interface.py @@ -74,6 +74,12 @@ class DevicePlugin(Plugin): #: For example: ``frozenset(['kobo'])`` VIRTUAL_BOOK_EXTENSIONS = frozenset([]) + #: Whether to nuke comments in the copy of the book sent to the device. If + #: not None this should be short string that the comments will be replaced + #: by. + NUKE_COMMENTS = None + + @classmethod def get_gui_name(cls): if hasattr(cls, 'gui_name'): diff --git a/src/calibre/devices/prs505/driver.py b/src/calibre/devices/prs505/driver.py index 9c1dc930b8..7bff74c5f8 100644 --- a/src/calibre/devices/prs505/driver.py +++ b/src/calibre/devices/prs505/driver.py @@ -56,6 +56,8 @@ class PRS505(USBMS): SUPPORTS_SUB_DIRS = True MUST_READ_METADATA = True + NUKE_COMMENTS = _('Comments have been removed as the SONY reader' + ' chokes on them') SUPPORTS_USE_AUTHOR_SORT = True EBOOK_DIR_MAIN = 'database/media/books' SCAN_FROM_ROOT = False diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index 0a9dbaecdd..e929825245 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -391,6 +391,10 @@ class DeviceManager(Thread): # {{{ newmi.template_to_attribute(mi, cpb) else: newmi = mi + nuke_comments = getattr(self.connected_device, + 'NUKE_COMMENTS', None) + if nuke_comments is not None: + mi.comments = nuke_comments set_metadata(stream, newmi, stream_type=ext) except: if DEBUG: