only run on collection

This commit is contained in:
j 2020-06-28 10:23:21 +02:00
parent 24685b853e
commit 7049589f0e

View file

@ -1,5 +1,6 @@
#!/usr/bin/python3
import re
import sys
import ox
import ox.api
@ -7,6 +8,14 @@ import ox.api
site = 'archive.leftove.rs'
api = ox.api.signin('https://%s/api/' % site)
if len(sys.argv) > 1:
collection = sys.argv[1]
conditions = [
{'key': 'collection', 'operator': '==', 'value': collection}
]
else:
conditions = []
for regex, fragments in (
['Vol. \d+, No. \d+', ['Vol.', 'No.']],
['Vol \d+ no \d+', [' Vol ', ' no ']],
@ -17,7 +26,7 @@ for regex, fragments in (
'conditions': [
{'key': 'title', 'operator': '=', 'value': fragment}
for fragment in fragments
],
] + conditions,
'operator': '&'
},
'keys': ['id', 'title', 'volume'],