mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
96fdd1799f
commit
430f67c3f5
@ -253,8 +253,11 @@ class PRST1(USBMS):
|
||||
|
||||
# Get Metadata We Want
|
||||
lpath = book.lpath
|
||||
author = newmi.authors[0]
|
||||
title = newmi.title
|
||||
try:
|
||||
author = newmi.authors[0]
|
||||
except:
|
||||
author = _('Unknown')
|
||||
title = newmi.title or _('Unknown')
|
||||
|
||||
if lpath not in db_books:
|
||||
query = '''
|
||||
@ -405,34 +408,34 @@ class PRST1(USBMS):
|
||||
|
||||
def upload_cover(self, path, filename, metadata, filepath):
|
||||
debug_print('PRS-T1: uploading cover')
|
||||
|
||||
|
||||
if filepath.startswith(self._main_prefix):
|
||||
prefix = self._main_prefix
|
||||
source_id = 0
|
||||
else:
|
||||
prefix = self._card_a_prefix
|
||||
source_id = 1
|
||||
|
||||
|
||||
metadata.lpath = filepath.partition(prefix)[2]
|
||||
dbpath = self.normalize_path(prefix + DBPATH)
|
||||
debug_print("SQLite DB Path: " + dbpath)
|
||||
|
||||
with closing(sqlite.connect(dbpath)) as connection:
|
||||
with closing(sqlite.connect(dbpath)) as connection:
|
||||
cursor = connection.cursor()
|
||||
|
||||
|
||||
query = 'SELECT _id FROM books WHERE file_path = ?'
|
||||
t = (metadata.lpath,)
|
||||
cursor.execute(query, t)
|
||||
|
||||
|
||||
for i, row in enumerate(cursor):
|
||||
metadata.bookId = row[0]
|
||||
|
||||
|
||||
cursor.close()
|
||||
|
||||
|
||||
if metadata.bookId is not None:
|
||||
debug_print('PRS-T1: refreshing cover for book being sent')
|
||||
self.upload_book_cover(connection, metadata, source_id)
|
||||
|
||||
|
||||
debug_print('PRS-T1: done uploading cover')
|
||||
|
||||
def upload_book_cover(self, connection, book, source_id):
|
||||
|
Loading…
x
Reference in New Issue
Block a user