cleanup toc and extract for all epubs

This commit is contained in:
j 2016-01-12 00:23:11 +05:30
commit 18a72db811
2 changed files with 44 additions and 12 deletions

View file

@ -330,6 +330,20 @@ def upgrade_db(old, new=None):
if u.id != settings.USER_ID:
Metadata.get_or_create(u.id, i.id, i.meta, False)
session.commit()
if old <= '20160111-617-206e39c' and new > '20160111-617-206e39c':
from item.models import File
import media
with db.session() as session:
for f in File.query:
if f.info.get('extension') == 'epub':
if not 'tableofcontents' in f.item.meta:
f.info = media.metadata(f.fullpath())
if 'tableofcontents' in f.info:
f.item.meta['tableofcontents'] = f.info['tableofcontents']
f.item.update()
session.add(f.item)
session.add(f)
session.commit()
if old <= '20140527-120-3cb9819':
run_sql('CREATE INDEX ix_find_findvalue ON find (findvalue)')