diff --git a/oml/media/cbr.py b/oml/media/cbr.py index a1840a3..0c29fe2 100644 --- a/oml/media/cbr.py +++ b/oml/media/cbr.py @@ -1,16 +1,9 @@ # -*- 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 @@ -18,7 +11,6 @@ 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) diff --git a/oml/media/cbz.py b/oml/media/cbz.py index 0e71475..60f0672 100644 --- a/oml/media/cbz.py +++ b/oml/media/cbz.py @@ -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,9 +19,8 @@ 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.sorted_strings(files)[0] + cover = ox.sortedstrings(files)[0] try: data = z.read(cover) except: diff --git a/oml/utils.py b/oml/utils.py index ad2b65a..c080426 100644 --- a/oml/utils.py +++ b/oml/utils.py @@ -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):