store metadata per user. remove primaryid. only store isbn13
This commit is contained in:
parent
90648f9e65
commit
02e040d9f5
16 changed files with 245 additions and 192 deletions
|
|
@ -11,11 +11,10 @@ from glob import glob
|
|||
from datetime import datetime
|
||||
|
||||
from PyPDF2 import PdfFileReader
|
||||
import stdnum.isbn
|
||||
import ox
|
||||
|
||||
import settings
|
||||
from utils import normalize_isbn, find_isbns, get_language
|
||||
from utils import get_language, to_isbn13, find_isbns
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -151,9 +150,9 @@ def info(pdf):
|
|||
del data[key]
|
||||
'''
|
||||
if 'identifier' in data:
|
||||
value = normalize_isbn(data['identifier'])
|
||||
if stdnum.isbn.is_valid(value):
|
||||
data['isbn'] = [value]
|
||||
value = to_isbn13(data['identifier'])
|
||||
if value:
|
||||
data['isbn'] = value
|
||||
del data['identifier']
|
||||
for key, value in data.items():
|
||||
if isinstance(value, dict):
|
||||
|
|
@ -170,9 +169,7 @@ def info(pdf):
|
|||
if not 'isbn' in data:
|
||||
isbn = extract_isbn(text)
|
||||
if isbn:
|
||||
data['isbn'] = [isbn]
|
||||
if 'isbn' in data and isinstance(data['isbn'], str):
|
||||
data['isbn'] = [data['isbn']]
|
||||
data['isbn'] = isbn
|
||||
if 'date' in data and len(data['date']) == 8 and data['date'].isdigit():
|
||||
d = data['date']
|
||||
data['date'] = '%s-%s-%s' % (d[:4], d[4:6], d[6:])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue