View Full Version : Plugins


junkml
01-03-2009, 11:21 AM
Hello, I thought I'd start a new thread about the Plugins.

I've finally been able to create a plugin that will work with the Windows Command Line. However, I'm running into one thing.

If I modify the Hello World plugin to work on_import agains .lit files, I get the following error when loading a file:

Loading plugin from C:\Users\Owner\AppData\Roaming\calibre\plugins\Hel lo World Plugin.zip
Traceback (most recent call last):
File "C:\Program Files\calibre\library.zip\calibre\customize\ui.py", line 146,
in _run_filetype_plugins
File "<string>", line 20, in run
File "calibre\ebooks\metadata\meta.pyo", line 87, in set_metadata
AttributeError: 'MetaInformation' object has no attribute 'lower'

kovidgoyal
01-03-2009, 12:27 PM
oops small typo in the hello world plugin:

change

set_metadata(file, ext, mi)

to
set_metadata(file, mi, ext)


But you should be aware that calibre can't set the metadata in lit files. Setting only works for rtf, lrf and epub

junkml
01-03-2009, 12:56 PM
oops small typo in the hello world plugin:

change

set_metadata(file, ext, mi)

to
set_metadata(file, mi, ext)


But you should be aware that calibre can't set the metadata in lit files. Setting only works for rtf, lrf and epub

Cool thanks.

Another question, though. Is there any way to have Calibre re-read the metadata from the file within the plugin?

kovidgoyal
01-03-2009, 01:33 PM
Cool thanks.

Another question, though. Is there any way to have Calibre re-read the metadata from the file within the plugin?

If you want to change the way calibre reads metadata from files, you have to create a metadata reader plugin. Its in the documentation.

junkml
01-03-2009, 01:42 PM
If you want to change the way calibre reads metadata from files, you have to create a metadata reader plugin. Its in the documentation.

My bad. I didn't delve into the Metadata section of your documentation.

I do appreciate your patience with all this!

junkml
01-03-2009, 10:21 PM
Ok. I have to admit that I'm stumped again.

I've got a metadata reader that shows up and appears to run when adding a file to calibre, but it isn't picking up the metadata from the file (a non-drm lit file).

I'm afraid I need to ask for some pointers again.

kovidgoyal
01-03-2009, 11:25 PM
This plugin is identical to the built in lit metadata plugin. If that is failing to pick up metadata, this will too.

junkml
01-04-2009, 08:59 AM
This plugin is identical to the built in lit metadata plugin. If that is failing to pick up metadata, this will too.

The problem is, the built in lit plugin will get the metadata from my file, but if I disable it, and add this one, nothing happens. There's no error when adding at the command line, but no metadata come through.

I deliberately started with the same setup as your current lit metadata code. I figured once I can get that running as my own plugin, then I can work on customizing it. My first step was just to make sure I could get the plugin running at all.

kovidgoyal
01-04-2009, 12:49 PM
Ah ok, now I understand. I'm somewhat swamped in work at the moment. Could you opena aticket and attach your plugin and I'll get around to figuring out why it doesn't work in the next couple of days.

junkml
01-04-2009, 01:27 PM
Ah ok, now I understand. I'm somewhat swamped in work at the moment. Could you opena aticket and attach your plugin and I'll get around to figuring out why it doesn't work in the next couple of days.

No problem. I figured it was something simple I was missing. I'll open a ticket in a little while.

Thanks again!

junkml
01-05-2009, 07:45 PM
Kovid, noticed that version 4.126 is out, and says the status for the ticket on the metadata plugin is closed.

Is there something else that has to be changed with the .py file attached to the ticket, in order for it to work?

I use that script, but there is still nothing coming in for the metadata, even though the built-in plugin for .lit metadata works.

Sorry to keep pestering you, but this is the last little piece I need to get working.

Thanks.

kovidgoyal
01-05-2009, 08:06 PM
Yeah the problem should have been fixed in 126. At least your plugin was working for me. Try insering a print statement at the start of the run method and see if you get any output when running calibredb add

junkml
01-05-2009, 09:08 PM
Yeah the problem should have been fixed in 126. At least your plugin was working for me. Try insering a print statement at the start of the run method and see if you get any output when running calibredb add

put a print statement before the "return" statement, and it showed up when running on the command line, but still no metadata.

I did a print on ftype, stream, and get_metadata(stream, ftype), and this is what it output:

C:\Users\Owner\Documents\My Library>calibredb add "c:\users\owner\documents\my library\open.lit"

Loading plugin from C:\Users\Owner\AppData\Roaming\calibre\plugins\New LIT metadata.zip

lit

<open file u'c:\\users\\owner\\documents\\my library\\open.lit', mode 'rb' at 0x03622480>

<open file u'c:\\users\\owner\\documents\\my library\\open.lit', mode 'r+b' at 0x03622CA0>

If I enable the built-in lit metadata reader, it still brings in the metadata.

kovidgoyal
01-05-2009, 09:18 PM
Add a

print mi

where mi is the result of the get_metadata call

junkml
01-05-2009, 09:44 PM
Add a

print mi

where mi is the result of the get_metadata call

Interesting. There is absolutely nothing. The print statement after "print mi" shows up, but there is nothing for "print mi". No error, nothing.

