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
|
# Get Metadata We Want
|
||||||
lpath = book.lpath
|
lpath = book.lpath
|
||||||
author = newmi.authors[0]
|
try:
|
||||||
title = newmi.title
|
author = newmi.authors[0]
|
||||||
|
except:
|
||||||
|
author = _('Unknown')
|
||||||
|
title = newmi.title or _('Unknown')
|
||||||
|
|
||||||
if lpath not in db_books:
|
if lpath not in db_books:
|
||||||
query = '''
|
query = '''
|
||||||
@ -405,34 +408,34 @@ class PRST1(USBMS):
|
|||||||
|
|
||||||
def upload_cover(self, path, filename, metadata, filepath):
|
def upload_cover(self, path, filename, metadata, filepath):
|
||||||
debug_print('PRS-T1: uploading cover')
|
debug_print('PRS-T1: uploading cover')
|
||||||
|
|
||||||
if filepath.startswith(self._main_prefix):
|
if filepath.startswith(self._main_prefix):
|
||||||
prefix = self._main_prefix
|
prefix = self._main_prefix
|
||||||
source_id = 0
|
source_id = 0
|
||||||
else:
|
else:
|
||||||
prefix = self._card_a_prefix
|
prefix = self._card_a_prefix
|
||||||
source_id = 1
|
source_id = 1
|
||||||
|
|
||||||
metadata.lpath = filepath.partition(prefix)[2]
|
metadata.lpath = filepath.partition(prefix)[2]
|
||||||
dbpath = self.normalize_path(prefix + DBPATH)
|
dbpath = self.normalize_path(prefix + DBPATH)
|
||||||
debug_print("SQLite DB Path: " + dbpath)
|
debug_print("SQLite DB Path: " + dbpath)
|
||||||
|
|
||||||
with closing(sqlite.connect(dbpath)) as connection:
|
with closing(sqlite.connect(dbpath)) as connection:
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
query = 'SELECT _id FROM books WHERE file_path = ?'
|
query = 'SELECT _id FROM books WHERE file_path = ?'
|
||||||
t = (metadata.lpath,)
|
t = (metadata.lpath,)
|
||||||
cursor.execute(query, t)
|
cursor.execute(query, t)
|
||||||
|
|
||||||
for i, row in enumerate(cursor):
|
for i, row in enumerate(cursor):
|
||||||
metadata.bookId = row[0]
|
metadata.bookId = row[0]
|
||||||
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
if metadata.bookId is not None:
|
if metadata.bookId is not None:
|
||||||
debug_print('PRS-T1: refreshing cover for book being sent')
|
debug_print('PRS-T1: refreshing cover for book being sent')
|
||||||
self.upload_book_cover(connection, metadata, source_id)
|
self.upload_book_cover(connection, metadata, source_id)
|
||||||
|
|
||||||
debug_print('PRS-T1: done uploading cover')
|
debug_print('PRS-T1: done uploading cover')
|
||||||
|
|
||||||
def upload_book_cover(self, connection, book, source_id):
|
def upload_book_cover(self, connection, book, source_id):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user