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-07-2017, 05:25 PM   #1
lucask
Junior Member
lucask began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Aug 2017
Location: Uganda
Device: none
Help Writing a Plugin for File Checksums

Hello. I'm trying to write a Calibre plugin that will compute MD5 checksums of ebooks and store them in a custom column. I tried writing one following the examples in the manual (attached) but I clearly don't know what I'm doing as the code does nothing. I'd appreciate if anyone with some Python would give a few pointers regarding what I'm not doing right. Thank you.
Attached Files
File Type: py __init__.py (785 Bytes, 63 views)
lucask is offline   Reply With Quote
Old 08-07-2017, 06:21 PM   #2
BetterRed
null operator
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 11,303
Karma: 10578436
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Moderator Notice
@lucask - I moved your thread to the Development sub-forum.

If you read the PLEASE READ BEFORE ... sticky you'll understand why

BR
BetterRed is offline   Reply With Quote
Old 08-08-2017, 12:01 AM   #3
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: 33,613
Karma: 10209576
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
The indentation of the run method is incorrect. And for metadatawriter plugins you need to implement the set_metadata method, not the run method.

Also I'm not sure what you are expecting to do here. If you want to add metadata based on newly added book files to the calibre databse you need to create a filetype plugin not a metadatawriter plugin.

Create a filetype plugin and implement either the postimport() or postadd() methods in it.
kovidgoyal is offline   Reply With Quote
Old 08-24-2017, 02:02 AM   #4
lucask
Junior Member
lucask began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Aug 2017
Location: Uganda
Device: none
Thank you for responding. I have been trying for an embarrassingly long time to understand and implement your suggestion and had the following questions.
1. I intend to apply this plugin to an existing library, not to newly imported books. Should I still try to write postadd() and/or postimport() methods?
2. I have not yet had a successful test, so I don't know if the way I attempt to write to a user-defined column is right. In the GUI these columns are preceded by pound signs (as in #genre). When writing such plugins, is it, for instance 'mi.genre = ((some_code))' or 'mi.#genre = ((some_code))?

Thank you for your time.
lucask is offline   Reply With Quote
Old 08-24-2017, 02:24 AM   #5
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: 33,613
Karma: 10209576
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If you want to apply it to an existing library you will need to create a user interface plugin. I suggest simply adapting an existing plugin such as the Word Count plugin.
kovidgoyal is offline   Reply With Quote
Old 08-24-2017, 03:37 AM   #6
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 15,486
Karma: 25810738
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo,Aura H2O,Glo HD,Aura ONE,Clara HD,Forma;tolino epos
Yes, the Count Pages plugin would be a good example for this. It already iterates over the selected books, does some processing on them in a background and then passes the result back to the foreground for updating into a column.

But, I don't know what the point of calculating a checksum for the books in the library is. There are plenty of things you can do that will change the files in a way to invalidate the checksum (edit, convert, polish, update metadata). And if you send the book outside the library calibre updates the metadata, including the cover, and that won't match the checksum.
davidfor is online now   Reply With Quote
Old 08-24-2017, 07:16 AM   #7
pdurrant
The Grand Mouse 高貴的老鼠
pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.
 
pdurrant's Avatar
 
Posts: 55,139
Karma: 207731578
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage, Yotaphone 2
Perhaps a checksum of the contents of the HTML/CSS/Images, and not of the metadata?
pdurrant is offline   Reply With Quote
Old 10-07-2017, 07:31 PM   #8
botmtl
Enthusiast
botmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel isbotmtl really knows where his or her towel is
 
botmtl's Avatar
 
Posts: 43
Karma: 70238
Join Date: Jun 2014
Device: none
I think having the checksum for the file as it was when it was first imported can still be really useful. I had some plans for something like this for myself.

The context is the key. I regularly grab free books off amazon. When I do, it's not rare that I grab a whole bunch of them in one sitting. That collection of books has gotten pretty big over time. After downloading the books and importing them to calibre, I clean up the tiles, the authors, do the cover thing... basically I work so much on them that on the next batch import, I end up with with duplicates. Having the original checksum (to prevent reimporting books I already imported) would be great in this case and an up-to-date checksum would be useless.
botmtl is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing a plugin and my method isn't being called plugin_dev Development 8 09-20-2014 10:02 AM
Writing a first plugin Agama Development 50 07-07-2012 05:06 PM
Calibre checksums? Suffolk Punch Calibre 6 05-15-2011 12:49 AM
Help with plugin writing meme Plugins 2 01-21-2011 02:57 PM
Writing an interface action plugin kiwidude Plugins 21 11-11-2010 05:11 PM


All times are GMT -4. The time now is 09:54 PM.


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