Created
September 28, 2016 17:22
-
-
Save lukasheinrich/70bc0da9f19845b32567b29dec7d7647 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import urllib | |
import datetime | |
event = '443176' | |
sessionid = 175282 | |
date = '2016-07-05' | |
time = '08:30:00' | |
sessiondata = requests.get('https://indico.cern.ch/export/event/{}/session/{}.json'.format(event,sessionid)).json() | |
thisone = [x for x in sessiondata['results'] if x['startDate']['time']==time][0] | |
contrib_data = [] | |
for x in thisone['contributions']: | |
time = datetime.datetime.strptime('{} {}'.format(x['startDate']['date'],x['startDate']['time']),'%Y-%m-%d %H:%M:%S') | |
lastname = x['speakers'][0]['last_name'] | |
attachments = [d['download_url'] for d in x['folders'][0]['attachments']] | |
contrib_data += [(time,lastname,attachments)] | |
sorted_data = sorted(contrib_data,key = lambda x:x[0]) | |
for i,x in enumerate(sorted_data): | |
for j,att in enumerate(x[2]): | |
urllib.urlretrieve (att, '{:03}-{:03}-{}.pdf'.format(i,j,x[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment