diff --git a/ctl b/ctl index 8195061..da49820 100755 --- a/ctl +++ b/ctl @@ -56,7 +56,7 @@ else ARCH="_armv7l" fi PLATFORM="linux$ARCH" - if [ -e "$BASE/platform_${PLATFORM}/lib/libunrar.so" ]; then + if [ -e $BASE/platform_${PLATFORM}/lib/libunrar.so ]; then export UNRAR_LIB_PATH="$BASE/platform_${PLATFORM}/lib/libunrar.so" fi fi diff --git a/oml/item/models.py b/oml/item/models.py index 72d6b8e..a2b200a 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -843,17 +843,15 @@ def download_cover(id): url = i.meta.get('cover') else: url = None - cover = None logger.debug('download cover %s %s', id, url) ratio = None - if url: - try: - cover = ox.net.read_url(url) - ratio = get_ratio(cover) - except: - logger.debug('unable to read cover url %s', url) - cover = None + try: + cover = ox.net.read_url(url) + ratio = get_ratio(cover) + except: + logger.debug('unable to read cover url %s', url) + cover = None with db.session(): i = Item.get(id, for_update=True) if i: diff --git a/oml/media/cbz.py b/oml/media/cbz.py index 60f0672..b08c972 100644 --- a/oml/media/cbz.py +++ b/oml/media/cbz.py @@ -1,14 +1,9 @@ # -*- coding: utf-8 -*- import os import zipfile -import logging import ox - -logger = logging.getLogger(__name__) - - def cover(path): data = None logger.debug('cover %s', path) diff --git a/oml/media/epub.py b/oml/media/epub.py index 552a134..cd5a6f0 100644 --- a/oml/media/epub.py +++ b/oml/media/epub.py @@ -153,7 +153,7 @@ def info(epub): contents.append(txt) if contents: data['tableofcontents'] = '\n'.join(contents).strip() - if 'tableofcontents' not in data: + if not 'tableofcontents' in data: guide = info.find('{http://www.idpf.org/2007/opf}guide') if guide: for ref in guide.findall('{http://www.idpf.org/2007/opf}reference'): @@ -169,7 +169,7 @@ def info(epub): data['description'] = strip_tags(decode_html(data['description'])) text = extract_text(epub) data['textsize'] = len(text) - if 'isbn' not in data: + if not 'isbn' in data: isbn = extract_isbn(text) if isbn: data['isbn'] = isbn diff --git a/oml/media/pdf.py b/oml/media/pdf.py index 75313b2..bc342d0 100644 --- a/oml/media/pdf.py +++ b/oml/media/pdf.py @@ -237,13 +237,10 @@ def info(pdf): def extract_text(pdf): if sys.platform == 'win32': pdf = get_short_path_name(pdf) - cmd = ['pdftotext', pdf, '-'] if sys.platform == 'darwin': - pdftotext = ['/usr/local/bin/pdftotext', pdf, '-'] - if os.path.exists(pdftotext[0]): - cmd = pdftotext - else: - cmd = ['/usr/bin/mdimport', '-d2', pdf] + cmd = ['/usr/bin/mdimport', '-d2', pdf] + else: + cmd = ['pdftotext', pdf, '-'] if sys.platform == 'win32': startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW @@ -254,7 +251,7 @@ def extract_text(pdf): stdout, stderr = p.communicate() stdout = stdout.decode() stderr = stderr.decode() - if sys.platform == 'darwin' and cmd[0] == '/usr/bin/mdimport': + if sys.platform == 'darwin': if 'kMDItemTextContent' in stderr: stdout = stderr.split('kMDItemTextContent = "')[-1].split('\n')[0][:-2] else: diff --git a/oml/tasks.py b/oml/tasks.py index 93d3b45..3f97379 100644 --- a/oml/tasks.py +++ b/oml/tasks.py @@ -36,10 +36,7 @@ class Tasks(Thread): def run(self): self.load_tasks() - if time.mktime(time.gmtime()) - settings.server.get('last_scan', 0) > 24*60*60: - settings.server['last_scan'] = time.mktime(time.gmtime()) - self.queue('scan') - + self.queue('scan') import item.scan from item.models import sync_metadata, get_preview, get_cover from user.models import (