Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 02-03-2015, 10:39 AM   #1
ahisham
Junior Member
ahisham began at the beginning.
 
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'});
However, it didn't get saved!!

What else I need to modify to get it working ?
ahisham is offline   Reply With Quote
Old 02-03-2015, 11:57 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
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.
kovidgoyal is offline   Reply With Quote
Advert
Old 02-03-2015, 12:28 PM   #3
ahisham
Junior Member
ahisham began at the beginning.
 
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
ahisham is offline   Reply With Quote
Old 02-03-2015, 09:18 PM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
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.
kovidgoyal is offline   Reply With Quote
Old 02-04-2015, 06:37 AM   #5
ahisham
Junior Member
ahisham began at the beginning.
 
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
ahisham is offline   Reply With Quote
Advert
Old 02-04-2015, 07:04 AM   #6
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ahisham View Post
Another question, is it possible to escape commas and dots characters in values in this genre column ?

Thanks
No.

Quote:
Originally Posted by ahisham View Post
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
Before you do the search/replace, search for publishers comtaining a '#' and select the results.
chaley is offline   Reply With Quote
Old 02-05-2015, 09:53 AM   #7
ahisham
Junior Member
ahisham began at the beginning.
 
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'});
ahisham is offline   Reply With Quote
Reply


Forum Jump

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


All times are GMT -4. The time now is 03:23 AM.


MobileRead.com is a privately owned, operated and funded community.