Correct handling of ContentType for newer Kobo firmware.

The py3 changes highlighted an error in how the ContentType was being
handled. This should have been fixed ages ago.

Also fixed an issue with the Language column and old firmware/database
versions.
This commit is contained in:
David 2019-06-02 13:01:12 +10:00
parent 7d81b1dddf
commit 469e8cfb55

View File

@ -1839,15 +1839,15 @@ class KOBOTOUCH(KOBO):
self.bookshelvelist = self.get_bookshelflist(connection) self.bookshelvelist = self.get_bookshelflist(connection)
debug_print("KoboTouch:books - shelf list:", self.bookshelvelist) debug_print("KoboTouch:books - shelf list:", self.bookshelvelist)
columns = 'Title, Attribution, DateCreated, ContentID, MimeType, ContentType, ImageId, ReadStatus, Description, Publisher, Language ' columns = 'Title, Attribution, DateCreated, ContentID, MimeType, ContentType, ImageId, ReadStatus, Description, Publisher '
if self.dbversion >= 16: if self.dbversion >= 16:
columns += ', ___ExpirationStatus, FavouritesIndex, Accessibility' columns += ', ___ExpirationStatus, FavouritesIndex, Accessibility'
else: else:
columns += ', -1 as ___ExpirationStatus, -1 as FavouritesIndex, -1 as Accessibility' columns += ', -1 as ___ExpirationStatus, -1 as FavouritesIndex, -1 as Accessibility'
if self.dbversion >= 33: if self.dbversion >= 33:
columns += ', IsDownloaded, ISBN' columns += ', Language, IsDownloaded, ISBN'
else: else:
columns += ', "1" as IsDownloaded, null AS ISBN' columns += ', NULL AS Language, "1" AS IsDownloaded, NULL AS ISBN'
if self.supports_series(): if self.supports_series():
columns += ", Series, SeriesNumber, ___UserID, ExternalId, Subtitle" columns += ", Series, SeriesNumber, ___UserID, ExternalId, Subtitle"
else: else:
@ -1915,7 +1915,7 @@ class KOBOTOUCH(KOBO):
raise raise
query= ('SELECT Title, Attribution, DateCreated, ContentID, MimeType, ContentType, ' query= ('SELECT Title, Attribution, DateCreated, ContentID, MimeType, ContentType, '
'ImageId, ReadStatus, -1 AS ___ExpirationStatus, "-1" AS FavouritesIndex, ' 'ImageId, ReadStatus, -1 AS ___ExpirationStatus, "-1" AS FavouritesIndex, '
'null AS ISBN, Language ' 'null AS ISBN, NULL AS Language '
'-1 AS Accessibility, 1 AS IsDownloaded, NULL AS Series, NULL AS SeriesNumber, null as Subtitle ' '-1 AS Accessibility, 1 AS IsDownloaded, NULL AS Series, NULL AS SeriesNumber, null as Subtitle '
'FROM content ' 'FROM content '
'WHERE BookID IS NULL' 'WHERE BookID IS NULL'
@ -2325,17 +2325,18 @@ class KOBOTOUCH(KOBO):
debug_print("KoboTouch:contentid_from_path - end - ContentID='%s'"%ContentID) debug_print("KoboTouch:contentid_from_path - end - ContentID='%s'"%ContentID)
return ContentID return ContentID
def get_content_type_from_path(self, path):
ContentType = 6
if self.fwversion < (1, 9, 17):
ContentType = super(KOBOTOUCH, self).get_content_type_from_path(path)
return ContentType
def get_content_type_from_extension(self, extension): def get_content_type_from_extension(self, extension):
debug_print("KoboTouch:get_content_type_from_extension - start") debug_print("KoboTouch:get_content_type_from_extension - start")
# With new firmware, ContentType appears to be 6 for all types of sideloaded books. # With new firmware, ContentType appears to be 6 for all types of sideloaded books.
if self.fwversion >= (1,9,17) or extension == '.kobo' or extension == '.mobi': ContentType = 6
debug_print("KoboTouch:get_content_type_from_extension - V2 firmware") if self.fwversion < (1,9,17):
ContentType = 6 ContentType = super(KOBOTOUCH, self).get_content_type_from_extension(extension)
# For older firmware, it depends on the type of file.
elif extension == '.kobo' or extension == '.mobi':
ContentType = 6
else:
ContentType = 901
return ContentType return ContentType
def set_plugboards(self, plugboards, pb_func): def set_plugboards(self, plugboards, pb_func):