diff --git a/src/calibre/devices/prst1/driver.py b/src/calibre/devices/prst1/driver.py index ca8e2ae435..22ef567280 100644 --- a/src/calibre/devices/prst1/driver.py +++ b/src/calibre/devices/prst1/driver.py @@ -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):