Getting schedule from frab works
This commit is contained in:
parent
dba3b68c07
commit
d8259446b6
|
@ -10,6 +10,9 @@ from staticfiles import copy_dir
|
||||||
|
|
||||||
WIKI_URL = "https://events.ccc.de/congress/2017/wiki/api.php?action=parse&page=Assembly:CSOC&format=json&prop=text"
|
WIKI_URL = "https://events.ccc.de/congress/2017/wiki/api.php?action=parse&page=Assembly:CSOC&format=json&prop=text"
|
||||||
|
|
||||||
|
FLIGHTPLAN_URL = "https://fahrplan.events.ccc.de/congress/2017/Fahrplan/schedule.json"
|
||||||
|
MISSION_CREW = ['Tim Pritlove', 'Charles Stross', 'Mathias Dalheimer', 'ktemkin']
|
||||||
|
|
||||||
STATIC_FILES_DIR = "static/"
|
STATIC_FILES_DIR = "static/"
|
||||||
TEMPLATE_DIR = "templates"
|
TEMPLATE_DIR = "templates"
|
||||||
|
|
||||||
|
@ -34,11 +37,31 @@ def render_to_file(jinja_env, template, context, url, output_dir):
|
||||||
|
|
||||||
def generate_index(jinja_env, output_dir):
|
def generate_index(jinja_env, output_dir):
|
||||||
resp = requests.get(WIKI_URL)
|
resp = requests.get(WIKI_URL)
|
||||||
page = resp.json()['parse']
|
|
||||||
|
|
||||||
render_to_file(jinja_env, 'index.html', page, 'index.html', output_dir)
|
if resp.ok:
|
||||||
|
try:
|
||||||
|
page = resp.json()['parse']
|
||||||
|
render_to_file(jinja_env, 'index.html', page, 'index.html', output_dir)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def generate_flightplan(jinja_env, output_dir):
|
||||||
|
resp = requests.get(FLIGHTPLAN_URL)
|
||||||
|
|
||||||
|
if resp.ok:
|
||||||
|
lectures = []
|
||||||
|
days = resp.json()['schedule']['conference']['days']
|
||||||
|
|
||||||
|
for day in days:
|
||||||
|
for room in day['rooms'].values():
|
||||||
|
for lecture in room:
|
||||||
|
persons = lecture['persons']
|
||||||
|
if any([person['public_name'] in MISSION_CREW for person in persons]):
|
||||||
|
lectures += [lecture]
|
||||||
|
|
||||||
|
print(lectures)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
print("Usage: %s" % sys.argv[0])
|
print("Usage: %s" % sys.argv[0])
|
||||||
|
@ -47,7 +70,6 @@ def main():
|
||||||
output_dir = os.path.abspath(sys.argv[1])
|
output_dir = os.path.abspath(sys.argv[1])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if not os.path.exists(output_dir):
|
if not os.path.exists(output_dir):
|
||||||
os.mkdir(output_dir)
|
os.mkdir(output_dir)
|
||||||
|
|
||||||
|
@ -56,7 +78,9 @@ def main():
|
||||||
|
|
||||||
template_dir = os.path.join(BASE_DIR, TEMPLATE_DIR)
|
template_dir = os.path.join(BASE_DIR, TEMPLATE_DIR)
|
||||||
jinja_env = Environment(loader=FileSystemLoader(template_dir))
|
jinja_env = Environment(loader=FileSystemLoader(template_dir))
|
||||||
|
|
||||||
generate_index(jinja_env, output_dir)
|
generate_index(jinja_env, output_dir)
|
||||||
|
generate_flightplan(jinja_env, output_dir)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue