2 from __future__ import unicode_literals
4 from .common import InfoExtractor
12 class SWRMediathekIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:www\.)?swrmediathek\.de/(?:content/)?player\.htm\?show=(?P<id>[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})'
16 'url': 'http://swrmediathek.de/player.htm?show=849790d0-dab8-11e3-a953-0026b975f2e6',
17 'md5': '8c5f6f0172753368547ca8413a7768ac',
19 'id': '849790d0-dab8-11e3-a953-0026b975f2e6',
21 'title': 'SWR odysso',
22 'description': 'md5:2012e31baad36162e97ce9eb3f157b8a',
23 'thumbnail': r're:^http:.*\.jpg$',
25 'upload_date': '20140515',
26 'uploader': 'SWR Fernsehen',
27 'uploader_id': '990030',
30 'url': 'http://swrmediathek.de/player.htm?show=0e1a8510-ddf2-11e3-9be3-0026b975f2e6',
31 'md5': 'b10ab854f912eecc5a6b55cd6fc1f545',
33 'id': '0e1a8510-ddf2-11e3-9be3-0026b975f2e6',
35 'title': 'Nachtcafé - Alltagsdroge Alkohol - zwischen Sektempfang und Komasaufen',
36 'description': 'md5:e0a3adc17e47db2c23aab9ebc36dbee2',
37 'thumbnail': r're:http://.*\.jpg',
39 'upload_date': '20140516',
40 'uploader': 'SWR Fernsehen',
41 'uploader_id': '990030',
43 'skip': 'redirect to http://swrmediathek.de/index.htm?hinweis=swrlink',
45 'url': 'http://swrmediathek.de/player.htm?show=bba23e10-cb93-11e3-bf7f-0026b975f2e6',
46 'md5': '4382e4ef2c9d7ce6852535fa867a0dd3',
48 'id': 'bba23e10-cb93-11e3-bf7f-0026b975f2e6',
50 'title': 'Saša Stanišic: Vor dem Fest',
51 'description': 'md5:5b792387dc3fbb171eb709060654e8c9',
52 'thumbnail': r're:http://.*\.jpg',
54 'upload_date': '20140520',
56 'uploader_id': '284670',
58 'skip': 'redirect to http://swrmediathek.de/index.htm?hinweis=swrlink',
61 def _real_extract(self, url):
62 video_id = self._match_id(url)
64 video = self._download_json(
65 'http://swrmediathek.de/AjaxEntry?ekey=%s' % video_id,
66 video_id, 'Downloading video JSON')
69 title = attr['entry_title']
70 media_type = attr.get('entry_etype')
73 for entry in video.get('sub', []):
74 if entry.get('name') != 'entry_media':
77 entry_attr = entry.get('attr', {})
78 f_url = entry_attr.get('val2')
81 codec = entry_attr.get('val0')
83 formats.extend(self._extract_m3u8_formats(
84 f_url, video_id, 'mp4', 'm3u8_native',
85 m3u8_id='hls', fatal=False))
87 formats.extend(self._extract_f4m_formats(
88 f_url + '?hdcore=3.7.0', video_id,
89 f4m_id='hds', fatal=False))
92 'format_id': determine_protocol({'url': f_url}),
94 'quality': int_or_none(entry_attr.get('val1')),
95 'vcodec': codec if media_type == 'Video' else 'none',
96 'acodec': codec if media_type == 'Audio' else None,
98 self._sort_formats(formats)
101 entry_pdatet = attr.get('entry_pdatet')
103 upload_date = entry_pdatet[:-4]
108 'description': attr.get('entry_descl'),
109 'thumbnail': attr.get('entry_image_16_9'),
110 'duration': parse_duration(attr.get('entry_durat')),
111 'upload_date': upload_date,
112 'uploader': attr.get('channel_title'),
113 'uploader_id': attr.get('channel_idkey'),