03-07-2013, 11:19 AM | #1 |
Member
Posts: 15
Karma: 10
Join Date: Mar 2013
Device: Bluefire reader, samsung galaxy s3
|
Automate epubsplit for multiple epubs
I used the epubsplit for a single epub and it works great.
Thanks for it. I want to use it on multiple epubs and automate the whole process of splitting. Can i use any tool or command line option for accessing the plugin through Calibre and automating the whole process? I am a .net developer. Just an FYI for any thing helpful you might have for me. Thanks in advance. |
03-07-2013, 11:26 AM | #2 | |
Resident Curmudgeon
Posts: 73,957
Karma: 128903250
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
Advert | |
|
03-07-2013, 11:46 AM | #3 |
Well trained by Cats
Posts: 29,799
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
|
03-07-2013, 02:22 PM | #4 |
Plugin Developer
Posts: 6,313
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
|
(same as PM response to cakiran)
calibre doesn't really have any useful way to automate work flow or call plugins from CLI. epubsplit did have a CLI at one time, but I removed it due to lack of interest and it's general clunkiness/incompleteness at the time. I've re-introduced that basic CLI and polished it a bit. You'll need epubmerge.py and BeautifulSoup.py from the source repository and a working Python 2.7. Hope that helps. Jim |
03-07-2013, 04:00 PM | #5 |
Member
Posts: 15
Karma: 10
Join Date: Mar 2013
Device: Bluefire reader, samsung galaxy s3
|
Step by step help will be very useful. Thanks.
I have installed python 3.3 on my windows 7 box. I downloaded epubmerge.py and checked it but it is having options to merge not to split.
Can you give me an example of how i can split an epub using these files please? Should i download both these files to a folder? Do i need to have the epubsplit py files too or just these 2 files are enough? I would like to copy out the first chapter of the for eg. test.epub to test_chapter1.epub. Can you please tell me the command to be used and the steps to be followed. Thanks for your help. |
Advert | |
|
03-07-2013, 05:27 PM | #6 |
Plugin Developer
Posts: 6,313
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
|
This is only tested against Python 2.7. Python 3.3 contains many changes, so it may or may not work--you're on your own for that.
You only need epubsplit.py and BeautifulSoup.py from the epubsplit source repository. (I mistyped when I wrote epubmerger.py--sorry.) Put them in the directory you plan to run them from. (I don't know how you'd go about adding a python script to your path or anything like that.) Run 'python epubsplit.py' to get the CLI options. Run 'python epubsplit.py input.epub' to get a list of split point 'lines' in the source epub. Each 'line' is equivalent to the lines presented in the plugin GUI. To do the actual split, run 'python epubsplit.py -o output.epub input.epub 0 1 2' for example, to split off the first 3 lines. |
03-07-2013, 09:49 PM | #7 |
Resident Curmudgeon
Posts: 73,957
Karma: 128903250
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
This sounds a lot more difficult then one at a time via the GUI.
|
03-07-2013, 10:17 PM | #8 |
creator of calibre
Posts: 43,851
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
@JimmXinu: It is perfectly possible to use plugins from the calibre command line, see the modify epub plugin for an example.
|
03-07-2013, 10:22 PM | #9 |
Plugin Developer
Posts: 6,313
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
|
Yep. That's why I had discarded the CLI and left it as a GUI plugin only. I only resurrected the CLI because cakiran asked.
However, if you have a number of epubs that you know you only want certain parts of, this may still be easier. |
03-07-2013, 10:33 PM | #10 | |
Plugin Developer
Posts: 6,313
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
|
Quote:
Currently, on my system at least (Win7, calibre 0.9.21 64bit), 'calibre-debug -e' isn't effective because calibre-debug is taking all the options and not passing them to the called py file. Using the modify epub example: Spoiler:
I'd started writing up some similar instructions for epubspllit using 'calibre-debug -e' instead of calling for a separate python instead when I found this issue. On reflection, I probably should have reported it--I know I used to use 'calibre-debug -e' to call py files and pass options. |
|
03-07-2013, 10:37 PM | #11 |
creator of calibre
Posts: 43,851
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You need this
calibre-debug myscript.py -- --option1 --iption2 file1 file2 The -e is no longer required and you need the -- to indicate that remaining arguments should be passed to the script. |
03-07-2013, 10:49 PM | #12 |
Plugin Developer
Posts: 6,313
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
|
So it does. Thanks for pointing that out.
I would point out that neither the online manual page or 'calibre-debug --help' mention that technique. I know that '--' is somewhat standard, but since it used to work without '--' (witness the modify epub example you referenced yourself) it might be worth including. |
03-07-2013, 10:57 PM | #13 |
creator of calibre
Posts: 43,851
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Sure, easy to do.
|
03-08-2013, 04:51 AM | #14 |
creator of calibre
Posts: 43,851
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I've added an interface to calibre-debug to make running plugins even easier. Define a
def cli_main(self, args): ... method in your main plugin class in __init__.py. Then you can run the plugin from the command line with calibre-debug --run-plugin "Plugin Name" -- --option1 file1 ... This will call cli_main() in your plugin with the passed in arguments. No need to unzip the plugin and run python files etc. Will be in next weeks release, you can test it now if you run calibre from source. |
03-08-2013, 10:12 AM | #15 | |
Member
Posts: 15
Karma: 10
Join Date: Mar 2013
Device: Bluefire reader, samsung galaxy s3
|
It worked. Thanks.
Quote:
I was able to do this using python 2.7.2 and it worked fine for a single book i tried just now. I will wrap this into a batch file or a .net exe and see how it works with other epubs. Thanks so much. One more question which is quite unrelated to this issue but related to epubs. Is there any easy way to find out the total number of pages of a epub? |
|
Tags |
.net, automate, calibre, commandline, epubsplit |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[GUI Plugin] EpubSplit | JimmXinu | Plugins | 422 | 04-07-2024 04:10 PM |
Automate Calibre Tagging | ohemeffgee | Library Management | 1 | 11-11-2012 06:56 AM |
Any way to automate editting metadata? | louwin | Library Management | 4 | 04-24-2012 06:58 PM |
Help Merging Multiple Small Epubs into One Large Epub | kazbates | Workshop | 14 | 09-15-2011 02:18 AM |
I am looking for a tool that could automate convertion of... | astra | Workshop | 24 | 08-30-2009 06:38 AM |