only run on collection

This commit is contained in:
j 2020-06-28 10:21:56 +02:00
parent 8ca2e0cd63
commit 24685b853e
1 changed files with 12 additions and 1 deletions

View File

@ -14,11 +14,22 @@ import dateparser
import ox.api
api = ox.api.signin('https://archive.leftove.rs/api/')
if len(sys.argv) > 1:
collection = sys.argv[1]
query = {
'conditions': [
{'key': 'collection', 'operator': '==', 'value': collection}
]
}
else:
query = {}
if os.path.exists('titles.json'):
titles = json.load(open('titles.json'))
else:
titles = api.findDocuments({
'query': {},
'query': query,
'keys': ['id', 'title', 'date'],
'range': [0, 15000]
})['data']['items']