diff --git a/src/calibre/devices/prst1/driver.py b/src/calibre/devices/prst1/driver.py index 02913b0bcc..fff8186f8c 100644 --- a/src/calibre/devices/prst1/driver.py +++ b/src/calibre/devices/prst1/driver.py @@ -57,6 +57,7 @@ class PRST1(USBMS): THUMBNAIL_HEIGHT = 144 SUPPORTS_SUB_DIRS = True + SUPPORTS_USE_AUTHOR_SORT = True MUST_READ_METADATA = True EBOOK_DIR_MAIN = 'Sony_Reader/media/books' @@ -257,13 +258,25 @@ class PRST1(USBMS): newmi = book # Get Metadata We Want - lpath = book.lpath + # Make sure lpath uses Unix-style strings + lpath = book.lpath.replace('\\', '/') try: - author = newmi.authors[0] + if opts.use_author_sort: + if newmi.author_sort : + author = newmi.author_sort + else: + author = authors_to_sort_string(newmi.authors) + else: + author = newmi.authors[0] except: author = _('Unknown') title = newmi.title or _('Unknown') + # Get modified date + modified_date = os.path.getmtime(book.path) + time_offset = time.altzone if time.daylight else time.timezone + modified_date = (modified_date - time_offset) * 1000 + if lpath not in db_books: query = ''' INSERT INTO books @@ -273,8 +286,8 @@ class PRST1(USBMS): values (?,?,?,?,?,?,?,?,?,0,0) ''' t = (title, author, source_id, int(time.time() * 1000), - int(calendar.timegm(book.datetime) * 1000), lpath, - os.path.basename(book.lpath), book.size, book.mime) + modified_date, lpath, + os.path.basename(lpath), book.size, book.mime) cursor.execute(query, t) book.bookId = cursor.lastrowid if upload_covers: @@ -286,8 +299,7 @@ class PRST1(USBMS): SET title = ?, author = ?, modified_date = ?, file_size = ? WHERE file_path = ? ''' - t = (title, author, int(calendar.timegm(book.datetime) * 1000), book.size, - lpath) + t = (title, author, modified_date, book.size, lpath) cursor.execute(query, t) book.bookId = db_books[lpath] if refresh_covers: