Okay! This seems to be working for me. I can now extract the cover image from the PMLZ archive. I modified metadata/pml.py as follows:
Code:
def get_metadata(stream, extract_cover=True):
""" Return metadata as a L{MetaInfo} object """
mi = MetaInformation(_('Unknown'), [_('Unknown')])
stream.seek(0)
pml = ''
if stream.name.endswith('.pmlz'):
with TemporaryDirectory('_unpmlz') as tdir:
zf = ZipFile(stream)
zf.extractall(tdir)
pmls = glob.glob(os.path.join(tdir, '*.pml'))
for p in pmls:
with open(p, 'r+b') as p_stream:
pml += p_stream.read()
coverpath = glob.glob(os.path.join(tdir, 'cover.png'))
if len(coverpath)==0:
imagedir=os.path.join(tdir,'images')
coverpath = glob.glob(os.path.join(imagedir, 'cover.png'))
if len(coverpath)==0:
imagedir=os.path.join(tdir,pmls[0] + '_img')
coverpath = glob.glob(os.path.join(imagedir, 'cover.png'))
if len(coverpath)>0:
coverdata = open(coverpath, 'rb').read()
if coverdata is not None:
mi.cover_data = ('png', coverdata)
else:
Try it out and see if that works for you as well (I've only tested it on a Mac). If so, would you so kindly push that in?
- Jim