From fd2df7f5a44b350cc172fc61f106489c654c452d Mon Sep 17 00:00:00 2001 From: Kolenka Date: Tue, 11 Oct 2011 19:33:40 -0700 Subject: [PATCH] Sony T1: Bugfixes + Author Sort Ensure path is correct on Windows before updating database Ensure modification time is being used on Windows Enable "Use Author Sort" for the T1 --- src/calibre/devices/prst1/driver.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/calibre/devices/prst1/driver.py b/src/calibre/devices/prst1/driver.py index eeb73da182..8e46541996 100644 --- a/src/calibre/devices/prst1/driver.py +++ b/src/calibre/devices/prst1/driver.py @@ -55,6 +55,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' @@ -255,12 +256,20 @@ 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') + modified_date = os.path.getmtime(book.path) * 1000 if lpath not in db_books: query = ''' @@ -271,8 +280,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: @@ -284,7 +293,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, + t = (title, author, modified_date, book.size, lpath) cursor.execute(query, t) book.bookId = db_books[lpath]