merge cbr/cbz cover extraction
This commit is contained in:
parent
7ab27db0dd
commit
9ef5c01235
2 changed files with 45 additions and 37 deletions
|
|
@ -1,36 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
import os
|
||||
import zipfile
|
||||
|
||||
import ox
|
||||
|
||||
from .cbr import filter_images
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
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]
|
||||
files = filter_images(files)
|
||||
if files:
|
||||
cover = ox.sorted_strings(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
|
||||
from .cbr import cover, info
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue