From af1be07582394101a26a0f0b44efdc45d364cd06 Mon Sep 17 00:00:00 2001 From: Dreiundzwanzig Date: Sun, 20 Jun 2021 09:32:30 +0200 Subject: [PATCH] Add option to add specific center or doctor which --- README.md | 1 + doctoshotgun.py | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 120ec94..9c38ff1 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Further optional arguments: ``` --center "" [--center …] : filter centers to only choose one from the provided list +--additional-center "" [--ac …] : Add additional centers or doctors e.g. "Corona Impfzentren - Berlin;Berlin;/institut/berlin/ciz-berlin-berlin" -p , --patient : select patient for which book a slot -z, --pfizer : looking only for a Pfizer vaccine -m, --moderna : looking only for a Moderna vaccine diff --git a/doctoshotgun.py b/doctoshotgun.py index 08e4baf..0c654fe 100755 --- a/doctoshotgun.py +++ b/doctoshotgun.py @@ -228,7 +228,7 @@ def do_login(self): return True - def find_centers(self, where, motives=None): + def find_centers(self, where, motives=None, additional_centers=None): if motives is None: motives = self.vaccine_motives.keys() for city in where: @@ -256,6 +256,16 @@ def find_centers(self, where, motives=None): except KeyError: pass + if additional_centers: + for additional_center in additional_centers: + splitted = additional_center.split(';') + if len(splitted) == 3: + yield { + "name_with_title": splitted[0], #"Corona Impfzentren - Berlin", + "city": splitted[1], #"Berlin", + "url": splitted[2], #"/institut/berlin/ciz-berlin-berlin" + } + def get_patients(self): self.master_patient.go() @@ -511,6 +521,7 @@ def main(self): parser.add_argument('--patient', '-p', type=int, default=-1, help='give patient ID') parser.add_argument('--time-window', '-t', type=int, default=7, help='set how many next days the script look for slots (default = 7)') parser.add_argument('--center', '-c', action='append', help='filter centers') + parser.add_argument('--additional-center', '-ac', action='append', help='Add additional centers or doctors: "name;city;link" e.g. "Corona Impfzentren - Berlin;Berlin;/institut/berlin/ciz-berlin-berlin"') parser.add_argument('--start-date', type=str, default=None, help='first date on which you want to book the first slot (format should be DD/MM/YYYY)') parser.add_argument('--end-date', type=str, default=None, help='last date on which you want to book the first slot (format should be DD/MM/YYYY)') parser.add_argument('--dry-run', action='store_true', help='do not really book the slot') @@ -591,7 +602,7 @@ def main(self): while True: try: - for center in docto.find_centers(cities, motives): + for center in docto.find_centers(cities, motives, args.additional_center): if args.center: if center['name_with_title'] not in args.center: logging.debug("Skipping center '%s'", center['name_with_title'])