Skip to content

Commit

Permalink
bin/convert_from_pretalx.py: Use a variable/parameter for the year
Browse files Browse the repository at this point in the history
The warning is useful because of all the hard-coded values.
  • Loading branch information
primeos committed Jun 20, 2024
1 parent 67f7cc6 commit e3ec37c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions bin/convert_from_pretalx.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
#!/usr/bin/env python3

"""
Usage: ./convert_from_pretalx.py [YEAR]
Creates: "talks.json" based on the JSON data from our Pretalx CfP server.
"""

import json
import sys
from datetime import datetime, timedelta
import urllib.request


schedule_url = "https://cfp.tuebix.org/tuebix-2024/schedule/export/schedule.json"
YEAR = int(sys.argv[1] if len(sys.argv) == 2 else datetime.now().year)
if YEAR != 2024:
print("Warning: Potentially unsupported year.")

schedule_url = f"https://cfp.tuebix.org/tuebix-{YEAR}/schedule/export/schedule.json"
with urllib.request.urlopen(schedule_url) as data:
schedule = json.load(data)
with open("schedule.json", "w") as file:
json.dump(schedule, file)

# TODO: Don't hardcode the year, answer IDs, etc.
answers_url = "https://cfp.tuebix.org/api/events/tuebix-2024/answers/?format=json&limit=100"
answers_url = f"https://cfp.tuebix.org/api/events/tuebix-{YEAR}/answers/?format=json&limit=100"
with urllib.request.urlopen(answers_url) as data:
all_answers = json.load(data)["results"]

Expand Down Expand Up @@ -63,7 +73,7 @@ def gen_talks():

names, bios = merge_persons(talk['persons'])

slug = talk['slug'].removeprefix("tuebix-2024-")
slug = talk['slug'].removeprefix(f"tuebix-{YEAR}-")
# TODO: Try to improve the URL IDs for 2025 (maybe just ID + URL
# parameters for talk and author names (as they could change)?

Expand Down
2 changes: 1 addition & 1 deletion bin/update-schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def select_year():
def main():
year = select_year()
# TODO: Rewrite:
os.system("../bin/convert_from_pretalx.py")
os.system(f"../bin/convert_from_pretalx.py {year}")
os.system(f"../bin/json2md.py {year}")

if __name__ == "__main__":
Expand Down

0 comments on commit e3ec37c

Please sign in to comment.