Last active
January 13, 2016 17:28
-
-
Save saerdnaer/c9b858f870f0b4caf43c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# -*- coding: UTF-8 -*- | |
#import requests | |
import json | |
from collections import OrderedDict | |
def main(): | |
data = None | |
session = "7306" #wget https://lab.dsst.io/32c3-slides/slides/7306.json | |
media_event_id = "2935" #wget https://media.ccc.de/public/events/2935 | |
slug = "32c3-7306-jahresruckblick_des_ccc" | |
with open(session + ".json", "r", encoding='utf8') as fp: | |
#in = json.load(fp) | |
# maintain order from file | |
temp = fp.read() | |
data = json.JSONDecoder(object_pairs_hook=OrderedDict).decode(temp) | |
#r = requests.get("https://media.ccc.de/public/events/" + slug) | |
#print(json.dumps(r, indent=4)) | |
with open(media_event_id + "", "r", encoding='utf8') as fp: | |
#in = json.load(fp) | |
# maintain order from file | |
temp = fp.read() | |
event = json.JSONDecoder(object_pairs_hook=OrderedDict).decode(temp) | |
sources = {} | |
for recording in event['recordings']: | |
(type, format) = recording['display_mime_type'].split('/', 2) | |
if type != 'video': | |
continue | |
if recording['mime_type'].endswith('-web'): | |
continue | |
if recording['height'] == None and recording['width'] == None: | |
# alternative: recording['folder'].contains('-hd') | |
if recording['mime_type'].endswith('-hd'): | |
recording['width'] = 1920 | |
recording['height'] = 1080 | |
else: # sd: PAL wide | |
recording['width'] = 1024 | |
recording['height'] = 576 | |
if format not in sources: | |
sources[format] = [] | |
sources[format].append({ | |
"src": recording['recording_url'], | |
"mimetype": recording['display_mime_type'], | |
"res": {"w": recording['width'],"h": recording['height']}, | |
"lang": recording['language'] | |
}) | |
frame_list = [] | |
for item in data: | |
# convert frame count to seconds | |
time = round(item['start']/25) | |
frame_list.append(OrderedDict([ | |
('id', 'frame_' + str(time)), | |
('mimetype', 'image/jpeg'), | |
('time', time), | |
('url', 'https://lab.dsst.io/32c3-slides/slides/' + session + '/' + str(item['index']) +'.jpg'), | |
#('thumb', '') | |
])) | |
paella_data = OrderedDict([ | |
("streams", [{ | |
"sources": sources, | |
"preview": event['poster_url'] | |
}]), | |
("frameList", frame_list), | |
("metadata", { | |
"title": event['title'], | |
"duration": event['length'] | |
}) | |
]) | |
print(json.dumps(paella_data, indent=4)) | |
with open(session + ".paella-data.json", "w", encoding='utf8') as fp: | |
json.dump(paella_data, fp, indent=4) | |
if __name__ == '__main__': | |
main() |
This file contains hidden or 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
{ | |
"streams": [ | |
{ | |
"sources": { | |
"mp4": [ | |
{ | |
"src": "http://cdn.media.ccc.de/congress/2015/h264-hd/32c3-7306-de-en-Jahresrueckblick_des_CCC_hd.mp4", | |
"lang": "de-en", | |
"mimetype": "video/mp4", | |
"res": { | |
"h": 1080, | |
"w": 1920 | |
} | |
}, | |
{ | |
"src": "http://cdn.media.ccc.de/congress/2015/h264-sd/32c3-7306-de-en-Jahresrueckblick_des_CCC_sd.mp4", | |
"lang": "de-en", | |
"mimetype": "video/mp4", | |
"res": { | |
"h": 576, | |
"w": 1024 | |
} | |
} | |
], | |
"webm": [ | |
{ | |
"src": "http://cdn.media.ccc.de/congress/2015/webm-hd/32c3-7306-de-en-Jahresrueckblick_des_CCC_webm-hd.webm", | |
"lang": "de-en", | |
"mimetype": "video/webm", | |
"res": { | |
"h": 1080, | |
"w": 1920 | |
} | |
}, | |
{ | |
"src": "http://cdn.media.ccc.de/congress/2015/webm-sd/32c3-7306-de-en-Jahresrueckblick_des_CCC_webm-sd.webm", | |
"lang": "de-en", | |
"mimetype": "video/webm", | |
"res": { | |
"h": 576, | |
"w": 1024 | |
} | |
} | |
] | |
}, | |
"preview": "https://static.media.ccc.de/media/congress/2015/7306-hd_preview.jpg" | |
} | |
], | |
"frameList": [ | |
{ | |
"id": "frame_109", | |
"mimetype": "image/jpeg", | |
"time": 109, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/0.jpg" | |
}, | |
{ | |
"id": "frame_119", | |
"mimetype": "image/jpeg", | |
"time": 119, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/1.jpg" | |
}, | |
{ | |
"id": "frame_217", | |
"mimetype": "image/jpeg", | |
"time": 217, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/2.jpg" | |
}, | |
{ | |
"id": "frame_383", | |
"mimetype": "image/jpeg", | |
"time": 383, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/3.jpg" | |
}, | |
{ | |
"id": "frame_397", | |
"mimetype": "image/jpeg", | |
"time": 397, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/4.jpg" | |
}, | |
{ | |
"id": "frame_440", | |
"mimetype": "image/jpeg", | |
"time": 440, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/5.jpg" | |
}, | |
{ | |
"id": "frame_541", | |
"mimetype": "image/jpeg", | |
"time": 541, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/6.jpg" | |
}, | |
{ | |
"id": "frame_626", | |
"mimetype": "image/jpeg", | |
"time": 626, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/7.jpg" | |
}, | |
{ | |
"id": "frame_655", | |
"mimetype": "image/jpeg", | |
"time": 655, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/8.jpg" | |
}, | |
{ | |
"id": "frame_713", | |
"mimetype": "image/jpeg", | |
"time": 713, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/9.jpg" | |
}, | |
{ | |
"id": "frame_798", | |
"mimetype": "image/jpeg", | |
"time": 798, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/10.jpg" | |
}, | |
{ | |
"id": "frame_819", | |
"mimetype": "image/jpeg", | |
"time": 819, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/11.jpg" | |
}, | |
{ | |
"id": "frame_902", | |
"mimetype": "image/jpeg", | |
"time": 902, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/12.jpg" | |
}, | |
{ | |
"id": "frame_1077", | |
"mimetype": "image/jpeg", | |
"time": 1077, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/13.jpg" | |
}, | |
{ | |
"id": "frame_1120", | |
"mimetype": "image/jpeg", | |
"time": 1120, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/14.jpg" | |
}, | |
{ | |
"id": "frame_1173", | |
"mimetype": "image/jpeg", | |
"time": 1173, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/15.jpg" | |
}, | |
{ | |
"id": "frame_1464", | |
"mimetype": "image/jpeg", | |
"time": 1464, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/16.jpg" | |
}, | |
{ | |
"id": "frame_1734", | |
"mimetype": "image/jpeg", | |
"time": 1734, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/17.jpg" | |
}, | |
{ | |
"id": "frame_1799", | |
"mimetype": "image/jpeg", | |
"time": 1799, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/18.jpg" | |
}, | |
{ | |
"id": "frame_2032", | |
"mimetype": "image/jpeg", | |
"time": 2032, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/19.jpg" | |
}, | |
{ | |
"id": "frame_2085", | |
"mimetype": "image/jpeg", | |
"time": 2085, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/20.jpg" | |
}, | |
{ | |
"id": "frame_2133", | |
"mimetype": "image/jpeg", | |
"time": 2133, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/21.jpg" | |
}, | |
{ | |
"id": "frame_2266", | |
"mimetype": "image/jpeg", | |
"time": 2266, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/22.jpg" | |
}, | |
{ | |
"id": "frame_2338", | |
"mimetype": "image/jpeg", | |
"time": 2338, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/23.jpg" | |
}, | |
{ | |
"id": "frame_2382", | |
"mimetype": "image/jpeg", | |
"time": 2382, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/24.jpg" | |
}, | |
{ | |
"id": "frame_2406", | |
"mimetype": "image/jpeg", | |
"time": 2406, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/25.jpg" | |
}, | |
{ | |
"id": "frame_2489", | |
"mimetype": "image/jpeg", | |
"time": 2489, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/26.jpg" | |
}, | |
{ | |
"id": "frame_2619", | |
"mimetype": "image/jpeg", | |
"time": 2619, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/27.jpg" | |
}, | |
{ | |
"id": "frame_2664", | |
"mimetype": "image/jpeg", | |
"time": 2664, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/28.jpg" | |
}, | |
{ | |
"id": "frame_2736", | |
"mimetype": "image/jpeg", | |
"time": 2736, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/29.jpg" | |
}, | |
{ | |
"id": "frame_2777", | |
"mimetype": "image/jpeg", | |
"time": 2777, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/30.jpg" | |
}, | |
{ | |
"id": "frame_3073", | |
"mimetype": "image/jpeg", | |
"time": 3073, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/31.jpg" | |
}, | |
{ | |
"id": "frame_3083", | |
"mimetype": "image/jpeg", | |
"time": 3083, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/32.jpg" | |
}, | |
{ | |
"id": "frame_3177", | |
"mimetype": "image/jpeg", | |
"time": 3177, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/33.jpg" | |
}, | |
{ | |
"id": "frame_3203", | |
"mimetype": "image/jpeg", | |
"time": 3203, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/34.jpg" | |
}, | |
{ | |
"id": "frame_3293", | |
"mimetype": "image/jpeg", | |
"time": 3293, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/35.jpg" | |
}, | |
{ | |
"id": "frame_3310", | |
"mimetype": "image/jpeg", | |
"time": 3310, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/36.jpg" | |
}, | |
{ | |
"id": "frame_3576", | |
"mimetype": "image/jpeg", | |
"time": 3576, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/37.jpg" | |
}, | |
{ | |
"id": "frame_3598", | |
"mimetype": "image/jpeg", | |
"time": 3598, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/38.jpg" | |
}, | |
{ | |
"id": "frame_3861", | |
"mimetype": "image/jpeg", | |
"time": 3861, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/39.jpg" | |
}, | |
{ | |
"id": "frame_3990", | |
"mimetype": "image/jpeg", | |
"time": 3990, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/40.jpg" | |
}, | |
{ | |
"id": "frame_4076", | |
"mimetype": "image/jpeg", | |
"time": 4076, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/41.jpg" | |
}, | |
{ | |
"id": "frame_4214", | |
"mimetype": "image/jpeg", | |
"time": 4214, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/42.jpg" | |
}, | |
{ | |
"id": "frame_4256", | |
"mimetype": "image/jpeg", | |
"time": 4256, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/43.jpg" | |
}, | |
{ | |
"id": "frame_4264", | |
"mimetype": "image/jpeg", | |
"time": 4264, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/44.jpg" | |
}, | |
{ | |
"id": "frame_4318", | |
"mimetype": "image/jpeg", | |
"time": 4318, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/45.jpg" | |
}, | |
{ | |
"id": "frame_4435", | |
"mimetype": "image/jpeg", | |
"time": 4435, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/46.jpg" | |
}, | |
{ | |
"id": "frame_4481", | |
"mimetype": "image/jpeg", | |
"time": 4481, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/47.jpg" | |
}, | |
{ | |
"id": "frame_4493", | |
"mimetype": "image/jpeg", | |
"time": 4493, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/48.jpg" | |
}, | |
{ | |
"id": "frame_4558", | |
"mimetype": "image/jpeg", | |
"time": 4558, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/49.jpg" | |
}, | |
{ | |
"id": "frame_4618", | |
"mimetype": "image/jpeg", | |
"time": 4618, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/50.jpg" | |
}, | |
{ | |
"id": "frame_4748", | |
"mimetype": "image/jpeg", | |
"time": 4748, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/51.jpg" | |
}, | |
{ | |
"id": "frame_4824", | |
"mimetype": "image/jpeg", | |
"time": 4824, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/52.jpg" | |
}, | |
{ | |
"id": "frame_4836", | |
"mimetype": "image/jpeg", | |
"time": 4836, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/53.jpg" | |
}, | |
{ | |
"id": "frame_4915", | |
"mimetype": "image/jpeg", | |
"time": 4915, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/54.jpg" | |
}, | |
{ | |
"id": "frame_5065", | |
"mimetype": "image/jpeg", | |
"time": 5065, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/55.jpg" | |
}, | |
{ | |
"id": "frame_5149", | |
"mimetype": "image/jpeg", | |
"time": 5149, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/56.jpg" | |
}, | |
{ | |
"id": "frame_5386", | |
"mimetype": "image/jpeg", | |
"time": 5386, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/57.jpg" | |
}, | |
{ | |
"id": "frame_5728", | |
"mimetype": "image/jpeg", | |
"time": 5728, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/58.jpg" | |
}, | |
{ | |
"id": "frame_5832", | |
"mimetype": "image/jpeg", | |
"time": 5832, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/59.jpg" | |
}, | |
{ | |
"id": "frame_5954", | |
"mimetype": "image/jpeg", | |
"time": 5954, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/60.jpg" | |
}, | |
{ | |
"id": "frame_6154", | |
"mimetype": "image/jpeg", | |
"time": 6154, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/61.jpg" | |
}, | |
{ | |
"id": "frame_6236", | |
"mimetype": "image/jpeg", | |
"time": 6236, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/62.jpg" | |
}, | |
{ | |
"id": "frame_6328", | |
"mimetype": "image/jpeg", | |
"time": 6328, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/63.jpg" | |
}, | |
{ | |
"id": "frame_6346", | |
"mimetype": "image/jpeg", | |
"time": 6346, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/64.jpg" | |
}, | |
{ | |
"id": "frame_6449", | |
"mimetype": "image/jpeg", | |
"time": 6449, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/65.jpg" | |
}, | |
{ | |
"id": "frame_6543", | |
"mimetype": "image/jpeg", | |
"time": 6543, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/66.jpg" | |
}, | |
{ | |
"id": "frame_6605", | |
"mimetype": "image/jpeg", | |
"time": 6605, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/67.jpg" | |
}, | |
{ | |
"id": "frame_6677", | |
"mimetype": "image/jpeg", | |
"time": 6677, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/68.jpg" | |
}, | |
{ | |
"id": "frame_6749", | |
"mimetype": "image/jpeg", | |
"time": 6749, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/69.jpg" | |
}, | |
{ | |
"id": "frame_6831", | |
"mimetype": "image/jpeg", | |
"time": 6831, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/70.jpg" | |
}, | |
{ | |
"id": "frame_6847", | |
"mimetype": "image/jpeg", | |
"time": 6847, | |
"url": "https://lab.dsst.io/32c3-slides/slides/7306/71.jpg" | |
} | |
], | |
"metadata": { | |
"title": "Jahresr\u00fcckblick des CCC", | |
"duration": 7034 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment