| 
									
										
										
										
											2019-03-14 21:30:01 +01:00
										 |  |  | # coding: utf-8 | 
					
						
							| 
									
										
										
										
											2015-02-10 05:42:41 +01:00
										 |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .common import InfoExtractor | 
					
						
							|  |  |  | from ..utils import ( | 
					
						
							|  |  |  |     int_or_none, | 
					
						
							| 
									
										
										
										
											2016-05-01 01:43:58 +01:00
										 |  |  |     parse_iso8601, | 
					
						
							| 
									
										
										
										
											2019-03-14 21:30:01 +01:00
										 |  |  |     try_get, | 
					
						
							| 
									
										
										
										
											2019-04-28 23:05:36 +07:00
										 |  |  |     url_or_none, | 
					
						
							| 
									
										
										
										
											2015-02-10 05:42:41 +01:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class CCCIE(InfoExtractor): | 
					
						
							|  |  |  |     IE_NAME = 'media.ccc.de' | 
					
						
							| 
									
										
										
										
											2016-01-01 15:14:41 +06:00
										 |  |  |     _VALID_URL = r'https?://(?:www\.)?media\.ccc\.de/v/(?P<id>[^/?#&]+)' | 
					
						
							| 
									
										
										
										
											2015-02-10 05:42:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-01 15:14:41 +06:00
										 |  |  |     _TESTS = [{ | 
					
						
							|  |  |  |         'url': 'https://media.ccc.de/v/30C3_-_5443_-_en_-_saal_g_-_201312281830_-_introduction_to_processor_design_-_byterazor#video', | 
					
						
							| 
									
										
										
										
											2015-05-15 12:28:10 +01:00
										 |  |  |         'md5': '3a1eda8f3a29515d27f5adb967d7e740', | 
					
						
							| 
									
										
										
										
											2015-02-10 05:42:41 +01:00
										 |  |  |         'info_dict': { | 
					
						
							| 
									
										
										
										
											2016-05-01 01:43:58 +01:00
										 |  |  |             'id': '1839', | 
					
						
							| 
									
										
										
										
											2015-02-10 05:42:41 +01:00
										 |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |             'title': 'Introduction to Processor Design', | 
					
						
							| 
									
										
										
										
											2019-03-14 21:30:01 +01:00
										 |  |  |             'creator': 'byterazor', | 
					
						
							| 
									
										
										
										
											2016-05-01 01:43:58 +01:00
										 |  |  |             'description': 'md5:df55f6d073d4ceae55aae6f2fd98a0ac', | 
					
						
							| 
									
										
										
										
											2017-01-02 20:08:07 +08:00
										 |  |  |             'thumbnail': r're:^https?://.*\.jpg$', | 
					
						
							| 
									
										
										
										
											2016-01-01 15:29:42 +06:00
										 |  |  |             'upload_date': '20131228', | 
					
						
							| 
									
										
										
										
											2016-05-01 01:43:58 +01:00
										 |  |  |             'timestamp': 1388188800, | 
					
						
							|  |  |  |             'duration': 3710, | 
					
						
							| 
									
										
										
										
											2019-03-14 21:30:01 +01:00
										 |  |  |             'tags': list, | 
					
						
							| 
									
										
										
										
											2015-02-10 05:42:41 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2016-01-01 15:14:41 +06:00
										 |  |  |     }, { | 
					
						
							|  |  |  |         'url': 'https://media.ccc.de/v/32c3-7368-shopshifting#download', | 
					
						
							| 
									
										
										
										
											2019-04-28 23:05:36 +07:00
										 |  |  |         'only_matching': True, | 
					
						
							| 
									
										
										
										
											2016-01-01 15:14:41 +06:00
										 |  |  |     }] | 
					
						
							| 
									
										
										
										
											2015-02-10 05:42:41 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							| 
									
										
										
										
											2016-05-01 01:43:58 +01:00
										 |  |  |         display_id = self._match_id(url) | 
					
						
							|  |  |  |         webpage = self._download_webpage(url, display_id) | 
					
						
							| 
									
										
										
										
											2017-01-02 20:08:07 +08:00
										 |  |  |         event_id = self._search_regex(r"data-id='(\d+)'", webpage, 'event id') | 
					
						
							| 
									
										
										
										
											2016-05-01 01:43:58 +01:00
										 |  |  |         event_data = self._download_json('https://media.ccc.de/public/events/%s' % event_id, event_id) | 
					
						
							| 
									
										
										
										
											2015-02-10 05:42:41 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         formats = [] | 
					
						
							| 
									
										
										
										
											2016-05-01 01:43:58 +01:00
										 |  |  |         for recording in event_data.get('recordings', []): | 
					
						
							|  |  |  |             recording_url = recording.get('recording_url') | 
					
						
							|  |  |  |             if not recording_url: | 
					
						
							|  |  |  |                 continue | 
					
						
							|  |  |  |             language = recording.get('language') | 
					
						
							|  |  |  |             folder = recording.get('folder') | 
					
						
							|  |  |  |             format_id = None | 
					
						
							|  |  |  |             if language: | 
					
						
							|  |  |  |                 format_id = language | 
					
						
							|  |  |  |             if folder: | 
					
						
							|  |  |  |                 if language: | 
					
						
							|  |  |  |                     format_id += '-' + folder | 
					
						
							|  |  |  |                 else: | 
					
						
							|  |  |  |                     format_id = folder | 
					
						
							|  |  |  |             vcodec = 'h264' if 'h264' in folder else ( | 
					
						
							|  |  |  |                 'none' if folder in ('mp3', 'opus') else None | 
					
						
							| 
									
										
										
										
											2015-02-10 05:42:41 +01:00
										 |  |  |             ) | 
					
						
							|  |  |  |             formats.append({ | 
					
						
							|  |  |  |                 'format_id': format_id, | 
					
						
							| 
									
										
										
										
											2016-05-01 01:43:58 +01:00
										 |  |  |                 'url': recording_url, | 
					
						
							|  |  |  |                 'width': int_or_none(recording.get('width')), | 
					
						
							|  |  |  |                 'height': int_or_none(recording.get('height')), | 
					
						
							|  |  |  |                 'filesize': int_or_none(recording.get('size'), invscale=1024 * 1024), | 
					
						
							|  |  |  |                 'language': language, | 
					
						
							| 
									
										
										
										
											2015-02-10 05:42:41 +01:00
										 |  |  |                 'vcodec': vcodec, | 
					
						
							|  |  |  |             }) | 
					
						
							|  |  |  |         self._sort_formats(formats) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return { | 
					
						
							| 
									
										
										
										
											2016-05-01 01:43:58 +01:00
										 |  |  |             'id': event_id, | 
					
						
							|  |  |  |             'display_id': display_id, | 
					
						
							|  |  |  |             'title': event_data['title'], | 
					
						
							| 
									
										
										
										
											2019-03-14 21:30:01 +01:00
										 |  |  |             'creator': try_get(event_data, lambda x: ', '.join(x['persons'])), | 
					
						
							| 
									
										
										
										
											2016-05-01 01:43:58 +01:00
										 |  |  |             'description': event_data.get('description'), | 
					
						
							|  |  |  |             'thumbnail': event_data.get('thumb_url'), | 
					
						
							|  |  |  |             'timestamp': parse_iso8601(event_data.get('date')), | 
					
						
							|  |  |  |             'duration': int_or_none(event_data.get('length')), | 
					
						
							|  |  |  |             'tags': event_data.get('tags'), | 
					
						
							| 
									
										
										
										
											2015-02-10 05:42:41 +01:00
										 |  |  |             'formats': formats, | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-10-27 13:22:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class CCCPlaylistIE(InfoExtractor): | 
					
						
							|  |  |  |     IE_NAME = 'media.ccc.de:lists' | 
					
						
							|  |  |  |     _VALID_URL = r'https?://(?:www\.)?media\.ccc\.de/c/(?P<id>[^/?#&]+)' | 
					
						
							|  |  |  |     _TESTS = [{ | 
					
						
							|  |  |  |         'url': 'https://media.ccc.de/c/30c3', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'title': '30C3', | 
					
						
							|  |  |  |             'id': '30c3', | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         'playlist_count': 135, | 
					
						
							|  |  |  |     }] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							| 
									
										
										
										
											2019-04-28 23:05:36 +07:00
										 |  |  |         playlist_id = self._match_id(url).lower() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         conf = self._download_json( | 
					
						
							|  |  |  |             'https://media.ccc.de/public/conferences/' + playlist_id, | 
					
						
							|  |  |  |             playlist_id) | 
					
						
							| 
									
										
										
										
											2017-10-27 13:22:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-28 23:05:36 +07:00
										 |  |  |         entries = [] | 
					
						
							|  |  |  |         for e in conf['events']: | 
					
						
							|  |  |  |             event_url = url_or_none(e.get('frontend_link')) | 
					
						
							|  |  |  |             if event_url: | 
					
						
							|  |  |  |                 entries.append(self.url_result(event_url, ie=CCCIE.ie_key())) | 
					
						
							| 
									
										
										
										
											2017-10-27 13:22:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-28 23:05:36 +07:00
										 |  |  |         return self.playlist_result(entries, playlist_id, conf.get('title')) |