forked from voc/schedule
-
Notifications
You must be signed in to change notification settings - Fork 1
/
schedule_rC3_21.py
executable file
·347 lines (296 loc) · 11.7 KB
/
schedule_rC3_21.py
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import requests
import json
import pytz
import os
import sys
import optparse
import git as gitlib
from voc.schedule import Schedule, ScheduleEncoder, Event
from voc.tools import commit_changes_if_something_relevant_changed, ensure_folders_exist, git, harmonize_event_type, load_json, write
from voc import rc3hub
tz = pytz.timezone('Europe/Amsterdam')
parser = optparse.OptionParser()
parser.add_option('--online', action='store_true', dest='online', default=False)
parser.add_option('--show-assembly-warnings', action='store_true', dest='show_assembly_warnings', default=False)
parser.add_option('--fail', action='store_true', dest='exit_when_exception_occours', default=False)
parser.add_option('--stats', action='store_true', dest='only_stats', default=False)
parser.add_option('--git', action='store_true', dest='git', default=False)
parser.add_option('--debug', action='store_true', dest='debug', default=False)
options, args = parser.parse_args()
local = False
use_offline_frab_schedules = False
only_workshops = False
# channels = requests \
# .get('https://c3voc.de/wiki/lib/exe/graphql2.php?query={channels{nodes{name:slug,url:schedule_url,schedule_room,room_guid,prefix}}}') \
# .json()['data']['channels']['nodes']
xc3 = 'rC3_21'
channels = [
{
'url': 'https://pretalx.c3voc.de/rc3-2021-fem/schedule/export/schedule.json',
'name': 'FeM',
'room_guid': '69371c99-1f93-4d01-8ea6-65b0e748b9e0',
'stage': 'FeM Channel'
},
{
'url': 'https://pretalx.c3voc.de/rc3-2021-cbase/schedule/export/schedule.json',
'name': 'c-base',
'room_guid': '5cfed623-26cc-4ac4-a4b2-0653195ddb4a',
'stage': 'c-base'
},
{
'url': 'https://pretalx.c3voc.de/rc3-2021-cwtv/schedule/export/schedule.json',
'name': 'CWTV',
'room_guid': '01a11ad1-38e2-464d-b0bb-de6a85534ed4',
'stage': 'Chaos-West TV'
},
{
'url': 'https://pretalx.c3voc.de/rc3-2021-chaosstudiohamburg/schedule/export/schedule.json',
'name': 'Chaosstudio Hamburg',
'room_guid': 'a4475839-786e-451b-aaa4-b37ed830ab2f',
'stage': 'Chaosstudio Hamburg'
},
{
'url': 'https://pretalx.c3voc.de/rc3-2021-chaoszone/schedule/export/schedule.json',
'name': 'ChaosZone TV',
'room_guid': 'e72d07ac-75b2-4b93-8f05-4bc7fe6e7e96',
'stage': 'ChaosZone TV'
},
{
'url': 'https://pretalx.c3voc.de/rc3-2021-r3s/schedule/export/schedule.json',
'name': 'r3s',
'room_guid': 'f91f4af4-b667-4705-9aab-5c280177bf49',
'stage': 'r3s - Monheim/Rhein'
},
{
'url': 'https://cfp.franconian.net/end-of-year-event-2021/schedule/export/schedule.json',
'name': 'franconian.net',
'options': {
'overwrite_slug': True
},
'room_guid': '6e8bfc10-0670-412e-bbe9-7b9aa1dcd714',
'stage': 'franconian.net'
},
{
'url': 'https://pretalx.c3voc.de/rc3-2021-hacc-a-f/schedule/export/schedule.json',
'name': 'about:future / hacc',
'room_guid': 'c2789542-5d1a-41a7-a934-119f762fbdb0',
'stage': 'about:future stage'
},
{
'url': 'https://pretalx.c3voc.de/rc3-2021-sendezentrum/schedule/export/schedule.json',
'name': 'Sendezentrum',
'room_guid': 'd1915b0a-6d9d-47f0-b9e8-3c00ab62e2fe',
'stage': 'Sendezentrum Bühne'
},
{
'url': 'https://pretalx.c3voc.de/rc3-2021-haecksen/schedule/export/schedule.json',
'name': 'haecksen',
'room_guid': '6246d4db-85df-47de-b4ef-1edb76b5bd7b',
'stage': 'Haecksen Stream'
},
{
'url': 'https://pretalx.c3voc.de/rc3-2021-gehacktes-from-hell/schedule/export/schedule.json',
'name': 'hell',
'room_guid': 'e5d65c11-3c4e-418c-aebe-4fc7a655176b',
'stage': 'Bierscheune'
},
{
'url': 'https://pretalx.c3voc.de/rc3-2021-xhain/schedule/export/schedule.json',
'name': 'xHain',
'room_guid': '32277bdb-ae00-4cfb-81f1-e9ef36aee72d',
'stage': 'Lichtung'
},
{
'url': 'https://pretalx.c3voc.de/rc3-2021-lounge/schedule/export/schedule.json',
'name': 'lounge',
'room_guid': '3fa26587-25ef-4b6e-9d16-e9e16bc26854',
'stage': 'rC3 Lounge'
},
{
'url': 'https://pretalx.c3voc.de/rc3-2021-chill-lounge/schedule/export/schedule.json',
'name': 'abchillgleis',
'room_guid': '94170a45-363b-40e3-9157-c044f1c56309',
'stage': 'Abchillgleis'
},
]
additional_schedule_urls = channels
targets = [
'filesystem',
'voctoimport',
# 'rc3hub'
]
id_offsets = {
# franconian local talk ids are <100, but speaker integer ids might collide
# when 10 additional speakers are created there
# c3voc pretalx schedule local ids' range from 120 to till >500
}
# this list/map is required to sort the events in the schedule.xml in the correct way
# other rooms/assemblies are added at the end on demand.
rooms = {
'channels': [
# channels with video recordings/livestream – same order as streaming website
'Chaos-West TV',
'Chaosstudio Hamburg',
'ChaosZone TV',
'c-base',
'r3s - Monheim/Rhein',
'FeM Channel',
'franconian.net',
'about:future stage',
'Sendezentrum Bühne',
'Haecksen Stream',
'Lichtung',
'Bierscheune',
],
'rooms': [
],
'music': [
'rC3 Lounge',
'Abchillgleis',
]
}
output_dir = '/srv/www/' + xc3
secondary_output_dir = './' + xc3
ensure_folders_exist(output_dir, secondary_output_dir)
os.chdir(output_dir)
def main():
#try:
# full_schedule = Schedule.from_url(main_schedule_url)
# print(' version: ' + full_schedule.version())
# #print(' contains {events_count} events, with local ids from {min_id} to {max_id}'.format(**full_schedule.stats.__dict__))
#except:
full_schedule = Schedule.from_XC3_template(None, 38, 27, 4)
conference = full_schedule.conference()
conference['acronym'] = 'rc3-2021'
conference['title'] = 'rC3 NOWHERE'
loaded_schedules = {}
# add additional rooms from this local config now, so they are in the correct order
for key in rooms:
full_schedule.add_rooms(rooms[key])
# add room guid's to schedule class
for entry in channels:
if entry.get('room_guid'):
full_schedule._room_ids[entry['stage'] or entry['name']] = entry['room_guid']
# add events from additional_schedule's to full_schedule
for entry in additional_schedule_urls:
try:
print('\n== Channel ' + entry['name'])
url = entry['url'].replace('schedule.xml', 'schedule.json')
if not url:
print(' has no schedule_url yet – ignoring')
continue
if url in loaded_schedules:
print(' schedule ' + url + ' was already loaded – ignoring')
continue
other_schedule = Schedule.from_url(url)
loaded_schedules[url] = True
if 'version' in other_schedule.schedule():
full_schedule._schedule['schedule']['version'] += '; {}'.format(entry['name'])
print(' version: ' + other_schedule.version())
else:
print(' WARNING: schedule "{}" does not have a version number'.format(entry['name']))
try:
print(' contains {events_count} events, with local ids from {min_id} to {max_id}'.format(**other_schedule.stats.__dict__))
print(' local person ids from {person_min_id} to {person_max_id}'.format(**other_schedule.stats.__dict__))
print(' rooms: {}'.format(', '.join(other_schedule.rooms())))
except:
pass
id_offset = entry.get('id_offset') or id_offsets.get(entry['name']) or 0
if full_schedule.add_events_from(other_schedule, id_offset=id_offset, options={
**(entry.get('options') or {}),
'prefix_person_ids': entry.get('prefix')
}):
print(' success')
except KeyboardInterrupt:
exit()
except requests.exceptions.HTTPError as e:
if e.response.status_code == 404:
print(' not yet available (404)')
else:
print(' HTTP ERROR: ' + str(e))
if options.exit_when_exception_occours:
raise e
except Exception as e:
print(' UNEXPECTED ERROR:' + str(sys.exc_info()[1]))
if options.exit_when_exception_occours:
raise e
# remove breaks from lightning talk schedule import
# full_schedule.remove_event(guid='bca1ec84-e62d-528a-b254-68401ece6c7c')
if options.only_stats:
exit()
full_schedule.foreach_event(harmonize_event_type)
# write all events from the channels to an own schedule.json/xml
export_stages_schedule(full_schedule)
export_streams_schedule(full_schedule)
# to get proper a state, we first have to remove all event files from the previous run
if not local or options.git:
git('rm events/*')
# write separate file for each event, to get better git diffs
def export_event(event: Event):
origin_system = None
if isinstance(event, Event):
origin_system = event.origin.origin_system
with open('events/{}.json'.format(event['guid']), 'w') as fp:
json.dump({
**event,
'room_id': full_schedule._room_ids.get(event['room'], None),
'origin': origin_system or None,
}, fp, indent=2, cls=ScheduleEncoder)
full_schedule.foreach_event(export_event)
# write all events to one big schedule.json/xml
write('\nExporting... ')
full_schedule.export('everything')
# expose metadata to own file
with open('meta.json', 'w') as fp:
json.dump({
'data': {
'version': full_schedule.version(),
'source_urls': list(loaded_schedules.keys()),
'rooms': [{
'guid': full_schedule._room_ids.get(room, None),
'schedule_name': room
} for room in full_schedule.rooms()],
'channels': channels
},
}, fp, indent=2, cls=ScheduleEncoder)
print('\nDone')
print(' version: ' + full_schedule.version())
print('\n rooms: ')
for room in full_schedule.rooms():
print(' - ' + room)
print()
if not local or options.git:
commit_changes_if_something_relevant_changed(full_schedule)
def export_stages_schedule(full_schedule):
write('\nExporting channels... ')
schedule = full_schedule.copy('Channels')
for day in schedule.days():
i = 0
room_keys = list(day['rooms'].keys())
for room_key in room_keys:
if not(room_key in rooms['channels']):
del day['rooms'][room_key]
i += 1
print('\n channels: ')
for room in schedule.rooms():
print(' - {} {}'.format(full_schedule._room_ids.get(room), room))
schedule._schedule['schedule']['version'] = schedule.version().split(';')[0]
schedule.export('channels')
return schedule
def export_streams_schedule(full_schedule):
write('\nExporting streams... ')
schedule = full_schedule.copy('Streams')
for day in schedule.days():
i = 0
room_keys = list(day['rooms'].keys())
for room_key in room_keys:
if not(room_key in rooms['channels']) and not(room_key in rooms['music']):
del day['rooms'][room_key]
i += 1
schedule._schedule['schedule']['version'] = schedule.version().split(';')[0]
schedule.export('streams')
return schedule
if __name__ == '__main__':
main()