better year detection
This commit is contained in:
parent
c0cff7c541
commit
c001e6fed7
1 changed files with 4 additions and 3 deletions
|
@ -34,11 +34,12 @@ for d in api.findDocuments({
|
||||||
edit['title'] = title
|
edit['title'] = title
|
||||||
|
|
||||||
year = re.compile(' \d{4} ').findall(document['title'])
|
year = re.compile(' \d{4} ').findall(document['title'])
|
||||||
if year and not document.get('date'):
|
if year and year[0] in ('1', '2') and not document.get('date'):
|
||||||
document['date'] = edit['date'] = year[0]
|
document['date'] = edit['date'] = year[0]
|
||||||
|
|
||||||
if document.get('date') and document['date'] in title:
|
if document.get('date') and document['date'] in title:
|
||||||
title = title.replace(document['date'], '').strip()
|
title = title.replace(document['date'], '').strip()
|
||||||
|
if title:
|
||||||
edit['title'] = title
|
edit['title'] = title
|
||||||
|
|
||||||
if edit:
|
if edit:
|
||||||
|
|
Loading…
Reference in a new issue