openmedialibrary/oml/media/cbz.py
2019-01-29 18:46:12 +05:30

30 lines
656 B
Python

# -*- coding: utf-8 -*-
import os
import zipfile
import ox
def cover(path):
data = None
logger.debug('cover %s', path)
data = None
try:
z = zipfile.ZipFile(path)
except zipfile.BadZipFile:
logger.debug('invalid zbc file %s', path)
return data
files = [f.filename for f in z.filelist]
if files:
cover = ox.sortedstrings(files)[0]
try:
data = z.read(cover)
except:
data = None
return data
def info(path):
data = {}
data['title'] = os.path.splitext(os.path.basename(path))[0]
#data['pages'] = fixme read rar to count pages
return data