From a186affcdc399a903d03cfc16df640adc31c6891 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 10 Oct 2012 19:43:23 +0530 Subject: [PATCH] Kobo driver: Friendlier error message when the user tries to add kepubs from the device to calibre. Fixes to getting bookmarks from the device. No longer show unsupported db version for older Kobo models with newer firmware. Fixes #1063352 (KOBO database version unsupported) --- src/calibre/devices/kobo/driver.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/calibre/devices/kobo/driver.py b/src/calibre/devices/kobo/driver.py index 9805510c9f..8d6e6ad7a4 100644 --- a/src/calibre/devices/kobo/driver.py +++ b/src/calibre/devices/kobo/driver.py @@ -33,11 +33,11 @@ class KOBO(USBMS): gui_name = 'Kobo Reader' description = _('Communicate with the Kobo Reader') author = 'Timothy Legge and David Forrester' - version = (2, 0, 0) + version = (2, 0, 1) dbversion = 0 fwversion = 0 - supported_dbversion = 33 + supported_dbversion = 62 has_kepubs = False supported_platforms = ['windows', 'osx', 'linux'] @@ -59,7 +59,8 @@ class KOBO(USBMS): SUPPORTS_SUB_DIRS = True SUPPORTS_ANNOTATIONS = True - VIRTUAL_BOOK_EXTENSIONS = frozenset(['kobo']) + # "kepubs" do not have an extension. The name looks like a GUID. Using an empty string seems to work. + VIRTUAL_BOOK_EXTENSIONS = frozenset(['kobo', '']) EXTRA_CUSTOMIZATION_MESSAGE = [ _('The Kobo supports several collections including ')+\ @@ -1044,6 +1045,7 @@ class KOBO(USBMS): extension = os.path.splitext(path_map[id])[1] ContentType = self.get_content_type_from_extension(extension) if extension != '' else self.get_content_type_from_path(path_map[id]) ContentID = self.contentid_from_path(path_map[id], ContentType) + debug_print("get_annotations - ContentID: ", ContentID, "ContentType: ", ContentType) bookmark_ext = extension @@ -1066,7 +1068,10 @@ class KOBO(USBMS): try: last_read = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(calendar.timegm(time.strptime(bookmark.last_read, "%Y-%m-%dT%H:%M:%S")))) except: - last_read = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(calendar.timegm(time.strptime(bookmark.last_read, "%Y-%m-%dT%H:%M:%S.%f")))) + try: + last_read = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(calendar.timegm(time.strptime(bookmark.last_read, "%Y-%m-%dT%H:%M:%S.%f")))) + except: + last_read = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(calendar.timegm(time.strptime(bookmark.last_read, "%Y-%m-%dT%H:%M:%SZ")))) else: #self.datetime = time.gmtime() last_read = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()) @@ -1157,6 +1162,7 @@ class KOBO(USBMS): if bm.type == 'kobo_bookmark': mi = db.get_metadata(db_id, index_is_id=True) + debug_print("KOBO:add_annotation_to_library - Title: ", mi.title) user_notes_soup = self.generate_annotation_html(bm.value) if mi.comments: a_offset = mi.comments.find('
') @@ -1750,6 +1756,9 @@ class KOBOTOUCH(KOBO): ContentID = os.path.splitext(path)[0] # Remove the prefix on the file. it could be either ContentID = ContentID.replace(self._main_prefix, '') + elif extension == '': + ContentID = path + ContentID = ContentID.replace(self._main_prefix + self.normalize_path('.kobo/kepub/'), '') else: ContentID = path ContentID = ContentID.replace(self._main_prefix, "file:///mnt/onboard/")