only run on collection

This commit is contained in:
j 2020-06-28 10:21:56 +02:00
parent 8ca2e0cd63
commit 24685b853e

View file

@ -14,11 +14,22 @@ import dateparser
import ox.api import ox.api
api = ox.api.signin('https://archive.leftove.rs/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'): if os.path.exists('titles.json'):
titles = json.load(open('titles.json')) titles = json.load(open('titles.json'))
else: else:
titles = api.findDocuments({ titles = api.findDocuments({
'query': {}, 'query': query,
'keys': ['id', 'title', 'date'], 'keys': ['id', 'title', 'date'],
'range': [0, 15000] 'range': [0, 15000]
})['data']['items'] })['data']['items']