02-03-2015, 10:39 AM | #1 |
Junior Member
Posts: 8
Karma: 10
Join Date: Aug 2014
Device: none
|
Set Custom Column from identify.py
Hi,
With reference to this post: https://www.mobileread.com/forums/sho...3&postcount=11 My aim is to save a value for custom column retrieved from a metadata plugin like amazon.py. To confirm, I just need this once and will revert my code changes back once run. @kovidgoyal suggested to modify the identify.py to be able to save the custom metadata. I tried (static data) this at end of merge function: Code:
ans.set_user_metadata("#genre", {'#value#': ['Ebooks.Language.Java','Ebooks.Language.Python'], 'datatype':'text', 'is_multiple': '|', 'name': u'Genre'}); What else I need to modify to get it working ? |
02-03-2015, 11:57 AM | #2 |
creator of calibre
Posts: 43,859
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You cannot save custom metadata from a metadata download plugin. That would make no sense, since there is no guarantee that different users would have the same custom columns. To enable that you would need to allow metadata plugins to be customized with a list of custom columns to save to, which is not worth the effort for me.
|
Advert | |
|
02-03-2015, 12:28 PM | #3 |
Junior Member
Posts: 8
Karma: 10
Join Date: Aug 2014
Device: none
|
Thanks kovidgoyal ..
Sure .. I just want to modify my own local library with these custom values. Also, this is for one time only, i.e. download metadata, save values in custom columns, revert back my code changes. For me, I followed http://manual.calibre-ebook.com/sub_groups.html and created custom column with lookup key "#genre", heading as "Genre" and type as "Comma-separated text, like tags, shown in the tag browser". My question is how to save (the shown sample static data) in database ? Another question, is it possible to escape commas and dots characters in values in this genre column ? Thanks |
02-03-2015, 09:18 PM | #4 |
creator of calibre
Posts: 43,859
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Save your metadata in an unused builtin column,like say,publisher,and then use the bulk search and replace tool to copy it over after all your downloads are complete.
|
02-04-2015, 06:37 AM | #5 |
Junior Member
Posts: 8
Karma: 10
Join Date: Aug 2014
Device: none
|
Thanks kovidgoyal ..
I think setting the value from inside identify.py would give more ways for updating the values. But since it seems difficult, I tried setting the value to publisher as you suggested. To keep original publisher data, I separated them by a '#' and updated also the identify.py to handle (merge) the new format. All is good. Now, in bulk search and replace, i use "(.+)#(.+)" to move 2nd group to genre column. The problem is it also moves the value if it doesn't contain '#' separator! How to move the 2nd group from publisher field to genre field only if the '#' exists ? Thanks |
Advert | |
|
02-04-2015, 07:04 AM | #6 | |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Before you do the search/replace, search for publishers comtaining a '#' and select the results. |
|
02-05-2015, 09:53 AM | #7 |
Junior Member
Posts: 8
Karma: 10
Join Date: Aug 2014
Device: none
|
Thanks .. This will work for now.
Please if it is possible to be able to save from identify.py, this will be really helpful. I just need to be able to save this sample data: Code:
ans.set_user_metadata("#genre", {'#value#': ['Ebooks.Language.Java','Ebooks.Language.Python'], 'datatype':'text', 'is_multiple': '|', 'name': u'Genre'}); |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Custom column returns value based on value of another custom column? | calvin-c | Calibre | 3 | 09-14-2013 02:24 PM |
Default Value for Custom Column (fixed set of permitted values) | Andy P | Calibre | 1 | 06-21-2013 03:25 AM |
Automatically set custom column when fetching news | bork | Library Management | 1 | 04-14-2012 03:20 AM |
How do i set dolphin HD to identify as desktop? | Merischino | Kindle Fire | 1 | 12-21-2011 06:09 PM |
Using OnDevice to set the value of a custom column | WendyR14 | Library Management | 3 | 10-23-2011 08:03 PM |