From 24685b853ef2d0887f42b4c11e05d7e2f4eaa995 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 28 Jun 2020 10:21:56 +0200 Subject: [PATCH] only run on collection --- cleanup/add_date.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cleanup/add_date.py b/cleanup/add_date.py index cc8080e..b51476b 100644 --- a/cleanup/add_date.py +++ b/cleanup/add_date.py @@ -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']