]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import ( | |
3 | int_or_none, | |
4 | parse_iso8601, | |
5 | try_get, | |
6 | url_or_none, | |
7 | ) | |
8 | ||
9 | ||
10 | class CCCIE(InfoExtractor): | |
11 | IE_NAME = 'media.ccc.de' | |
12 | _VALID_URL = r'https?://(?:www\.)?media\.ccc\.de/v/(?P<id>[^/?#&]+)' | |
13 | ||
14 | _TESTS = [{ | |
15 | 'url': 'https://media.ccc.de/v/30C3_-_5443_-_en_-_saal_g_-_201312281830_-_introduction_to_processor_design_-_byterazor#video', | |
16 | 'md5': '3a1eda8f3a29515d27f5adb967d7e740', | |
17 | 'info_dict': { | |
18 | 'id': '1839', | |
19 | 'ext': 'mp4', | |
20 | 'title': 'Introduction to Processor Design', | |
21 | 'creator': 'byterazor', | |
22 | 'description': 'md5:df55f6d073d4ceae55aae6f2fd98a0ac', | |
23 | 'thumbnail': r're:^https?://.*\.jpg$', | |
24 | 'upload_date': '20131228', | |
25 | 'timestamp': 1388188800, | |
26 | 'duration': 3710, | |
27 | 'tags': list, | |
28 | } | |
29 | }, { | |
30 | 'url': 'https://media.ccc.de/v/32c3-7368-shopshifting#download', | |
31 | 'only_matching': True, | |
32 | }] | |
33 | ||
34 | def _real_extract(self, url): | |
35 | display_id = self._match_id(url) | |
36 | webpage = self._download_webpage(url, display_id) | |
37 | event_id = self._search_regex(r"data-id='(\d+)'", webpage, 'event id') | |
38 | event_data = self._download_json('https://media.ccc.de/public/events/%s' % event_id, event_id) | |
39 | ||
40 | formats = [] | |
41 | for recording in event_data.get('recordings', []): | |
42 | recording_url = recording.get('recording_url') | |
43 | if not recording_url: | |
44 | continue | |
45 | language = recording.get('language') | |
46 | folder = recording.get('folder') | |
47 | format_id = None | |
48 | if language: | |
49 | format_id = language | |
50 | if folder: | |
51 | if language: | |
52 | format_id += '-' + folder | |
53 | else: | |
54 | format_id = folder | |
55 | vcodec = 'h264' if 'h264' in folder else ( | |
56 | 'none' if folder in ('mp3', 'opus') else None | |
57 | ) | |
58 | formats.append({ | |
59 | 'format_id': format_id, | |
60 | 'url': recording_url, | |
61 | 'width': int_or_none(recording.get('width')), | |
62 | 'height': int_or_none(recording.get('height')), | |
63 | 'filesize': int_or_none(recording.get('size'), invscale=1024 * 1024), | |
64 | 'language': language, | |
65 | 'vcodec': vcodec, | |
66 | }) | |
67 | self._sort_formats(formats) | |
68 | ||
69 | return { | |
70 | 'id': event_id, | |
71 | 'display_id': display_id, | |
72 | 'title': event_data['title'], | |
73 | 'creator': try_get(event_data, lambda x: ', '.join(x['persons'])), | |
74 | 'description': event_data.get('description'), | |
75 | 'thumbnail': event_data.get('thumb_url'), | |
76 | 'timestamp': parse_iso8601(event_data.get('date')), | |
77 | 'duration': int_or_none(event_data.get('length')), | |
78 | 'tags': event_data.get('tags'), | |
79 | 'formats': formats, | |
80 | } | |
81 | ||
82 | ||
83 | class CCCPlaylistIE(InfoExtractor): | |
84 | IE_NAME = 'media.ccc.de:lists' | |
85 | _VALID_URL = r'https?://(?:www\.)?media\.ccc\.de/c/(?P<id>[^/?#&]+)' | |
86 | _TESTS = [{ | |
87 | 'url': 'https://media.ccc.de/c/30c3', | |
88 | 'info_dict': { | |
89 | 'title': '30C3', | |
90 | 'id': '30c3', | |
91 | }, | |
92 | 'playlist_count': 135, | |
93 | }] | |
94 | ||
95 | def _real_extract(self, url): | |
96 | playlist_id = self._match_id(url).lower() | |
97 | ||
98 | conf = self._download_json( | |
99 | 'https://media.ccc.de/public/conferences/' + playlist_id, | |
100 | playlist_id) | |
101 | ||
102 | entries = [] | |
103 | for e in conf['events']: | |
104 | event_url = url_or_none(e.get('frontend_link')) | |
105 | if event_url: | |
106 | entries.append(self.url_result(event_url, ie=CCCIE.ie_key())) | |
107 | ||
108 | return self.playlist_result(entries, playlist_id, conf.get('title')) |