View Single Post
Old 09-05-2008, 01:32 AM   #122
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
Quote:
Originally Posted by nrapallo View Post
It doesn't work with the 0.4.2 win32 executable, but does work with the python script. Now when I say work I mean it loads... The EBW1150 says it is an "Unknown document type" even though I have that 'mime.types' file with the 'application/x-palm-prc prc pdb' entry.

Back to debugging...
I now have a semi-functional PrcConverter.py but it does not load the resulting .imp onto the reader automatically yet!

My revised PrcConverter.py is:
Code:
# v0.1 - Inital plugin idea by ashkulz; Adapted by nrapallo (Sept 2008)
import impserve
import os, subprocess

class PrcConverter(impserve.ProxyResponse):
    def get_response(self, url, headers, data):
        #debug statement (TODO: also check if .ext is .prc/.pdb/.mobi)
        print headers 
        if not 'application/octet-stream' in headers['Content-Type']:
            return headers, data
	print "0\n"  #debug statement

        open('input.prc', 'wb').write(data)
	print "1\n"  #debug statement
        # using a command to convert .prc to .imp 'on the fly'... copied "C:\Program Files\Mobi2IMP\bin\Mobi2IMP.exe" to impserve directory
        if not subprocess.call(['Mobi2IMP', '--cover', '--out', 'output', 'input.prc']) or not os.path.isfile('output.imp'):
            return headers, data
 	print "2\n"  #debug statement
        headers['Content-Type'] = 'application/x-softbook'
        data = open('output.imp', 'rb').read()
        os.remove('input.prc')
        os.remove('output.imp')
	print "3\n"  #debug statement
        return headers, data
Excuse the print / debug statements for now. They will be removed when this plugin works!

This is the plugin debug log produced:
Code:
Loaded plugin: AdjustHtml.py
Loaded plugin: AdjustQueryString.py
Loaded plugin: PrcConverter.py
impserve 0.4.2: starting server on 127.0.0.1:9090
127.0.0.1 - - [05/Sep/2008 01:12:32] "GET http://authenticate.ebooksystem.net/authenticate/default.asp?SS=1&GUEST_ID=GC0000216225&DEVICE_TYPE=SoftBook&HWSERIES=2250&VERSION=35345&LANG=en&COLOR=NO&DIALED=UNKNOWN&GMT_OFFSET=-14280&SBPISP=NO&SE=1&MESSAGE=5757B0419BE4374C039A10FA38C4EDC70837BB0487AA60F27C9420D03ED187CB&BOOKSHELF=YES HTTP/1.0" 302 -
127.0.0.1 - - [05/Sep/2008 01:12:32] "GET http://bookshelf.ebooksystem.net/content/ HTTP/1.0" 200 -
127.0.0.1 - - [05/Sep/2008 01:12:33] "GET http://www.google.com/intl/en/images/about_logo.gif HTTP/1.0" 200 -
Content-Type: image/gif
Last-Modified: Wed, 07 Jun 2006 19:37:54 GMT
Expires: Sun, 17 Jan 2038 19:14:07 GMT
Cache-Control: public
Date: Fri, 05 Sep 2008 05:09:44 GMT
Server: gws
Content-Length: 5548
Connection: Close

127.0.0.1 - - [05/Sep/2008 01:12:37] "GET https://www.mobileread.com/forums/forumdisplay.php?f=128 HTTP/1.0" 200 -
Connection: close
Set-Cookie: bblastvisit=1220591391; expires=Sat, 05-Sep-2009 05:09:51 GMT; path=/; domain=.mobileread.com
Set-Cookie: bblastactivity=0; expires=Sat, 05-Sep-2009 05:09:51 GMT; path=/; domain=.mobileread.com
Set-Cookie: bbforum_view=c35555c929d51e1050e745ebb1541863c3e446a6a-1-%7Bi-128_i-1220591391_%7D; path=/; domain=.mobileread.com
Expires: 0
Cache-Control: private, post-check=0, pre-check=0, max-age=0
Pragma: no-cache
Content-Type: text/html; charset=ISO-8859-1
X-UA-Compatible: IE=7
Date: Fri, 05 Sep 2008 05:09:51 GMT
Server: Apache

127.0.0.1 - - [05/Sep/2008 01:12:42] "GET https://www.mobileread.com/forums/images/mr/misc/logo.gif HTTP/1.0" 200 -
Connection: close
Content-Type: image/gif
Accept-Ranges: bytes
ETag: "216147554"
Last-Modified: Wed, 09 Apr 2008 09:29:42 GMT
Content-Length: 3364
Date: Fri, 05 Sep 2008 05:09:56 GMT
Server: Apache

127.0.0.1 - - [05/Sep/2008 01:12:42] "GET https://www.mobileread.com/forums/images/mr/misc/rss.gif HTTP/1.0" 200 -
Connection: close
Content-Type: image/gif
Accept-Ranges: bytes
ETag: "1463968026"
Last-Modified: Fri, 18 May 2007 09:42:24 GMT
Content-Length: 1024
Date: Fri, 05 Sep 2008 05:09:57 GMT
Server: Apache

127.0.0.1 - - [05/Sep/2008 01:12:46] "GET https://www.mobileread.com/forums/clear.gif HTTP/1.0" 200 -
Connection: close
Content-Type: image/gif
Accept-Ranges: bytes
ETag: "1146313854"
Last-Modified: Tue, 15 Jul 2008 14:20:24 GMT
Content-Length: 43
Date: Fri, 05 Sep 2008 05:10:00 GMT
Server: Apache

