Mobileread
Plugin ideas... add yours here
#11  kiwidude 01-29-2011, 06:44 PM
Quote avantman42
Recently I started adding our paper books to my copy of Calibre, so that we've got a complete record of all the books we own. I've got a couple of MP3 audio books which I'd also like to add. I've added tags for both paper and audio books, and in the case of MP3s, I've added the files to the book's folder. Ideally, I'd like to add the MP3 files to the formats list.

A quick look suggests that this can't be done with a file type plugin, would anyone care to prove me wrong? Or tell me that it can be done some other way?
As you have discovered Calibre has no direct support for audiobooks. If it consists of a single mp3 file, you can just drag/drop this into Calibre like any other book format, it appears in the list of formats in the book details window etc.

However, an audiobook usually consists of multiple mp3 files. And Calibre does not support storing multiple files with the same format in the same directory (e.g. multiple versions of an EPUB). So the limitation that applies to ebooks applies even more so to audiobooks for which you will have multiple files of the same extension.

The workaround suggested for ebooks is to create a separate book entry in Calibre representing the alternate version of the book and storing it there. Thus the "equivalent" for audiobooks would be to create a "book" entry for each mp3 file making up the audiobook.

If Calibre were to ever support multiple "versions" within the same book record then possibly it would help you. However afaik there is no plan to do this as it would potentially be a big task.

Storing files "manually" inside the Calibre folders in general is a *bad* idea as often gets repeated in the forums. If you were to rename the book author for instance then it is possible you would lose the audio files - that file structure is for Calibre to do with as it will and it will only keep track of the files in its database - i.e. things you have imported into Calibre.

So I can't think of a direct way for a plugin to help you. I would suggest posting in the main Calibre forum and asking others if they store audiobooks in Calibre and if so how they approach it.
Reply 

#12  kiwidude 01-29-2011, 07:06 PM
Quote paolamanzini
Hi kiwidude, thanks for the prompt answer. Well, I (perhaps naively?) thought that with the doi one could "suck up" the metadata from the article page itself, e/.g for the above doi it would be here:
http://www.informaworld.com/smpp/content~db=all~content=a785830700~frm=titlelink

Having said that, one site that is free as far as I know is "cite you like", which again for the above DOI returns:
http://www.citeulike.org/user/PreciousJ/article/7478980

But I am no tech-person, so perhaps this does not make sense...
The "suck up" technique is called "web scraping". In theory it is usually possible to do. The major downside is that it is extremely "fragile" - if the website you are trying to "scrape" the information from changes it's appearance with a redesign, then your code becomes useless. There can also potentially be legal issues as well I believe although how much of an issue that is in this case I am not sure.

As I don't have any journals and have a backlog of other plugins to work on I'm not volunteering to help further this myself I'm afraid. There is some information here now as a starting point if there is someone else out there keen to assist with writing it for you at some point.
Reply 

#13  avantman42 01-29-2011, 07:29 PM
It appears that I've been something of an idiot

Quote kiwidude
As you have discovered Calibre has no direct support for audiobooks. If it consists of a single mp3 file, you can just drag/drop this into Calibre like any other book format, it appears in the list of formats in the book details window etc.
I hadn't realised that I could add non-ebook files to Calibre.

Quote kiwidude
However, an audiobook usually consists of multiple mp3 files. And Calibre does not support storing multiple files with the same format in the same directory (e.g. multiple versions of an EPUB). So the limitation that applies to ebooks applies even more so to audiobooks for which you will have multiple files of the same extension.
I've now realised that I can put all the files in a zip archive and add that, which is good enough for me.

Quote kiwidude
Storing files "manually" inside the Calibre folders in general is a *bad* idea as often gets repeated in the forums. If you were to rename the book author for instance then it is possible you would lose the audio files - that file structure is for Calibre to do with as it will and it will only keep track of the files in its database - i.e. things you have imported into Calibre.
I realise that you should generally leave Calibre's library directory alone, but having read this thread (specifically posts 9 & 10), I thought I should be OK. Now that I've realised I can import non-ebook files into Calibre, it's all good

