From 79f9adee92cad6df84e5cee10cc91c7c5547af44 Mon Sep 17 00:00:00 2001 From: Kolenka Date: Tue, 11 Oct 2011 10:18:09 -0700 Subject: [PATCH 1/5] Sony T1: Fix typo in if statement when uploading a cover --- src/calibre/devices/prst1/driver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/devices/prst1/driver.py b/src/calibre/devices/prst1/driver.py index 44c93af4cc..eeb73da182 100644 --- a/src/calibre/devices/prst1/driver.py +++ b/src/calibre/devices/prst1/driver.py @@ -443,7 +443,7 @@ class PRST1(USBMS): def upload_book_cover(self, connection, book, source_id): debug_print('PRST1: Uploading/Refreshing Cover for ' + book.title) - if not book.thumbnail and book.thumbnail[-1]: + if not book.thumbnail or not book.thumbnail[-1]: return cursor = connection.cursor() From fd2df7f5a44b350cc172fc61f106489c654c452d Mon Sep 17 00:00:00 2001 From: Kolenka Date: Tue, 11 Oct 2011 19:33:40 -0700 Subject: [PATCH 2/5] 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] From 342d189f87febd19c9ad2b6b6196d4a68d0776c5 Mon Sep 17 00:00:00 2001 From: Kolenka Date: Tue, 11 Oct 2011 19:37:06 -0700 Subject: [PATCH 3/5] Sony T1: Cleanup --- src/calibre/devices/prst1/driver.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/calibre/devices/prst1/driver.py b/src/calibre/devices/prst1/driver.py index 8e46541996..5376eeb87f 100644 --- a/src/calibre/devices/prst1/driver.py +++ b/src/calibre/devices/prst1/driver.py @@ -293,8 +293,7 @@ class PRST1(USBMS): SET title = ?, author = ?, modified_date = ?, file_size = ? WHERE file_path = ? ''' - t = (title, author, modified_date, book.size, - lpath) + t = (title, author, modified_date, book.size, lpath) cursor.execute(query, t) book.bookId = db_books[lpath] if refresh_covers: From b6a7aa34f344cfa4cbd1dcaa96b1b96c731b0368 Mon Sep 17 00:00:00 2001 From: Kolenka Date: Tue, 11 Oct 2011 19:38:01 -0700 Subject: [PATCH 4/5] Sony T1: Cleanup --- src/calibre/devices/prst1/driver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/devices/prst1/driver.py b/src/calibre/devices/prst1/driver.py index 5376eeb87f..592dbd8552 100644 --- a/src/calibre/devices/prst1/driver.py +++ b/src/calibre/devices/prst1/driver.py @@ -256,7 +256,7 @@ class PRST1(USBMS): newmi = book # Get Metadata We Want - # Make sure lpath uses Unix-style strings + # Make sure lpath uses Unix-style strings lpath = book.lpath.replace('\\', '/') try: if opts.use_author_sort: From 9b56902017d0a334be6148f87f42fee51e1d9d6b Mon Sep 17 00:00:00 2001 From: Kolenka Date: Tue, 11 Oct 2011 19:59:44 -0700 Subject: [PATCH 5/5] Sony T1: Use localtime timestamp for modified_date --- src/calibre/devices/prst1/driver.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/calibre/devices/prst1/driver.py b/src/calibre/devices/prst1/driver.py index 592dbd8552..578a9bc65c 100644 --- a/src/calibre/devices/prst1/driver.py +++ b/src/calibre/devices/prst1/driver.py @@ -269,7 +269,11 @@ class PRST1(USBMS): except: author = _('Unknown') title = newmi.title or _('Unknown') - modified_date = os.path.getmtime(book.path) * 1000 + + # 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 = '''