View Single Post
Old 09-04-2008, 11:55 PM   #119
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
Ashish:

I agree; choice to install content is better than no content...

Also, I tried your PrcConverter.py, but I got a message on startup that it failed to load. Any ideas why that would happen. I ran the script on its own to see if there were any syntax errors but only got the message that impserve wasn't defined.

I know you are away for a bit, but does anything appear wrong with this:
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):
        if not 'prc' in headers['Content-Type']:
            return headers, data

        open('input.prc', 'wb').write(data)

        # 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', '--o', 'output', 'input.prc']) or not os.path.isfile('output.imp'):
            return headers, data
 
        headers['Content-Type'] = 'application/x-softbook'
        data = open('output.imp', 'rb').read()
        os.remove('input.prc')
        os.remove('output.imp')

        return headers, data
I got this message when impserve was launched:
Code:
Loaded plugin: AdjustHtml.py
Loaded plugin: AdjustQueryString.py
The following plugins failed to load: PrcConverter.py
impserve 0.4.2: starting server on 127.0.0.1:9090
nrapallo is offline   Reply With Quote