Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 08-25-2019, 07:47 PM   #1
thiago.eec
Addict
thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.
 
Posts: 209
Karma: 71602
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
Set a value to a custom column inside a plugin

Hi everyone.

I'm trying to set a value to a custom column, but got stuck.

Here is what I got:

Code:
mi = db.get_metadata(book_id)
mi.set_user_metadata(#percentage, progress)
But it doesn't work, because 'progress' just a integer.
According to the Manual, I should use:

Code:
set_user_metadata(field, metadata)
How is a 'metadata' represented? I've noticed is not just a value, but I can't figure out how to make it work.
thiago.eec is offline   Reply With Quote
Old 08-26-2019, 12:21 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: 35,458
Karma: 12734961
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Assuming percentage is a numeric field it should be fine. But if what youwant to do is set it in the custom column in the database, the way to do it is like this:

db.new_api.set_field('#percentage', {book_id: value})
kovidgoyal is online now   Reply With Quote
Advert
Old 08-27-2019, 06:48 PM   #3
thiago.eec
Addict
thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.thiago.eec knows who John Galt is.
 
Posts: 209
Karma: 71602
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
Thanks, Kovid.

That worked.
thiago.eec is offline   Reply With Quote
Reply

Tags
custom columns, metadata

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set value of custom column automatically? steins Plugins 5 12-27-2018 04:23 AM
Set default value of a custom column laszlopanaflex Library Management 2 12-01-2018 03:54 PM
How to set the number of decimals in a custom column sekhemty Library Management 3 04-28-2017 10:06 AM
Set Custom Column from identify.py ahisham Development 6 02-05-2015 10:53 AM
Using OnDevice to set the value of a custom column WendyR14 Library Management 3 10-23-2011 09:03 PM


All times are GMT -4. The time now is 10:36 PM.


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