From d77b78fb331f957f269e0e8bab2289cb64da8ae9 Mon Sep 17 00:00:00 2001 From: Nemo Date: Wed, 27 Mar 2024 14:27:53 +0530 Subject: [PATCH] update zomato --- src/zomato.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/zomato.py b/src/zomato.py index e7ff64cb..6ac7ddbe 100644 --- a/src/zomato.py +++ b/src/zomato.py @@ -52,8 +52,10 @@ def get_event_details(event_id, zomaland = False): def parse_datetime(dt): tz = datetime.timezone(datetime.timedelta(hours=5, minutes=30)) # Asia/Kolkata timezone + print(dt) (start,end) = dt.split("-") r_start = None + print(start) for d in list(datefinder.find_dates(start)): days = (d - datetime.datetime.now()).days if days > 0 and days < 90: @@ -63,6 +65,9 @@ def parse_datetime(dt): r_end = dd break + if r_start == None: + return None + # Move end by 1 day if r_end < r_start: r_end = r_end + datetime.timedelta(days=1) @@ -95,6 +100,8 @@ def make_event(event_id, data): # IF not, let us check our datetime properly if 'url' not in r and 'onwards' not in r['datetime']: r['start'], r['end'] = parse_datetime(r['datetime']) + if r['start'] == None: + return None return r @@ -104,6 +111,8 @@ def make_event(event_id, data): # Zomaland tickets show up via Insider anyway if not zomaland: jsonData = get_event_details(e, zomaland) - events.append(make_event(e, jsonData)) + event = make_event(e, jsonData) + if event!=None: + events.append(event) with open("out/zomato.json", "w") as f: json.dump(sorted(events, key=lambda x: x['event_id']), f, indent=2)