better year detection

This commit is contained in:
j 2019-06-10 10:32:58 +01:00
parent c0cff7c541
commit c001e6fed7

View file

@ -33,13 +33,14 @@ for d in api.findDocuments({
if title != document['title']:
edit['title'] = title
year = re.compile('\d{4}').findall(document['title'])
if year and not document.get('date'):
year = re.compile(' \d{4} ').findall(document['title'])
if year and year[0] in ('1', '2') and not document.get('date'):
document['date'] = edit['date'] = year[0]
if document.get('date') and document['date'] in title:
title = title.replace(document['date'], '').strip()
edit['title'] = title
if title:
edit['title'] = title
if edit:
edit['id'] = d['id']