Fixing problem where the uids have automatically got a random suffix which prevented a correct update detection

This commit is contained in:
Patrick Müller 2021-03-11 20:31:27 +01:00
parent df73c0164b
commit 765a5c235a

10
main.py
View File

@ -27,6 +27,7 @@ def crawl():
end=datetime.strptime((datetime.now() + timedelta(days=365)).strftime('%Y-%m-%d'), '%Y-%m-%d')) end=datetime.strptime((datetime.now() + timedelta(days=365)).strftime('%Y-%m-%d'), '%Y-%m-%d'))
except ValueError as error: except ValueError as error:
# Value error sometimes happens because of a problem with dateutil and timezones # Value error sometimes happens because of a problem with dateutil and timezones
print("error")
exit(1) exit(1)
# ______ __ __ __ __ __ __ ____ _____ ____ __ # ______ __ __ __ __ __ __ ____ _____ ____ __
@ -81,17 +82,18 @@ def crawl():
# Also removes the timezone from all the datetime objects # Also removes the timezone from all the datetime objects
evtIdx = {} evtIdx = {}
for event in events: for event in events:
# Remove random last part of uid
uid = event.uid
if '_' in uid:
event.uid = uid[:(uid.rindex('_'))]
if not event.uid in evtIdx.keys(): if not event.uid in evtIdx.keys():
# Event not known yet # Event not known yet
uid = event.uid uid = event.uid
# Remove random last part of uid
uid = uid[:(uid.rindex('_'))]
event.uid = uid + '---0' event.uid = uid + '---0'
evtIdx[uid] = 1 evtIdx[uid] = 1
else: else:
uid = event.uid uid = event.uid
# Remove random last part of uid
uid = uid[:(uid.rindex('_'))]
event.uid = uid + '---' + str(evtIdx[uid]) event.uid = uid + '---' + str(evtIdx[uid])
evtIdx[uid] += 1 evtIdx[uid] += 1
# Remove timezones # Remove timezones