-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_talks.py
More file actions
56 lines (46 loc) · 1.59 KB
/
process_talks.py
File metadata and controls
56 lines (46 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import json
import requests
import warnings
from urllib3.exceptions import NotOpenSSLWarning
# Suppress NotOpenSSLWarning
warnings.filterwarnings("ignore", category=NotOpenSSLWarning)
# URL of the JSON data
url = "https://www.breizhcamp.org/json/talks.json"
# Fetch the JSON data from the URL
response = requests.get(url)
input_data = response.json()
# Initialize the output data structure
output_data = {
"sessions": {},
"speakers": {}
}
# Function to generate a unique speaker ID
def generate_speaker_id(name):
return name.lower().replace(" ", "_")
# Process each session in the input data
for session in input_data:
session_id = session["id"]
speaker_name = session["speakers"]
# Generate speaker ID
speaker_id = generate_speaker_id(speaker_name)
# Add session details to output data
output_data["sessions"][session_id] = {
"speakers": [speaker_id],
"tags": [session["format"]],
"title": session["name"],
"id": session_id,
"startTime": session["event_start"],
"endTime": session["event_end"],
"trackTitle": session["venue"]
}
# Add speaker details to output data, even all set to nullity
if speaker_id not in output_data["speakers"]:
output_data["speakers"][speaker_id] = {
"name": speaker_name,
"photoUrl": None,
"socials": None,
"id": speaker_id
}
# Write the JSON output to a file formatted for OpenFeedback
with open('openfeedback_output.json', 'w', encoding='utf-8') as outfile:
json.dump(output_data, outfile, indent=4, ensure_ascii=False)