Thanks for your help. I had expected a reply along the lines of "Calibre only deals with e-book formats, it can't help with any other files", so this is much better than I'd expected.
Reply 

#14  kiwidude 01-29-2011, 07:45 PM
Quote avantman42
I realise that you should generally leave Calibre's library directory alone, but having read this thread (specifically posts 9 & 10), I thought I should be OK. Now that I've realised I can import non-ebook files into Calibre, it's all good .
Quite right you are, thanks for pointing me to that. I wasn't 100% sure if the directory would be moved or recreated - as the answer is "moved" then my caution on that was unnecessary.

However as you have a workaround of adding as a zip then that is even better. The only reason I did not suggest that is Calibre uses a zip format for storing html files in. So provided you don't intend to have an html format of a book and an audiobook format then you should be ok. Also of course it also means you have to unzip your audio files each time to play them, where I thought you may have been wanting to keep the files unzipped to use Calibre to send them to a device or something.

However if that solution does what you need then it's all good
Reply 

#15  avantman42 01-29-2011, 08:02 PM
Quote kiwidude
Quite right you are, thanks for pointing me to that. I wasn't 100% sure if the directory would be moved or recreated - as the answer is "moved" then my caution on that was unnecessary.

However as you have a workaround of adding as a zip then that is even better.
I'm happier now that I've found a way to actually tell Calibre about the files - I wasn't entirely confident trusting to it renaming rather than recreating the directory.

Quote kiwidude
The only reason I did not suggest that is Calibre uses a zip format for storing html files in. So provided you don't intend to have an html format of a book and an audiobook format then you should be ok.
That also occurred to me after I'd posted. I've only got a few audio books at the moment, and none of them are in HTML format. To prevent problems in future, though, I've decided to use .tar as a format for audio books, so that I can have both HTML and audio versions of a book if I wish.

Quote kiwidude
Also of course it also means you have to unzip your audio files each time to play them, where I thought you may have been wanting to keep the files unzipped to use Calibre to send them to a device or something.

However if that solution does what you need then it's all good
I don't mind having to uncompress them in order to play them. At the end of the day, Calibre isn't designed or intended to deal with audio or paper books, so I don't mind some limitations with those, but I like having all my books managed in one place.

Thanks again for your help.
Reply 

#16  sherman 01-31-2011, 03:41 AM
Hi folks.

Well, when I purchase a book, I like to retain all it's formatting and don't like doing an epub-to-epub conversion. However, most publishers don't do a "perfect" epub (in my opinion) and usually require a few css and xpgt tweaks before I load it on to my reader.

However, the publishers use a master template, so the changes I like to make to one book are identical to any other book by that publisher. This of course gets very repetitive very quickly...

So I was wondering if it were possible if someone was interested in making a plugin that would open an epub, run a series of find/replace operations on the css and xpgt files within and repackage the epub -- basically an "automated" Tweak Epub feature.

Example:
For some reason, Penguin books scale down the fonts by one "size". so a typical body paragraph has the following style
Code
.tx {
font-size: small;
text-align: justify;
text-indent: 15px;
}
So therefore, when I make my alterations x-large becomes xx-large, large to x-large, medium to large, delete small, x-small to small, xx-small to x-small. I also like to change the indent to around 1.3em.

I also like to change the margins in the page-template.xpgt to 5px.



Any thoughts?
Reply 

#17  garcle 01-31-2011, 02:58 PM
OK the Title Goal ("Scrape and Update a Custom field PLugin") is probably way too generic. But I have not let go the idea of having a custom DCC column in my Calibre Library (it would be useful to me).

So a Plugin that takes the ISBN of the selected record and hits (for example)the Classify web service, and then "beautiful Soups" the result to grab the DCC, and then saves it back into the nominated custom column. would be awesome

