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 08-07-2017, 04: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, 252 views)
lucask is offline   Reply With Quote
Old 08-07-2017, 05:21 PM   #2
BetterRed
null operator (he/him)
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: 20,550
Karma: 26954694
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 online now   Reply With Quote
Old 08-07-2017, 11:01 PM   #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: 43,842
Karma: 22666666
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, 01: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, 01: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: 43,842
Karma: 22666666
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, 02: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: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
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 offline   Reply With Quote
Old 08-24-2017, 06: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: 71,495
Karma: 306214458
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
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, 06: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


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 09:02 AM
Writing a first plugin Agama Development 50 07-07-2012 04:06 PM
Calibre checksums? Suffolk Punch Calibre 6 05-14-2011 11:49 PM
Help with plugin writing meme Plugins 2 01-21-2011 01:57 PM
Writing an interface action plugin kiwidude Plugins 21 11-11-2010 04:11 PM


All times are GMT -4. The time now is 05:24 AM.


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