Compare commits
6 Commits
a27ef9701f
...
4e4b853416
Author | SHA1 | Date |
---|---|---|
j | 4e4b853416 | |
j | c38d3a8b35 | |
j | debe3823e2 | |
j | e623307d19 | |
j | 1421e402e1 | |
j | 853f6cdc0c |
2
ctl
2
ctl
|
@ -56,7 +56,7 @@ else
|
||||||
ARCH="_armv7l"
|
ARCH="_armv7l"
|
||||||
fi
|
fi
|
||||||
PLATFORM="linux$ARCH"
|
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"
|
export UNRAR_LIB_PATH="$BASE/platform_${PLATFORM}/lib/libunrar.so"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -843,15 +843,17 @@ def download_cover(id):
|
||||||
url = i.meta.get('cover')
|
url = i.meta.get('cover')
|
||||||
else:
|
else:
|
||||||
url = None
|
url = None
|
||||||
|
cover = None
|
||||||
|
|
||||||
logger.debug('download cover %s %s', id, url)
|
logger.debug('download cover %s %s', id, url)
|
||||||
ratio = None
|
ratio = None
|
||||||
try:
|
if url:
|
||||||
cover = ox.net.read_url(url)
|
try:
|
||||||
ratio = get_ratio(cover)
|
cover = ox.net.read_url(url)
|
||||||
except:
|
ratio = get_ratio(cover)
|
||||||
logger.debug('unable to read cover url %s', url)
|
except:
|
||||||
cover = None
|
logger.debug('unable to read cover url %s', url)
|
||||||
|
cover = None
|
||||||
with db.session():
|
with db.session():
|
||||||
i = Item.get(id, for_update=True)
|
i = Item.get(id, for_update=True)
|
||||||
if i:
|
if i:
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
import zipfile
|
import zipfile
|
||||||
|
import logging
|
||||||
|
|
||||||
import ox
|
import ox
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def cover(path):
|
def cover(path):
|
||||||
data = None
|
data = None
|
||||||
logger.debug('cover %s', path)
|
logger.debug('cover %s', path)
|
||||||
|
|
|
@ -153,7 +153,7 @@ def info(epub):
|
||||||
contents.append(txt)
|
contents.append(txt)
|
||||||
if contents:
|
if contents:
|
||||||
data['tableofcontents'] = '\n'.join(contents).strip()
|
data['tableofcontents'] = '\n'.join(contents).strip()
|
||||||
if not 'tableofcontents' in data:
|
if 'tableofcontents' not in data:
|
||||||
guide = info.find('{http://www.idpf.org/2007/opf}guide')
|
guide = info.find('{http://www.idpf.org/2007/opf}guide')
|
||||||
if guide:
|
if guide:
|
||||||
for ref in guide.findall('{http://www.idpf.org/2007/opf}reference'):
|
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']))
|
data['description'] = strip_tags(decode_html(data['description']))
|
||||||
text = extract_text(epub)
|
text = extract_text(epub)
|
||||||
data['textsize'] = len(text)
|
data['textsize'] = len(text)
|
||||||
if not 'isbn' in data:
|
if 'isbn' not in data:
|
||||||
isbn = extract_isbn(text)
|
isbn = extract_isbn(text)
|
||||||
if isbn:
|
if isbn:
|
||||||
data['isbn'] = isbn
|
data['isbn'] = isbn
|
||||||
|
|
|
@ -237,10 +237,13 @@ def info(pdf):
|
||||||
def extract_text(pdf):
|
def extract_text(pdf):
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
pdf = get_short_path_name(pdf)
|
pdf = get_short_path_name(pdf)
|
||||||
|
cmd = ['pdftotext', pdf, '-']
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
cmd = ['/usr/bin/mdimport', '-d2', pdf]
|
pdftotext = ['/usr/local/bin/pdftotext', pdf, '-']
|
||||||
else:
|
if os.path.exists(pdftotext[0]):
|
||||||
cmd = ['pdftotext', pdf, '-']
|
cmd = pdftotext
|
||||||
|
else:
|
||||||
|
cmd = ['/usr/bin/mdimport', '-d2', pdf]
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
startupinfo = subprocess.STARTUPINFO()
|
startupinfo = subprocess.STARTUPINFO()
|
||||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||||
|
@ -251,7 +254,7 @@ def extract_text(pdf):
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
stdout = stdout.decode()
|
stdout = stdout.decode()
|
||||||
stderr = stderr.decode()
|
stderr = stderr.decode()
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin' and cmd[0] == '/usr/bin/mdimport':
|
||||||
if 'kMDItemTextContent' in stderr:
|
if 'kMDItemTextContent' in stderr:
|
||||||
stdout = stderr.split('kMDItemTextContent = "')[-1].split('\n')[0][:-2]
|
stdout = stderr.split('kMDItemTextContent = "')[-1].split('\n')[0][:-2]
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -36,7 +36,10 @@ class Tasks(Thread):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.load_tasks()
|
self.load_tasks()
|
||||||
self.queue('scan')
|
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')
|
||||||
|
|
||||||
import item.scan
|
import item.scan
|
||||||
from item.models import sync_metadata, get_preview, get_cover
|
from item.models import sync_metadata, get_preview, get_cover
|
||||||
from user.models import (
|
from user.models import (
|
||||||
|
|
Loading…
Reference in New Issue