edit: I take that back. Looking at the output again, the print statement BEFORE "print mi" shows up, but then nothing. So the print statement after "print mi" never happened. But, there was no error showing at the command line.

kovidgoyal
01-05-2009, 10:26 PM
print repr(mi)

junkml
01-05-2009, 10:54 PM
print repr(mi)

Same results. First print statement works, then nothing.

kovidgoyal
01-05-2009, 11:09 PM
Hmm that's just weird. OK re-open the ticket, I'll look at it again.

junkml
01-07-2009, 05:56 PM
Kovid, the metadata script is working now, thanks for your help and patience!

I do have one last question... Is there any way to have the metadata plugin run AFTER file plugin?

kovidgoyal
01-07-2009, 06:11 PM
What are you trying to achieve?

Atley
05-29-2009, 10:57 AM
I saw on your site that there is a plugin to handle two cards on my Sony PRS-505. I am not sure where I would find the plugin.... there is not any link on your site that I have been able to find... could you point me in the right direction?


Thanks,

kovidgoyal
05-29-2009, 12:07 PM
Two card support will be in the 0.6 release of calibre

Atley
06-05-2009, 04:35 AM
This may not be the right forum for this question, and if so, I apologize.

I am having a problem with calibre, the books transfer well enough but I am not getting the collections.

is there a log file I can look at to see what may be causing the issue?

details:

I am transferring 470 books (as PDF) to my reader, some books with multiple tags, e.g. Wiley_ASP_.NET_2.0_From_The_Ground_Up.pdf has tags: Programming, .NET Framework 2.0, Web Programming

I am hoping that the second card support will help resolve this.

are there any known issues that would cause a tag to not transfer to the unit as a collection?

kovidgoyal
06-05-2009, 10:48 AM
Are you using send to device or save to disk to transfer the books?

Atley
06-06-2009, 03:51 PM
Send to device - (I have the default location to send to set to the memory card on the device)

kovidgoyal
06-06-2009, 04:26 PM
in that case, no there are no known issues

cartman
06-06-2009, 07:57 PM
I have got some issues with collections too, as i have lost them 2 or 3 times. I have seen it occur when the device resets after trying to open an lrf created from a web page, and i think it happened also after adding some books with calibre and unplugging the usb cable without safely removing the device (though i am sure all transfers were finished before doing that). After collections were lost, recopying books from calibre did not fix the issue, and i had to format the sd card and the internal memory to get them to work again.

Atley
06-07-2009, 08:47 AM
that is what happened to me, although I did properly remove the device. if I added the books a bit at at time, the collections went over too, but at some point, before all my books were transferred, the collections would disappear.

I have almost 3000 books to transfer to two cards... this is becoming a real problem.

Atley
06-07-2009, 01:40 PM
it is frustrating that the device supports cards that have capacity for numbers of books that its software cannot support properly. your software is far better in this than theirs is, but it is still falling short of the mark.

I understand that these are XML files that are being generated and then supplied to the appropriate folders on the device in order for the device to generate the menus and collections.

is there any way to have a copy of the generated XML files stored in a folder on my machine as well as transferred to the device so that I can manually copy them into the correct directories or at least check them for correctness in the event of an issue?

That in itself would go a long way towards solving this delemma.

I have a feeling that there is an issue with the software actually on the device overwriting these files or perhaps timing out the connection after a certain time in the transfer. I would imagine that the collection XML for 470 books would be fairly large (especially since I have them quite often having between 2 and 5 tags per book for better separation).

I created an XML generator to test the theory and I would really like to see the results of the collection XML. My generator goes by folder and generates an xml entry for every PDF file within any of the folders recursively, it does not handle the generation of collections.

What language is your software written in?

Any suggestions?

kovidgoyal
06-07-2009, 02:04 PM
calibre is written in python. there's nothing wrong with the XML catalaogs calibre generates. The SONY just tends to overwrite them everytime it resets. Frankly the SONY reader just isn't designed to support large numbers of books.

Atley
06-11-2009, 08:02 PM
That was my fear... It is so stupid... I mean, the cards could hold a lot more books in the simple formats that the device is compatible with than I am trying to put in it, why make a device that can support upto 16gb (between two cards) and yet make it incapable of processing the menus for the number of books those cards can hold.

What a huge design flaw... The whole selling point is that you can take your library with you... I have way more than 470 actual books yet this device craps out with only half of one of it's cards full.

I do not doubt the code, I was hoping to get a copy of the xml so that I could keep it and keep recopying it to the device in the hopes that the reader would some day just get it... I am going to copying it out of the device after the books copy over, before I detatch it from my machine. I will let you know if I have any issue getting the XML. Thanks for all your help.

itimpi
06-12-2009, 12:07 AM
I have found it is only worth having a large card if you also intend to make use of its ability play mp3 files - these are much larger than ebook files.

Atley
06-19-2009, 06:43 AM
Yea, but that sucks, I got the reader as a way to carry my study tools and my technical documentation with me. All together this consists of close to 11gb of data in PDFs which my laptop easily can carry and theoretically this device should also handle well.

I have a media player that holds music and video which is much smaller and lighter than this device. I just want it to do what it is supposed to do.