From 7049589f0eacbef206b31542c11afea68ff7187c Mon Sep 17 00:00:00 2001 From: j Date: Sun, 28 Jun 2020 10:23:21 +0200 Subject: [PATCH] only run on collection --- cleanup/add_volume.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cleanup/add_volume.py b/cleanup/add_volume.py index 4aeae0d..26d3eb5 100755 --- a/cleanup/add_volume.py +++ b/cleanup/add_volume.py @@ -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'],