Compare commits

...

2 Commits

Author SHA1 Message Date
j 106ae904c3 cbr/cbz cleanups 2019-02-01 18:27:58 +05:30
j 3b438010d6 another cbz fix 2019-02-01 17:56:28 +05:30
3 changed files with 15 additions and 6 deletions

View File

@ -1,9 +1,16 @@
# -*- coding: utf-8 -*-
import logging
import os
import ox
logger = logging.getLogger(__name__)
IMAGE_EXTENSIONS = ['.jpg', '.png', '.gif']
def filter_images(files):
return [f for f in files if os.path.splitext(f)[-1] in IMAGE_EXTENSION]
def cover(path):
data = None
#open rar file and extract first page here
@ -11,6 +18,7 @@ def cover(path):
from unrar import rarfile
rar = rarfile.RarFile(path)
files = rar.namelist()
files = filter_images(files)
if files:
cover = ox.sorted_strings(files)[0]
data = rar.read(cover)

View File

@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
import logging
import os
import zipfile
import logging
import ox
from .cbr import filter_images
logger = logging.getLogger(__name__)
def cover(path):
data = None
logger.debug('cover %s', path)
@ -19,8 +19,9 @@ def cover(path):
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.sortedstrings(files)[0]
cover = ox.sorted_strings(files)[0]
try:
data = z.read(cover)
except:

View File

@ -424,7 +424,7 @@ def ctl_output(*args):
p = subprocess.Popen([os.path.join(settings.base_dir, 'ctl')] + list(args),
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
logger.debug('ctl_output%s -> %s [%s]', args, stdout, stderr)
#logger.debug('ctl_output%s -> %s [%s]', args, stdout, stderr)
return stdout.decode('utf-8').strip()
def user_sort_key(u):