![]() |
#1 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,056
Karma: 11491187
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Getting BookId from viewer plugin
Hi,
I'm trying to make a plugin for updating some metadata when a book is loaded inside the viewer. My problem at this moment is that I don't know how to get the book id (or the title and author, is the same) from inside the plugin. I don't know if it is not possible or I haven't looked at the proper point. Thanks in advance |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 42,960
Karma: 20900374
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Viewer plugins have no access to the database. They cannot since the the viewer can be run on books outside of a calibre library as well. I assume what you want to do is have calibre run embed metadata automatically when you click the view button?
If so, create a calibre plugin that duplicates the builtin view plugin, except that it run the embed metadata plugin before opening the file in the viewer. Then you can use this plugin to replace the view button in your calibre. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,056
Karma: 11491187
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
I'll try to see how to implement this, I'm not so sure I'm able to do it.
|
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 42,960
Karma: 20900374
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
It's very easy if you just modify the calibre source code instead of trying to do it via a plugin. All you have to do is modify the view_format_by_id() method in actions/view.py add a call to db.embed_metadata() to update the metadata in the book format.
|
![]() |
![]() |
![]() |
#5 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,056
Karma: 11491187
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Quote:
Thank you very much, really |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 42,960
Karma: 20900374
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I suggest you setup calibre to run from source. Otherwise, you'd essentially have to clone parts of the builtin view plugin from actions/view.py into your own plugin.
|
![]() |
![]() |
![]() |
#7 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,056
Karma: 11491187
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Yes, I agree. Thank you again.
|
![]() |
![]() |
![]() |
#8 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,056
Karma: 11491187
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Quote:
Thank you again. |
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Viewer Plugin] Text to Speech | chye | Plugins | 19 | 10-24-2020 04:09 AM |
[Viewer Plugin] Get selected text on right click. | jverrone3 | Development | 1 | 03-27-2015 10:57 PM |
dr1000s cbr/cbz viewer or plugin? | maikarl | iRex | 1 | 03-14-2015 02:17 PM |
viewer plugin? | dhunter | Plugins | 1 | 03-08-2012 10:10 PM |
Perfect Viewer PDF Plugin | GJSmith | Kobo Tablets | 9 | 12-01-2011 02:03 PM |