From d7986e12baff8b98ec6fd8c280ced9385c6bd626 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Tue, 21 Dec 2010 20:37:19 +0000 Subject: [PATCH] Changes to the sony auto-collections tweak requested by Kovid. Also take the author_sort from the device_db plugboard, if it is available. --- resources/default_tweaks.py | 24 ++++++++++++------------ src/calibre/devices/usbms/books.py | 11 +++++++++-- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/resources/default_tweaks.py b/resources/default_tweaks.py index d15ffd4339..3835bcd656 100644 --- a/resources/default_tweaks.py +++ b/resources/default_tweaks.py @@ -180,22 +180,22 @@ sony_collection_renaming_rules={} # Default: empty (no rules), so no collection attributes are named. sony_collection_sorting_rules = [] -# Specify whether special collections are to be made. The two available are -# all_by_author and all_by_title. These collections work around various device -# idiosyncrasies regarding sorting of lists. The all by author collection is -# sorted by author(s) then title. The by title collection is sorted by title -# then authors(s) +# Specify whether special collections are to be made. This option is primarily +# of use on a Sony. The two available are all_by_author and all_by_title. These +# collections work around various device idiosyncrasies regarding sorting of +# lists, especially the sony *50 models. The author collection is sorted by +# author(s) then title. The title collection is sorted by title then authors(s) # Enable a collection by entering a collection name in the variable. That # collection name must be unique. # Examples: -# sony_all_books_by_author_collection = '%All by author' -# create a collection of all books sorted by author -# sony_all_books_by_title_collection = '%All by title' -# create a collection of books sorted by title, respecting the order tweaks -# sony_all_books_by_author_collection = '' +# device_special_collections = {'title':'', 'author':'%All by author'} +# create a collection named '%All by author' of all books sorted by author +# device_special_collections = {'title':'%All by title', 'author':''} +# create a collection named '%All by title' of books sorted by title, +# respecting the order tweaks +# sony_all_books_by_author_collection = {'title':'', 'author':''} # disable the collection -sony_all_books_by_author_collection = '' -sony_all_books_by_title_collection = '' +device_special_collections = {'title':'', 'author':''} # Create search terms to apply a query across several built-in search terms. diff --git a/src/calibre/devices/usbms/books.py b/src/calibre/devices/usbms/books.py index 0f78b85a57..84b8585d5c 100644 --- a/src/calibre/devices/usbms/books.py +++ b/src/calibre/devices/usbms/books.py @@ -133,8 +133,15 @@ class CollectionsBookList(BookList): collections = {} - all_by_author = tweaks['sony_all_books_by_author_collection'] - all_by_title = tweaks['sony_all_books_by_title_collection'] + # get the special collection names + try: + all_by_author = tweaks['device_special_collections']['author'] + except: + all_by_author = '' + try: + all_by_title = tweaks['device_special_collections']['title'] + except: + all_by_title = '' for book in self: tsval = book.get('_pb_title_sort',