View Single Post
Old 02-03-2008, 07:29 PM   #1
nrapallo
GuteBook/Mobi2IMP Creator
nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.
 
nrapallo's Avatar
 
Posts: 2,958
Karma: 2530691
Join Date: Dec 2007
Location: Toronto, Canada
Device: REB1200 EBW1150 Device: T1 NSTG iLiad_v2 NC Device: Asus_TF Next1 WPDN
Using perl scripts to produce .IMP ebooks and more...

I had wanted to use command-line based tools to facilitate the conversion of .html directly into .IMP format; bypassing the need for the eBook Publisher GUI. Don't get me wrong, I think the eBook Publisher is a very powerful tool. It is the most effective way to deal with multiple input files especially if they do not 'lend' themselves to be used in a ebook.

To achieve the best results, the .html should first be cleaned-up by 'Tidy'. This will remove those annoying '?', correct ill-formed TOC and clean-up the .html.

I needed this primarily as I was converting single .html files from various sources (expanded .PRC/.PDB, exploded .LIT, Blackmask/Project Gutenberg .html, etc.). I found it cumbersome to use the eBook Publisher for just one file, especially if the .html filename was in the format 'authorname - title'.html. For these .html files, I had all the info I needed to properly create a .IMP ebook in the filename; all I had to do was choose the category and I would be finished!

Enter the perl scripts...

To use these perl scripts, it is required that:
1. You have previously installed the eBook Publisher software from http://www.ebooktechnologies.com/sup...r_download.htm . The perl scripts use 'SBPubX' interface calls to create, view and manipulate .opf and .IMP files.
2. That perl scripts can be executed on your computer. For Windows, I had to install ActivePerl from ActiveState from http://www.activestate.com/store/activeperl/ .
BUILDIMP
A simple batch file called buildIMP.bat demonstrates how .IMP ebooks can be created using the workhorse routine 'Html2imp.pl'. The 'Html2imp.pl' perl script takes as input four parameters: 'Authorname' 'Title' 'Category' and 'htmlfilename'. If any of the parameters contain spaces, then quotes need to surround that parameter!

After executing the sample batch file, the .IMP ebook is produced along with the .opf project file used internally. This file can later be loaded into eBook Publisher for further processing, if necessary.
EXAMINEOPF
This perl script is invoked by 'examineOPF.pl project.opf'. It displays some information about the .opf file and prints out to stdout. If warranted, this output could be redirected to log file.
INFOIMP
This perl script is invoked by 'infoIMP.pl ebook.imp'. It displays some information about the .IMP file and prints out to stdout. If warranted, this output could be redirected to log file.

A variant of this script is 'infoIMPcsv.pl' which will 'dump' the .IMP details to stdout in 'comma separated values' format. You should redirect the output to a file so it can be opened in Microsoft Excel or similar for further exploration.

Another variant is 'infoIMPtab.pl' which will 'dump' the .IMP details to stdout in 'tabbed text' format. Again, you should redirect the output to a file so it can be opened in Microsoft Excel or similar for further exploration.

Try these on a directory full of .IMP files and you will get a mini-database of .IMP details!
VALIDATEOPF
This perl script is invoked by 'validateOPF.pl project.opf'. It validates the .opf showing all errors/warnings and prints out to stdout. Redirect to log file, if warranted. This can be used to extract the error log of a complex .opf build for future study.
Please feel free to modify these to suit your needs and consider sharing your achievements for others to benefit.

-Nick

EDIT: 18-May-2008 added windows executables (see IMP_OPF_windows-executables.zip) of each perl script for those that can't/won't work with perl scripts directly.
Attached Files
File Type: pl Html2imp.pl (4.7 KB, 1805 views)
File Type: pl examineOPF.pl (2.6 KB, 1510 views)
File Type: pl infoIMP.pl (1.8 KB, 1535 views)
File Type: pl validateOPF.pl (2.4 KB, 1525 views)
File Type: zip IMP_OPF_perl-scripts.zip (2.77 MB, 1780 views)
File Type: zip IMP_OPF_windows-executables.zip (8.70 MB, 2769 views)

Last edited by nrapallo; 05-27-2008 at 11:25 PM. Reason: added windows executables (see IMP_OPF_windows-executables.zip) of each perl script
nrapallo is offline   Reply With Quote