View Full Version : Perl only access to imp file info


derrell
08-28-2008, 04:55 PM
I have been curious for the past few days if it were possible to get information out of imp format files without using the eBook Publisher software from eti. The api that they provide seems to be full featured and has let nick do some wonderful things managing the imp files. The down side of that, for me at least, is that you need windows for most of it to work. :(

So being curious I pulled out my Camel book and decided to wade around and see if I could get some of the information out of an imp file. The attached short script is the beginning of what I've been able to extract from unencrypted books so far. There is more but this is pertinent for sorting and searching through a collection of imp ebooks that might have gotten just thrown into a directory with none too descriptive names. :whistle:

Location of the information in the file came from
http://www.chromakinetics.com/REB1200/imp_format.htm

nrapallo
08-28-2008, 05:12 PM
I have been curious for the past few days if it were possible to get information out of imp format files without using the eBook Publisher software from eti. The api that they provide seems to be full featured and has let nick do some wonderful things managing the imp files. The down side of that, for me at least, is that you need windows for most of it to work. :(

So being curious I pulled out my Camel book and decided to wade around and see if I could get some of the information out of an imp file. The attached short script is the beginning of what I've been able to extract from unencrypted books so far. There is more but this is pertinent for sorting and searching through a collection of imp ebooks that might have gotten just thrown into a directory with none too descriptive names. :whistle:

Location of the information in the file came from
http://www.chromakinetics.com/REB1200/imp_format.htm

Been there, done that... :rofl:

I've been working on 'imp_dump.pl' (see here (http://www.mobileread.com/forums/showthread.php?t=24952)) for the past few months to allow me to dissect an .imp into it's component parts - text/images/links/styles.

Once this is finished the process of re-building the html with images and links and styles can begin.

I 've managed to get most of the .RES filetypes decoded, but still hung up on a few. More on this as I finish...

ashkulz
08-28-2008, 06:56 PM
I too have some unfinished code, but now that I can use impmake on Linux I don't think I'll be ever able to work up the enthusiasm to complete it.

derrell
08-29-2008, 08:20 AM
Wasn't really going to try for a perl only solution to building imp files. Something more along the lines of being able to catalog the imp files without having to resort to running apps in wine. Actual creation of the imp files that way isn't a problem.

I do want to be able to use something like impfind --author Ringo and have it spew out a list of titles and paths to all of the files. I'm thinking it would be uesful to search on all the fields execpt the id. Shouldn't be too hard for me to do now that I can extract the info from the files. All that is left is just moving through the directory tree and generating the list on the right key.

nrapallo
08-29-2008, 08:29 AM
Wasn't really going to try for a perl only solution to building imp files. Something more along the lines of being able to catalog the imp files without having to resort to running apps in wine. Actual creation of the imp files that way isn't a problem.

I wasn't trying to build a .imp ebook; I was dissecting it so that I could (not yet possible) re-build a .html file that resembles the ones used to create it. But then again, that's not what you were looking for by writing imp_probe.pl, as evident by your below comments. OK got ya!

I do want to be able to use something like impfind --author Ringo and have it spew out a list of titles and paths to all of the files. I'm thinking it would be uesful to search on all the fields execpt the id. Shouldn't be too hard for me to do now that I can extract the info from the files. All that is left is just moving through the directory tree and generating the list on the right key.

Yes, this would be very nice, indeed, to have. Keep on truckin'...

ashkulz
08-29-2008, 10:38 AM
I do want to be able to use something like impfind --author Ringo and have it spew out a list of titles and paths to all of the files. I'm thinking it would be uesful to search on all the fields execpt the id. Shouldn't be too hard for me to do now that I can extract the info from the files. All that is left is just moving through the directory tree and generating the list on the right key. Look at the first two functions I have written for impserve -- they'll do the job.


def get_ebook_info(name):
""" get the details of the IMP book as a tuple """
if not isfile(name):
return None
info = [name, getsize(name), getmtime(name)]
f = open(name, 'rb')
if f.read(10) != '\x00\x02BOOKDOUG':
return None

def cString(skip=0):
result = ''
while 1:
data = f.read(1)
if data == '\x00':
if not skip: return result
skip -= 1
result, data = '', ''
result += data

f.read(38)
info += [cString(), cString(), cString(1), cString(2)]
f.close()
return tuple(info)