08-21-2020, 08:22 AM | #1 |
Member
Posts: 21
Karma: 10
Join Date: Apr 2019
Device: Kindle
|
How to set customer column value in plugin?
Hi there, I have a plugin called "douban.py", which can get some metadata from a website, and I also create a customer column called "#douban_rating".
In the douban.py file, there're code like this: Code:
def to_metadata(self, browser, log, entry_, timeout): # {{{ from calibre.utils.date import parse_date, utcnow #...... # Ratings if rating: try: mi.rating = float(rating['average']) / 2.0 except: log.exception('Failed to parse rating') mi.rating = 0 #...... Thanks a lot. |
08-21-2020, 09:18 AM | #2 |
creator of calibre
Posts: 44,380
Karma: 23766374
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Metadata download plugins can only store data in builtin columns, not custom one.
|
Advert | |
|
08-21-2020, 10:40 AM | #3 |
Member
Posts: 21
Karma: 10
Join Date: Apr 2019
Device: Kindle
|
Well, are there any workaround to do that? maybe i could just save the value into a txt file, then write a script to load them into my column?
or any other method? i just want to save the rating value into my column. thanks for reply. |
08-21-2020, 11:14 AM | #4 |
creator of calibre
Posts: 44,380
Karma: 23766374
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Save it as a tag and use a custom column template to display it in another column or use search and replace to copy it into another column.
|
08-21-2020, 11:21 AM | #5 |
Member
Posts: 21
Karma: 10
Join Date: Apr 2019
Device: Kindle
|
that seems OK, but i'm not sure how to do that:
"use a custom column template to display it in another column" "use search and replace to copy it into another column" could you give me a demo? |
Advert | |
|
08-21-2020, 05:27 PM | #6 |
null operator (he/him)
Posts: 20,946
Karma: 27620688
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
@likekindle - for the Skoob bookstore (Brazilian) there are two plugins, a Metadata Download plugin, and a GUI plugin called Skoob Synch, you might want to have a look at those, and IIRC Goodreads might have something similar. See ==>> Index of plugins
BR |
08-21-2020, 10:47 PM | #7 |
Grand Sorcerer
Posts: 24,905
Karma: 47303822
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
The Goodreads_rating plugin does it by adding the rating to the publisher column and then the F_rating plugin moves this to the separate column.
|
08-22-2020, 05:20 AM | #8 |
Member
Posts: 21
Karma: 10
Join Date: Apr 2019
Device: Kindle
|
@BetterRed Thanks, it seems a little complicated for me, i may try it later if i have no other ways.
|
08-22-2020, 05:29 AM | #9 |
Member
Posts: 21
Karma: 10
Join Date: Apr 2019
Device: Kindle
|
@davidfor
that's clever, i've tried the plugins, and they work for me, i could get rating from goodreads and store the value into a custom column. Then I have to modify my douban plugin just like the goodreads, right? maybe something like this: Code:
if rating: try: #print(float(rating['average'])) my_rate = float(rating['average']) print(title + " ----: " + str(my_rate)) if not(mi.rating==None): mi.publisher+="#PrB.rating#"+ str(my_rate) print ('mi.publisher:', mi.publisher) mi.rating = float(rating['average']) / 2.0 except: log.exception('Failed to parse rating') mi.rating = 0 |
08-22-2020, 06:48 AM | #10 | |
Grand Sorcerer
Posts: 24,905
Karma: 47303822
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Quote:
|
|
08-22-2020, 07:25 AM | #11 |
Member
Posts: 21
Karma: 10
Join Date: Apr 2019
Device: Kindle
|
@davidfor
Thank you so much, it works for me, and saves a lot of time for me. Cheers |
Tags |
custom column, metadata, plugin development |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Set a value to a custom column inside a plugin | thiago.eec | Development | 2 | 08-27-2019 05:48 PM |
How to set value of custom column automatically? | steins | Plugins | 5 | 12-27-2018 03:23 AM |
Set or Freeze Column Widths? | Nyssa | Library Management | 14 | 11-20-2014 02:57 PM |
Set value of another column from composite? | dirgeon | Library Management | 1 | 02-03-2013 11:40 AM |
Using OnDevice to set the value of a custom column | WendyR14 | Library Management | 3 | 10-23-2011 08:03 PM |