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'],