I have been tinkering and have figured out how to use the Beautiful Soup py Module to target response XML and to Lift a certain element within the response. My difficulty comes with getting my head around how to perform an update of a custom column associated with the selected record. (ie I'm having trouble navigating the data updating code of Calibre.)

A Plugin of this kind, while initially being targeted at a specific case, could potentially be expanded to become a generic plug-in for fetching and populating custom columns of various types from various services. Some other examples might be:-
- a cost column to track how much I have spent on my ebooks.
- an IMDB movie column with a link to movies made of the book.
- a country column denoting which country the author came from.
- a notification service, which alerts you when a new book in the current book series is published.


Oh and I'm aware of the 'fragility" issue, however Classify, for instance, is more a web services than an http:html response and one could expect that the xml element names would remain constant even if their position in the response changed.
Reply 

#18  kiwidude 01-31-2011, 10:11 PM
Quote sherman
So I was wondering if it were possible if someone was interested in making a plugin that would open an epub, run a series of find/replace operations on the css and xpgt files within and repackage the epub -- basically an "automated" Tweak Epub feature.
Good old Palmy North eh? Grew up near Stratford in Taranaki myself...

I don't have a need for such a plugin myself but I can understand the issue and technically there is no great difficulty. One question that comes to mind if someone was to assist you with writing it is the nature of the find/replace operations and how those are specified. Could you get away with substituting an entire css file? Or do you substitute just specific styles? Maybe if you could list (as an example) all of the substitutions you do currently that you require, put them either in an attachment or spoiler section for someone to take a look at.

If the find/replace operations are quite complex then you are probably going to want them specified using regular expressions for instance.
Reply 

#19  kiwidude 01-31-2011, 10:21 PM
Quote garcle
OK the Title Goal ("Scrape and Update a Custom field PLugin") is probably way too generic. But I have not let go the idea of having a custom DCC column in my Calibre Library (it would be useful to me)...
This does sound a VERY interesting idea, particularly if extensible via the BeautifulSoup type approach. I like your list of example usages too, very creative.

I've got the GoodReads plugin as next on my todo list to investigate so that will keep me out of trouble for a few days. But if no-one else has stepped in after that to help you with this then I could be tempted to offer help if needed, sounds an interesting challenge.
Reply 

#20  sherman 02-01-2011, 04:44 AM
Quote kiwidude
Good old Palmy North eh? Grew up near Stratford in Taranaki myself...

I don't have a need for such a plugin myself but I can understand the issue and technically there is no great difficulty. One question that comes to mind if someone was to assist you with writing it is the nature of the find/replace operations and how those are specified. Could you get away with substituting an entire css file? Or do you substitute just specific styles? Maybe if you could list (as an example) all of the substitutions you do currently that you require, put them either in an attachment or spoiler section for someone to take a look at.

If the find/replace operations are quite complex then you are probably going to want them specified using regular expressions for instance.
The 'naki eh? I was born and raised in New Plymouth -- Bell Block to be exact. Just shifted back actually, need to update my profile


But anyway, back on topic...

I tend to prefer replacing specific styles rather than substituting in a new stylesheet.
It wouldn't need anything too exotic, basic search is all that's necessary, although regular expressions would be much more flexible and powerful.

My idea was to use a basic text file with a series of search/replace terms that the plugin would perform on the .css and .xpgt files found in the epub.

So, for the Penguin example, the text file could look a little something like this:
Spoiler Warning below







[css]
(search)font-size: x-large (replace)font-size: xx-large
(search)font-size: large (replace)font-size: x-large
(search)font-size: medium (replace)font-size: large
(search)font-size: small (replace)
(search)font-size: xx-small (replace)-small
(search)font-size: x-small (replace)small
(search)font-size: -small (replace)x-small
(search)text-indent: 15px (replace)text-indent: 1.3em
(search)margin-right: 25px (replace)

[xpgt]
(search)20px or 30px (replace)5px


//of course, this wouldn't be the syntax actually used
Reply 

 « First  « Prev Next »  Last »  (2/140)
Today's Posts | Search this Thread | Login | Register