Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 03-07-2013, 11:19 AM   #1
cakiran
Member
cakiran began at the beginning.
 
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.
cakiran is offline   Reply With Quote
Old 03-07-2013, 11:26 AM   #2
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 73,845
Karma: 128597114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by cakiran View Post
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.
You cannot automate the process. The plugin would have no way of knowing where it was you wanted to split.
JSWolf is offline   Reply With Quote
Advert
Old 03-07-2013, 11:46 AM   #3
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,762
Karma: 54401244
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by JSWolf View Post
You cannot automate the process. The plugin would have no way of knowing where it was you wanted to split.
A 'Vegamatic' for books.
It slices. It dices. It makes a total Hash out of your book
theducks is offline   Reply With Quote
Old 03-07-2013, 02:22 PM   #4
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,305
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
JimmXinu is offline   Reply With Quote
Old 03-07-2013, 04:00 PM   #5
cakiran
Member
cakiran began at the beginning.
 
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.
cakiran is offline   Reply With Quote
Advert
Old 03-07-2013, 05:27 PM   #6
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,305
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.
JimmXinu is offline   Reply With Quote
Old 03-07-2013, 09:49 PM   #7
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 73,845
Karma: 128597114
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.
JSWolf is offline   Reply With Quote
Old 03-07-2013, 10:17 PM   #8
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,826
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.
kovidgoyal is offline   Reply With Quote
Old 03-07-2013, 10:22 PM   #9
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,305
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
Quote:
Originally Posted by JSWolf View Post
This sounds a lot more difficult then one at a time via the GUI.
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.
JimmXinu is offline   Reply With Quote
Old 03-07-2013, 10:33 PM   #10
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,305
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
Quote:
Originally Posted by kovidgoyal View Post
@JimmXinu: It is perfectly possible to use plugins from the calibre command line, see the modify epub plugin for an example.
Possible, but perfectly is a stretch--at least right now.

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:
Code:
C:\Users\username\Desktop\nook> calibre-debug -e me.py source.epub --smarten_punctuation
Usage: calibre-debug.exe [options]

Various command line interfaces useful for debugging calibre. With no options,
this command starts an embedded python interpreter. You can also run the main 
calibre GUI and the calibre viewer in debug mode.

It also contains interfaces to various bits of calibre that do not have
dedicated command line tools, such as font subsetting, tweaking ebooks and so on.


Whenever you pass arguments to calibre-debug.exe that have spaces in them, 
enclose the arguments in quotation marks.
calibre-debug.exe: error: no such option: --smarten_punctuation

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.
JimmXinu is offline   Reply With Quote
Old 03-07-2013, 10:37 PM   #11
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,826
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.
kovidgoyal is offline   Reply With Quote
Old 03-07-2013, 10:49 PM   #12
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,305
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.
JimmXinu is offline   Reply With Quote
Old 03-07-2013, 10:57 PM   #13
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,826
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Sure, easy to do.
kovidgoyal is offline   Reply With Quote
Old 03-08-2013, 04:51 AM   #14
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,826
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.
kovidgoyal is offline   Reply With Quote
Old 03-08-2013, 10:12 AM   #15
cakiran
Member
cakiran began at the beginning.
 
Posts: 15
Karma: 10
Join Date: Mar 2013
Device: Bluefire reader, samsung galaxy s3
It worked. Thanks.

Quote:
Originally Posted by JimmXinu View Post
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.

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?
cakiran is offline   Reply With Quote
Reply

Tags
.net, automate, calibre, commandline, epubsplit

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 03:36 PM.


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