mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
...
This commit is contained in:
commit
44a13d1f05
@ -602,6 +602,21 @@ class KOBO(USBMS):
|
|||||||
connection.commit()
|
connection.commit()
|
||||||
debug_print(' Commit: Reset FavouritesIndex list')
|
debug_print(' Commit: Reset FavouritesIndex list')
|
||||||
|
|
||||||
|
def set_favouritesindex(self, connection, ContentID):
|
||||||
|
cursor = connection.cursor()
|
||||||
|
|
||||||
|
t = (ContentID,)
|
||||||
|
|
||||||
|
try:
|
||||||
|
cursor.execute('update content set FavouritesIndex=1 where BookID is Null and ContentID = ?', t)
|
||||||
|
except:
|
||||||
|
debug_print(' Database Exception: Unable set book as Shortlist')
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
connection.commit()
|
||||||
|
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
|
||||||
readstatuslist = {
|
readstatuslist = {
|
||||||
@ -636,11 +651,7 @@ class KOBO(USBMS):
|
|||||||
|
|
||||||
# Process any collections that exist
|
# Process any collections that exist
|
||||||
for category, books in collections.items():
|
for category, books in collections.items():
|
||||||
# This is used to reset the Im_Reading, Read and Closed list
|
|
||||||
# in the ReadStatus column of the Content table
|
|
||||||
if category in readstatuslist.keys():
|
|
||||||
debug_print("Category: ", category, " id = ", readstatuslist.get(category))
|
debug_print("Category: ", category, " id = ", readstatuslist.get(category))
|
||||||
|
|
||||||
for book in books:
|
for book in books:
|
||||||
debug_print(' Title:', book.title, 'category: ', category)
|
debug_print(' Title:', book.title, 'category: ', category)
|
||||||
if category not in book.device_collections:
|
if category not in book.device_collections:
|
||||||
@ -650,35 +661,16 @@ class KOBO(USBMS):
|
|||||||
ContentType = self.get_content_type_from_extension(extension) if extension != '' else self.get_content_type_from_path(book.path)
|
ContentType = self.get_content_type_from_extension(extension) if extension != '' else self.get_content_type_from_path(book.path)
|
||||||
|
|
||||||
ContentID = self.contentid_from_path(book.path, ContentType)
|
ContentID = self.contentid_from_path(book.path, ContentType)
|
||||||
|
|
||||||
|
if category in readstatuslist.keys():
|
||||||
|
# Manage ReadStatus
|
||||||
self.set_readstatus(connection, ContentID, readstatuslist.get(category))
|
self.set_readstatus(connection, ContentID, readstatuslist.get(category))
|
||||||
if category == 'Shortlist':
|
if category == 'Shortlist':
|
||||||
debug_print("Category: ", category)
|
# Manage FavouritesIndex/Shortlist
|
||||||
cursor = connection.cursor()
|
self.set_favouritesindex(connection, ContentID)
|
||||||
for book in books:
|
|
||||||
debug_print(' Title:', book.title, 'category: ', category)
|
|
||||||
if 'Shortlist' not in book.device_collections:
|
|
||||||
book.device_collections.append('Shortlist')
|
|
||||||
# debug_print ("Shortlist found for: ", book.title)
|
|
||||||
extension = os.path.splitext(book.path)[1]
|
|
||||||
ContentType = self.get_content_type_from_extension(extension) if extension != '' else self.get_content_type_from_path(book.path)
|
|
||||||
|
|
||||||
ContentID = self.contentid_from_path(book.path, ContentType)
|
|
||||||
# datelastread = time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime())
|
|
||||||
|
|
||||||
t = (ContentID,)
|
|
||||||
|
|
||||||
try:
|
|
||||||
cursor.execute('update content set FavouritesIndex=1 where BookID is Null and ContentID = ?', t)
|
|
||||||
except:
|
|
||||||
debug_print('Database Exception: Unable set book as Shortlist')
|
|
||||||
raise
|
|
||||||
else:
|
|
||||||
connection.commit()
|
|
||||||
# debug_print('Database: Commit set Shortlist as Shortlist')
|
|
||||||
|
|
||||||
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 to 0")
|
debug_print("No Collections - reseting ReadStatus")
|
||||||
self.reset_readstatus(connection, oncard)
|
self.reset_readstatus(connection, oncard)
|
||||||
debug_print("No Collections - reseting FavouritesIndex")
|
debug_print("No Collections - reseting FavouritesIndex")
|
||||||
self.reset_favouritesindex(connection, oncard)
|
self.reset_favouritesindex(connection, oncard)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user