]>
Commit | Line | Data |
---|---|---|
375696b1 | 1 | from .common import InfoExtractor |
a9cd1691 RA |
2 | from ..utils import ( |
3 | parse_duration, | |
4 | int_or_none, | |
5 | determine_protocol, | |
6 | ) | |
375696b1 | 7 | |
8 | ||
9 | class SWRMediathekIE(InfoExtractor): | |
c7b32096 | 10 | _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})' |
375696b1 | 11 | |
12 | _TESTS = [{ | |
13 | 'url': 'http://swrmediathek.de/player.htm?show=849790d0-dab8-11e3-a953-0026b975f2e6', | |
7f739999 | 14 | 'md5': '8c5f6f0172753368547ca8413a7768ac', |
375696b1 | 15 | 'info_dict': { |
16 | 'id': '849790d0-dab8-11e3-a953-0026b975f2e6', | |
7f739999 | 17 | 'ext': 'mp4', |
375696b1 | 18 | 'title': 'SWR odysso', |
19 | 'description': 'md5:2012e31baad36162e97ce9eb3f157b8a', | |
ec85ded8 | 20 | 'thumbnail': r're:^http:.*\.jpg$', |
7f739999 S |
21 | 'duration': 2602, |
22 | 'upload_date': '20140515', | |
23 | 'uploader': 'SWR Fernsehen', | |
24 | 'uploader_id': '990030', | |
375696b1 | 25 | }, |
26 | }, { | |
27 | 'url': 'http://swrmediathek.de/player.htm?show=0e1a8510-ddf2-11e3-9be3-0026b975f2e6', | |
7f739999 | 28 | 'md5': 'b10ab854f912eecc5a6b55cd6fc1f545', |
375696b1 | 29 | 'info_dict': { |
30 | 'id': '0e1a8510-ddf2-11e3-9be3-0026b975f2e6', | |
7f739999 | 31 | 'ext': 'mp4', |
375696b1 | 32 | 'title': 'Nachtcafé - Alltagsdroge Alkohol - zwischen Sektempfang und Komasaufen', |
33 | 'description': 'md5:e0a3adc17e47db2c23aab9ebc36dbee2', | |
ec85ded8 | 34 | 'thumbnail': r're:http://.*\.jpg', |
7f739999 S |
35 | 'duration': 5305, |
36 | 'upload_date': '20140516', | |
37 | 'uploader': 'SWR Fernsehen', | |
38 | 'uploader_id': '990030', | |
375696b1 | 39 | }, |
a5eefc49 | 40 | 'skip': 'redirect to http://swrmediathek.de/index.htm?hinweis=swrlink', |
7f739999 S |
41 | }, { |
42 | 'url': 'http://swrmediathek.de/player.htm?show=bba23e10-cb93-11e3-bf7f-0026b975f2e6', | |
43 | 'md5': '4382e4ef2c9d7ce6852535fa867a0dd3', | |
44 | 'info_dict': { | |
45 | 'id': 'bba23e10-cb93-11e3-bf7f-0026b975f2e6', | |
46 | 'ext': 'mp3', | |
47 | 'title': 'Saša Stanišic: Vor dem Fest', | |
48 | 'description': 'md5:5b792387dc3fbb171eb709060654e8c9', | |
ec85ded8 | 49 | 'thumbnail': r're:http://.*\.jpg', |
7f739999 S |
50 | 'duration': 3366, |
51 | 'upload_date': '20140520', | |
52 | 'uploader': 'SWR 2', | |
53 | 'uploader_id': '284670', | |
a9cd1691 | 54 | }, |
a5eefc49 | 55 | 'skip': 'redirect to http://swrmediathek.de/index.htm?hinweis=swrlink', |
375696b1 | 56 | }] |
57 | ||
58 | def _real_extract(self, url): | |
a9cd1691 | 59 | video_id = self._match_id(url) |
375696b1 | 60 | |
7f739999 | 61 | video = self._download_json( |
a9cd1691 RA |
62 | 'http://swrmediathek.de/AjaxEntry?ekey=%s' % video_id, |
63 | video_id, 'Downloading video JSON') | |
375696b1 | 64 | |
7f739999 | 65 | attr = video['attr'] |
a9cd1691 RA |
66 | title = attr['entry_title'] |
67 | media_type = attr.get('entry_etype') | |
375696b1 | 68 | |
69 | formats = [] | |
a9cd1691 RA |
70 | for entry in video.get('sub', []): |
71 | if entry.get('name') != 'entry_media': | |
7f739999 S |
72 | continue |
73 | ||
a9cd1691 RA |
74 | entry_attr = entry.get('attr', {}) |
75 | f_url = entry_attr.get('val2') | |
76 | if not f_url: | |
77 | continue | |
78 | codec = entry_attr.get('val0') | |
79 | if codec == 'm3u8': | |
80 | formats.extend(self._extract_m3u8_formats( | |
81 | f_url, video_id, 'mp4', 'm3u8_native', | |
82 | m3u8_id='hls', fatal=False)) | |
83 | elif codec == 'f4m': | |
84 | formats.extend(self._extract_f4m_formats( | |
85 | f_url + '?hdcore=3.7.0', video_id, | |
86 | f4m_id='hds', fatal=False)) | |
87 | else: | |
88 | formats.append({ | |
89 | 'format_id': determine_protocol({'url': f_url}), | |
90 | 'url': f_url, | |
91 | 'quality': int_or_none(entry_attr.get('val1')), | |
92 | 'vcodec': codec if media_type == 'Video' else 'none', | |
93 | 'acodec': codec if media_type == 'Audio' else None, | |
7f739999 | 94 | }) |
375696b1 | 95 | self._sort_formats(formats) |
96 | ||
a9cd1691 RA |
97 | upload_date = None |
98 | entry_pdatet = attr.get('entry_pdatet') | |
99 | if entry_pdatet: | |
100 | upload_date = entry_pdatet[:-4] | |
101 | ||
375696b1 | 102 | return { |
103 | 'id': video_id, | |
a9cd1691 RA |
104 | 'title': title, |
105 | 'description': attr.get('entry_descl'), | |
106 | 'thumbnail': attr.get('entry_image_16_9'), | |
107 | 'duration': parse_duration(attr.get('entry_durat')), | |
108 | 'upload_date': upload_date, | |
109 | 'uploader': attr.get('channel_title'), | |
110 | 'uploader_id': attr.get('channel_idkey'), | |
375696b1 | 111 | 'formats': formats, |
d6fdc386 | 112 | } |