127.0.0.1 - - [05/Sep/2008 01:12:46] "GET https://www.mobileread.com/forums/images/mr/misc/f-129.png HTTP/1.0" 200 -
Connection: close
Content-Type: image/png
Accept-Ranges: bytes
ETag: "1469148012"
Last-Modified: Fri, 22 Jun 2007 14:29:15 GMT
Content-Length: 1458
Date: Fri, 05 Sep 2008 05:10:01 GMT
Server: Apache

127.0.0.1 - - [05/Sep/2008 01:12:54] "GET https://www.mobileread.com/forums/showthread.php?t=22663 HTTP/1.0" 200 -
Connection: close
Set-Cookie: bblastvisit=1220591408; expires=Sat, 05-Sep-2009 05:10:08 GMT; path=/; domain=.mobileread.com
Set-Cookie: bblastactivity=0; expires=Sat, 05-Sep-2009 05:10:08 GMT; path=/; domain=.mobileread.com
Expires: 0
Cache-Control: private, post-check=0, pre-check=0, max-age=0
Pragma: no-cache
Content-Type: text/html; charset=ISO-8859-1
X-UA-Compatible: IE=7
Date: Fri, 05 Sep 2008 05:10:08 GMT
Server: Apache

127.0.0.1 - - [05/Sep/2008 01:12:58] "GET https://www.mobileread.com/forums/image.php?u=8654&dateline=1186863588 HTTP/1.0" 200 -
Connection: close
Cache-control: max-age=31536000
Expires: Sat, 05 Sep 2009 05:10:12 GMT
Content-disposition: inline; filename=Sistine_Sibyl.jpg
Content-transfer-encoding: binary
Content-Length: 3723
Last-Modified: Sat, 11 Aug 2007 20:19:48 GMT
ETag: "1186863588-8654"
Date: Fri, 05 Sep 2008 05:10:12 GMT
Server: Apache
Content-Type: image/jpeg

127.0.0.1 - - [05/Sep/2008 01:12:59] "GET https://www.mobileread.com/forums/images/mr/attach/prc.gif HTTP/1.0" 200 -
Connection: close
Content-Type: image/gif
Accept-Ranges: bytes
ETag: "81527440"
Last-Modified: Fri, 22 Jun 2007 19:12:30 GMT
Content-Length: 135
Date: Fri, 05 Sep 2008 05:10:14 GMT
Server: Apache

127.0.0.1 - - [05/Sep/2008 01:13:02] "GET https://www.mobileread.com/forums/attachment.php?attachmentid=12111&d=1207787498 HTTP/1.0" 200 -
Connection: close
Vary: User-Agent
X-UA-Compatible: IE=7
Cache-control: max-age=31536000, private
Expires: Sat, 05 Sep 2009 05:10:16 GMT
Last-Modified: Thu, 10 Apr 2008 00:31:38 GMT
ETag: "12111"
Accept-Ranges: bytes
Content-disposition: attachment; filename="Pozzuoli_War%20of%20the%20Wenuses.prc"
Content-Length: 105285
Date: Fri, 05 Sep 2008 05:10:16 GMT
Server: Apache
Content-Type: application/octet-stream

0

1


Mobi2IMP (version 9.4b) Copyright (C) 2008 Nick Rapallo (nrapallo)
FULLFILENAME: input.prc
FILENAME    : input.prc
EXPLODEPATH : .\
EXPLODEDIR  : input
DatabaseName: Pozzuoli_War of the Wenuses
Version     : 0
Type        : TEXt
Creator     : REAd
baktime     : -2082844800
# of records: 20
---------------------------------------------------
---------------------------------------------------
Found 1 images
Looking for filepos
Found all 17 filepos
Adding name attributes
WARNING 17: 0000077137 - Not an anchor:
Fixing filepos attribute
EBW 1150 ebook created!

(reader responded "Unknown document type" at this point and the plugin failed to print "2")

(directory icon tapped to go back one webpage)

127.0.0.1 - - [05/Sep/2008 01:13:31] "GET http://directory.ebooksystem.net/directory/default.asp HTTP/1.0" 302 -
127.0.0.1 - - [05/Sep/2008 01:13:32] "GET https://www.mobileread.com/forums/forumdisplay.php?f=128 HTTP/1.0" 200 -
Connection: close
Set-Cookie: bblastvisit=1220591446; expires=Sat, 05-Sep-2009 05:10:46 GMT; path=/; domain=.mobileread.com
Set-Cookie: bblastactivity=0; expires=Sat, 05-Sep-2009 05:10:46 GMT; path=/; domain=.mobileread.com
Set-Cookie: bbforum_view=16ca0a403c69cd6c63057b53f7c6b162dd613c38a-1-%7Bi-128_i-1220591446_%7D; path=/; domain=.mobileread.com
Expires: 0
Cache-Control: private, post-check=0, pre-check=0, max-age=0
Pragma: no-cache
Content-Type: text/html; charset=ISO-8859-1
X-UA-Compatible: IE=7
Date: Fri, 05 Sep 2008 05:10:46 GMT
Server: Apache
Note that I placed a copy of Mobi2IMP.exe from the bin directory created by the Mobi2IMP installer package. The plugin did manage to save the input.prc and create the output.imp, but didn't load it "on-the-fly". (See attached .prc & .imp)

Notice above that Mobileread returns a Content-Type of 'application/octet-stream' when requesting the final .prc file. It has the filename there too so the plugin should, in the future, check the .ext to make sure we are doing a valid conversion.

Also, it seems that Mobileread uses a mimetype of 'application/x-mobipocket-ebook' for .prc download requests per the more detailed log report created prior to the one above. (See below text file)
Attached Files
File Type: prc input.prc (102.8 KB, 516 views)
File Type: imp output.imp (67.4 KB, 526 views)
File Type: txt PrcConverter-debug-log-detailed.txt (6.3 KB, 898 views)
nrapallo is offline   Reply With Quote