Skip to content

Commit

Permalink
feat: fix longstanding last_modified and dtstamp issue once for all
Browse files Browse the repository at this point in the history
BREAKING CHANGE: ics 0.7.2 complies w/ only RFC 2445 while 0.8.0.dev0
complies w/ RFC 5545, ics format is a bit different because of this
  • Loading branch information
Vinfall committed May 18, 2024
1 parent 2443ccc commit d9e36db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dateparser==1.2.0
requests==2.31.0
ics==0.7.2
ics==0.8.0.dev0
11 changes: 8 additions & 3 deletions vndb-calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,28 +366,33 @@ def make_calendar(processed_results):
# Only show estimation message in above cases
description_suffix = f'\nEstimated on "{result["released"]}"'

# Ensure release_date is a datetime object
if isinstance(release_date, str):
release_date = datetime.strptime(release_date, "%Y-%m-%d")

if args.description and result["intro"]:
description = url + "\n" + result["intro"] + description_suffix
else:
description = url + description_suffix
# TODO: include more info
event = Event(
uid=rid, # release identifier is more unique, but would conflict with event_dict below
name=title,
summary=title,
description=description,
begin=release_date,
last_modified=now,
dtstamp=now,
categories=["vn_release"],
)
event.make_all_day()

# Only add events if it's a different VN
# Only append events if it's a different VN
# Do NOT use release_date as a VN can have multiple releases on different dates
key = (vid, title)
if key not in event_dict:
event_dict[key] = event
for event in event_dict.values():
cal.events.add(event)
cal.events.append(event)

with open(_OUTPUT_FOLDER + _ICS_FILE, "w", encoding="utf-8") as f:
f.write(cal.serialize())
Expand Down

0 comments on commit d9e36db

Please # to comment.