02-20-2012, 06:54 PM | #1 | ||
hopeless n00b
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Sony Collections: Manual Management
I believe if you have Automatic Management enabled, it's possible to customize collection names to something like "Series: Harry Potter", "Genre: Fantasy" by using the following tweak:
Code:
sony_collection_renaming_rules={'series':'Series', 'tags':'Genre'} sony_collection_name_template='{category:||: }{value}' If that's not possible, would Automatic Management work with a multi-library, multiple calibre install scenario? For example, what would happen if the same reader was connected/synced to the following computers/libraries. Quote:
Quote:
|
||
02-21-2012, 06:23 AM | #2 | ||
Grand Sorcerer
Posts: 11,740
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
In manual mode, books are added to collections only when they are sent to the device. Metadata changes made after that point are ignored. In addition, books are only added to collections, they are never deleted. Finally, in manual mode no renaming rules or ordering rules are used, so the tweaks you mention will be ignored. Last point: the interactions in manual mode between calibre, the device, and (if used) Sony Reader are complicated. There is a good chance that you will get some unexpected results. Quote:
There is another dragon here: ondevice identification. When you send a book to the sony or match a book to the library using metadata, the book's unique ID (UUID) is stored in the metadata.calibre file on the device. This UUID is used to map a book back to the source book in the calibre library. If a book appears in more than one library, it will have more than one UUID, and the UUID of the last matching library is what will appear in metadata.calibre. Because of this, there is a good chance that connections between a book and a library will be lost, especially when plugboards modify the metadata in the book. It is worth noting that you can get an approximation of your desired collections when using manual mode only if you send the book from each library. |
||
Advert | |
|
02-21-2012, 10:58 AM | #3 | |
hopeless n00b
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Quote:
I went into Preferences » Plugins » Customize SONY Device Interface and the default for collections is: series, tags If I want series to show up as Series: Series Name and the tags to show up as Category: Tag Name or Genre: Tag Name (would be using different Calibre Portable installs so I don't ever forget to change settings when sending ebooks), what should I need to change the collections option to? If that's not possible, do you know what I might be able to do to quickly creating custom columns using existing metadata? I figure if I can't customize the device interface plugin to automatically generate the custom collection names, I should be able to use custom columns instead and use those to generate collections. e.g. Code:
series #myseries ( Harry Potter -> Series: Harry Potter Twilight -> Series: Twilight tags #category Harry Potter, Twilight -> Category: Harry Potter, Category: Twilight Code:
tags #type #genre Fiction, Children, Fantasy -> Fiction Genre: Children, Genre: Fantasy Fiction, Supernatural -> Fiction Genre: Supernatural FanFiction, Humor -> FanFiction Genre: Humor Magazine -> Magazine Thanks so much! Last edited by ilovejedd; 02-21-2012 at 11:17 AM. Reason: Fingers not keeping up with thoughts... |
|
02-21-2012, 11:14 AM | #4 |
Grand Sorcerer
Posts: 6,233
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
I have manual management and diferent collections according to tags and custom colums, and no problem.
|
02-21-2012, 11:57 AM | #5 | |||
hopeless n00b
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Quote:
Quote:
Quote:
|
|||
Advert | |
|
02-21-2012, 12:35 PM | #6 |
Grand Sorcerer
Posts: 11,740
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
@ilovejedd: If you use manual management then sony_collection_name_template is ignored. If you want to have the category name (as in "Genre") in front of the category value(s) you must put it there yourself.
You can indeed do what you want with an is_multiple composite custom column (built from other cols, like tags). The template for the column would create a set of comma-separated values of the form "Genre: value, Category:value, value" or whatever you want. The hard part is the template. It needs to check several fields for specific values and construct the appropriate list for the custom column. What I would do is write a custom template function that does the job. Going this route gives you the full power and performance of python, of course at the cost of requiring knowledge of python. The function would get the values of tags, series, and what-have-you (I am not following all the details of the transformations you describe) and would construct the value for the composite column. This post shows some of what you would do in the template function. What is missing is that you can get arbitrary metadata items for a book from the kwargs parameter. For example, kwargs.get('series') will return the value of the series or None if there isn't one. Similarly, kwargs.get('tags') will return a list of tags on the book. You use the lookup name as the parameter for 'get'. From what I understand, you would want a different function in each library, but I am not sure of that. You could do this in a general program mode template using in_list, list_union, and the like, but it would most likely be very slow. |
02-21-2012, 02:49 PM | #7 | |
hopeless n00b
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Quote:
For example, I have the following: Code:
Title Series Tags Harry Potter and the Philosopher's Stone Harry Potter [1.0] Fiction, Children, Fantasy Twilight Twilight [1.0] Fiction, Paranormal Code:
Title #MySeries #Type #Genre Harry Potter and the Philosopher's Stone Series: Harry Potter [1.0] Fiction Genre: Children, Genre: Fantasy Twilight Series: Twilight [1.0] Fiction Genre: Paranormal #Type: If certain pre-defined values are in tags (Fiction, Non-Fiction, Fanfiction, Magazine), it goes to this column. #Genre: Basically all tags (excluding Fiction, Non-Fiction, Fanfiction & Magazine) with "Genre: " added to the beginning of string. I'm trying to understand your sample code but as I'm a total noob to Python, I'm finding it quite difficult to comprehend. |
|
02-22-2012, 02:50 AM | #8 |
Grand Sorcerer
Posts: 11,740
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Here is a general program mode template that does what I think you want. It puts all values into one custom column, not three
Code:
program: categories = 'Fiction, Non-Fiction, Fanfiction, Magazine'; types = list_intersection(field('tags'), categories, ','); genres = list_re(list_difference(field('tags'), categories, ','), ',', '^', 'Genre: ') ; series = test(field('series'), strcat('Series: ' , field('series'), ' [', field('series_index'), ']'), ''); list_union(types, list_union(genres, series, ','), ',') Code:
Function: myFunc or whatever you want Arg count: 0 Documentation: whatever you want Program code: def evaluate(self, formatter, kwargs, mi, locals): # create a set of categories categories = {'fiction', 'non-fiction', 'fanfiction', 'magazine'} # get a list of non-empty tags tags = [v.strip() for v in kwargs.get('tags') if v.strip()] res = [] for v in tags: if v.lower() in categories: # tag is in categories. Add it 'as is' to the result list res.append(v) else: # tag is not in categories. Add it as a genre to the result list res.append('Genre: ' + v) # add the series if there is one series = kwargs.get('series') if series: res.append('Series: ' + series + (' [%3.1f]'%kwargs.get('series_index'))) return ', '.join(res) Code:
{:'myFunc()'} Code:
Function: myFunc or whatever you want Arg count: 0 Documentation: whatever you want Program code: def evaluate(self, formatter, kwargs, mi, locals, cats): categories = set([v.strip() for v in cats.split(',') if v.strip()]) tags = [v.strip() for v in kwargs.get('tags') if v.strip()] res = [] for v in tags: if v.lower() in categories: res.append(v) else: res.append('Genre: ' + v) series = kwargs.get('series') if series: res.append('Series: ' + series + (' [%3.1f]'%kwargs.get('series_index'))) return ', '.join(res) Code:
{:'myFunc('fiction, non-fiction, fanfiction, magazine')'} Last edited by chaley; 02-22-2012 at 10:29 AM. Reason: fix typo in second template function |
02-22-2012, 10:15 AM | #9 | |
hopeless n00b
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Thanks! I used the last one and it seems to be working great (just had a small typo v,lower() instead of v.lower()). Curious about the series information (Series: My Series [n.n]), wouldn't having the series index in there create a separate collection for each book in a series?
Also, I wonder how do you run the following? Quote:
|
|
02-22-2012, 10:25 AM | #10 | ||
Grand Sorcerer
Posts: 11,740
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
|
||
02-22-2012, 10:26 AM | #11 |
Well trained by Cats
Posts: 29,792
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
That goes in place of a simple template (anywhere one is allowed)
|
02-22-2012, 11:02 AM | #12 | ||
hopeless n00b
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Quote:
Quote:
Really, a very, very, very big for all the help! Last edited by ilovejedd; 02-22-2012 at 11:07 AM. |
||
02-23-2012, 10:54 AM | #13 |
hopeless n00b
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Woohoo. Just installed a nightly build of PRS+ (thanks Analogus!) and it now supports sub-collections. Granted, it's just one level but that's good enough for me. Here's a revised template to get sub-collections. Basically the same as chaley's script above except it uses Series| and Genre| as the prefix instead of Series: and Genre:
Code:
''' Function: myFunc Arg count: 1 Documentation: myFunc(categories) -- Format tags and series so they show up as sub-collections on the PRS+ custom firmware for Sony Readers. example: {:'myFunc('fiction, non-fiction, fanfiction, magazine, news')'} - Creates a top-level collection for any tag named fiction, non-fiction, fanfiction, magazine or news. All other tags will be created as sub-collections under Genre. ''' def evaluate(self, formatter, kwargs, mi, locals, cats): categories = set([v.strip() for v in cats.split(',') if v.strip()]) tags = [v.strip() for v in kwargs.get('tags') if v.strip()] res = [] for v in tags: if v.lower() in categories: res.append(v) else: res.append('Genre|' + v) series = kwargs.get('series') if series: res.append('Series|' + series) return ', '.join(res) I've also created a modified version of the script which would create the sub-collections under the main categories. e.g. Fiction, Children, Fantasy -> Fiction, Fiction|Children, Fiction|Fantasy FanFiction, Harry Potter, Twilight -> FanFiction, FanFiction|Harry Potter, FanFiction|Twilight News, New York Times -> News, News|New York Times Code:
''' Function: myFunc Arg count: 1 Documentation: myFunc(categories) -- Format tags and series so they show up as sub-collections on the PRS+ custom firmware for Sony Readers. example: {:'myFunc('fiction, non-fiction, fanfiction, magazine, news')'} - Creates a top-level collection for any tag named fiction, non-fiction, fanfiction, magazine or news. All other tags will be created as sub-collections under one of the top-level collections. If a main category isn't found, the book is assigned to Fiction. ''' def evaluate(self, formatter, kwargs, mi, locals, cats): categories = set([v.strip() for v in cats.split(',') if v.strip()]) tags = [v.strip() for v in kwargs.get('tags') if v.strip()] res = [] booktype = '' for v in tags: if v.lower() in categories: booktype = v if booktype == '': booktype = 'Fiction' res.append(booktype) for v in tags: if v.lower() not in categories: res.append(booktype + '|' + v) series = kwargs.get('series') if series: res.append('Series|' + series) return ', '.join(res) Screenshots of how sub-collections work can be found here: https://www.mobileread.com/forums/sho...postcount=2964 |
02-24-2012, 09:31 PM | #14 |
hopeless n00b
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Question on manual/only on send metadata management behavior:
If the books already exist on the device and I just want to update the metadata (e.g. to update collections, etc), would selecting "Send to Device" also re-send the actual epubs? Reason I'm asking is because PRS+ sub-collections are still kind of a moving target. Currently, I'm just using subsets of my libraries to test sub-collections (while also trying to figure out what would be the best way to organize my ebooks). Wouldn't want to send 3000 books to my reader only to have to do it over and over again whenever I need to update collections. |
02-24-2012, 11:17 PM | #15 | |
Grand Sorcerer
Posts: 11,740
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Also note that collections are merged when you resend. Removing a tag from the book then resending will not remove the book from that tag's collection. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Sony PRS-T1] seeking advice on library management and collections | Ozric | Library Management | 16 | 11-06-2011 10:51 AM |
Sony - 2 questions about automatic management | ThR | Devices | 0 | 03-18-2011 02:57 AM |
Sony collection management changes in calibre 0.7.9 | chaley | Calibre | 30 | 07-18-2010 08:29 PM |
Manual Creation / Management of Collections | ahi | Sony Reader | 11 | 06-25-2009 08:50 AM |
sony reader manual | bugsbunny14 | Sony Reader | 5 | 09-26-2006 07:06 PM |