mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Kobo Touch: Display Preview Tag for book previews on the device
This commit is contained in:
commit
c4e2734f6e
@ -100,7 +100,7 @@ class KOBO(USBMS):
|
|||||||
for idx,b in enumerate(bl):
|
for idx,b in enumerate(bl):
|
||||||
bl_cache[b.lpath] = idx
|
bl_cache[b.lpath] = idx
|
||||||
|
|
||||||
def update_booklist(prefix, path, title, authors, mime, date, ContentType, ImageID, readstatus, MimeType, expired, favouritesindex):
|
def update_booklist(prefix, path, title, authors, mime, date, ContentType, ImageID, readstatus, MimeType, expired, favouritesindex, accessibility):
|
||||||
changed = False
|
changed = False
|
||||||
try:
|
try:
|
||||||
lpath = path.partition(self.normalize_path(prefix))[2]
|
lpath = path.partition(self.normalize_path(prefix))[2]
|
||||||
@ -129,6 +129,10 @@ class KOBO(USBMS):
|
|||||||
if favouritesindex == 1:
|
if favouritesindex == 1:
|
||||||
playlist_map[lpath].append('Shortlist')
|
playlist_map[lpath].append('Shortlist')
|
||||||
|
|
||||||
|
# Label Previews
|
||||||
|
if accessibility == 6:
|
||||||
|
playlist_map[lpath].append('Preview')
|
||||||
|
|
||||||
path = self.normalize_path(path)
|
path = self.normalize_path(path)
|
||||||
# print "Normalized FileName: " + path
|
# print "Normalized FileName: " + path
|
||||||
|
|
||||||
@ -204,23 +208,31 @@ class KOBO(USBMS):
|
|||||||
self.dbversion = result[0]
|
self.dbversion = result[0]
|
||||||
|
|
||||||
debug_print("Database Version: ", self.dbversion)
|
debug_print("Database Version: ", self.dbversion)
|
||||||
if self.dbversion >= 14:
|
if self.dbversion >= 16:
|
||||||
query= 'select Title, Attribution, DateCreated, ContentID, MimeType, ContentType, ' \
|
query= 'select Title, Attribution, DateCreated, ContentID, MimeType, ContentType, ' \
|
||||||
'ImageID, ReadStatus, ___ExpirationStatus, FavouritesIndex from content where BookID is Null and ( ___ExpirationStatus <> "3" or ___ExpirationStatus is Null)'
|
'ImageID, ReadStatus, ___ExpirationStatus, FavouritesIndex, Accessibility from content where ' \
|
||||||
|
'BookID is Null and ( ___ExpirationStatus <> "3" or ___ExpirationStatus is Null)'
|
||||||
|
elif self.dbversion < 16 and self.dbversion >= 14:
|
||||||
|
query= 'select Title, Attribution, DateCreated, ContentID, MimeType, ContentType, ' \
|
||||||
|
'ImageID, ReadStatus, ___ExpirationStatus, "-1" as FavouritesIndex, "-1" as Accessibility from content where ' \
|
||||||
|
'BookID is Null and ( ___ExpirationStatus <> "3" or ___ExpirationStatus is Null)'
|
||||||
elif self.dbversion < 14 and self.dbversion >= 8:
|
elif self.dbversion < 14 and self.dbversion >= 8:
|
||||||
query= 'select Title, Attribution, DateCreated, ContentID, MimeType, ContentType, ' \
|
query= 'select Title, Attribution, DateCreated, ContentID, MimeType, ContentType, ' \
|
||||||
'ImageID, ReadStatus, ___ExpirationStatus, "-1" as FavouritesIndex from content where BookID is Null and ( ___ExpirationStatus <> "3" or ___ExpirationStatus is Null)'
|
'ImageID, ReadStatus, ___ExpirationStatus, "-1" as FavouritesIndex, "-1" as Accessibility from content where ' \
|
||||||
|
'BookID is Null and ( ___ExpirationStatus <> "3" or ___ExpirationStatus is Null)'
|
||||||
else:
|
else:
|
||||||
query= 'select Title, Attribution, DateCreated, ContentID, MimeType, ContentType, ' \
|
query= 'select Title, Attribution, DateCreated, ContentID, MimeType, ContentType, ' \
|
||||||
'ImageID, ReadStatus, "-1" as ___ExpirationStatus, "-1" as FavouritesIndex from content where BookID is Null'
|
'ImageID, ReadStatus, "-1" as ___ExpirationStatus, "-1" as FavouritesIndex, "-1" as Accessibility from content where BookID is Null'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cursor.execute (query)
|
cursor.execute (query)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if '___ExpirationStatus' not in str(e):
|
if '___ExpirationStatus' not in str(e):
|
||||||
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 from content where BookID is Null'
|
'ImageID, ReadStatus, "-1" as ___ExpirationStatus, "-1" as '
|
||||||
|
'FavouritesIndex, "-1" as Accessibility from content where '
|
||||||
|
'BookID is Null')
|
||||||
cursor.execute(query)
|
cursor.execute(query)
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
@ -234,10 +246,10 @@ class KOBO(USBMS):
|
|||||||
# debug_print("mime:", mime)
|
# debug_print("mime:", mime)
|
||||||
|
|
||||||
if oncard != 'carda' and oncard != 'cardb' and not row[3].startswith("file:///mnt/sd/"):
|
if oncard != 'carda' and oncard != 'cardb' and not row[3].startswith("file:///mnt/sd/"):
|
||||||
changed = update_booklist(self._main_prefix, path, row[0], row[1], mime, row[2], row[5], row[6], row[7], row[4], row[8], row[9])
|
changed = update_booklist(self._main_prefix, path, row[0], row[1], mime, row[2], row[5], row[6], row[7], row[4], row[8], row[9], row[10])
|
||||||
# print "shortbook: " + path
|
# print "shortbook: " + path
|
||||||
elif oncard == 'carda' and row[3].startswith("file:///mnt/sd/"):
|
elif oncard == 'carda' and row[3].startswith("file:///mnt/sd/"):
|
||||||
changed = update_booklist(self._card_a_prefix, path, row[0], row[1], mime, row[2], row[5], row[6], row[7], row[4], row[8], row[9])
|
changed = update_booklist(self._card_a_prefix, path, row[0], row[1], mime, row[2], row[5], row[6], row[7], row[4], row[8], row[9], row[10])
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
need_sync = True
|
need_sync = True
|
||||||
@ -562,7 +574,7 @@ class KOBO(USBMS):
|
|||||||
debug_print(' Commit: Reset ReadStatus list')
|
debug_print(' Commit: Reset ReadStatus list')
|
||||||
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
def set_readstatus(self, connection, ContentID, ReadStatus):
|
def set_readstatus(self, connection, ContentID, ReadStatus):
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
t = (ContentID,)
|
t = (ContentID,)
|
||||||
@ -601,7 +613,7 @@ class KOBO(USBMS):
|
|||||||
else:
|
else:
|
||||||
connection.commit()
|
connection.commit()
|
||||||
debug_print(' Commit: Reset FavouritesIndex list')
|
debug_print(' Commit: Reset FavouritesIndex list')
|
||||||
|
|
||||||
def set_favouritesindex(self, connection, ContentID):
|
def set_favouritesindex(self, connection, ContentID):
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
@ -615,7 +627,6 @@ class KOBO(USBMS):
|
|||||||
else:
|
else:
|
||||||
connection.commit()
|
connection.commit()
|
||||||
debug_print(' Commit: Set FavouritesIndex')
|
debug_print(' Commit: Set FavouritesIndex')
|
||||||
|
|
||||||
|
|
||||||
def update_device_database_collections(self, booklists, collections_attributes, oncard):
|
def update_device_database_collections(self, booklists, collections_attributes, oncard):
|
||||||
# Define lists for the ReadStatus
|
# Define lists for the ReadStatus
|
||||||
@ -623,7 +634,11 @@ class KOBO(USBMS):
|
|||||||
"Im_Reading":1,
|
"Im_Reading":1,
|
||||||
"Read":2,
|
"Read":2,
|
||||||
"Closed":3,
|
"Closed":3,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
accessibilitylist = {
|
||||||
|
"Preview":6,
|
||||||
|
}
|
||||||
# debug_print('Starting update_device_database_collections', collections_attributes)
|
# debug_print('Starting update_device_database_collections', collections_attributes)
|
||||||
|
|
||||||
# Force collections_attributes to be 'tags' as no other is currently supported
|
# Force collections_attributes to be 'tags' as no other is currently supported
|
||||||
@ -663,11 +678,14 @@ class KOBO(USBMS):
|
|||||||
ContentID = self.contentid_from_path(book.path, ContentType)
|
ContentID = self.contentid_from_path(book.path, ContentType)
|
||||||
|
|
||||||
if category in readstatuslist.keys():
|
if category in readstatuslist.keys():
|
||||||
# Manage ReadStatus
|
# Manage ReadStatus
|
||||||
self.set_readstatus(connection, ContentID, readstatuslist.get(category))
|
self.set_readstatus(connection, ContentID, readstatuslist.get(category))
|
||||||
if category == 'Shortlist':
|
if category == 'Shortlist':
|
||||||
# Manage FavouritesIndex/Shortlist
|
# Manage FavouritesIndex/Shortlist
|
||||||
self.set_favouritesindex(connection, ContentID)
|
self.set_favouritesindex(connection, ContentID)
|
||||||
|
if category in accessibilitylist.keys():
|
||||||
|
# Do not manage the Accessibility List
|
||||||
|
pass
|
||||||
else: # No collections
|
else: # No collections
|
||||||
# Since no collections exist the ReadStatus needs to be reset to 0 (Unread)
|
# Since no collections exist the ReadStatus needs to be reset to 0 (Unread)
|
||||||
debug_print("No Collections - reseting ReadStatus")
|
debug_print("No Collections - reseting ReadStatus")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user