]>
Commit | Line | Data |
---|---|---|
375696b1 | 1 | # -*- coding: utf-8 -*- |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import re | |
5 | ||
6 | from .common import InfoExtractor | |
7f739999 | 7 | from ..utils import parse_duration |
375696b1 | 8 | |
9 | ||
10 | class SWRMediathekIE(InfoExtractor): | |
c7b32096 | 11 | _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 | 12 | |
13 | _TESTS = [{ | |
14 | 'url': 'http://swrmediathek.de/player.htm?show=849790d0-dab8-11e3-a953-0026b975f2e6', | |
7f739999 | 15 | 'md5': '8c5f6f0172753368547ca8413a7768ac', |
375696b1 | 16 | 'info_dict': { |
17 | 'id': '849790d0-dab8-11e3-a953-0026b975f2e6', | |
7f739999 | 18 | 'ext': 'mp4', |
375696b1 | 19 | 'title': 'SWR odysso', |
20 | 'description': 'md5:2012e31baad36162e97ce9eb3f157b8a', | |
21 | 'thumbnail': 're:^http:.*\.jpg$', | |
7f739999 S |
22 | 'duration': 2602, |
23 | 'upload_date': '20140515', | |
24 | 'uploader': 'SWR Fernsehen', | |
25 | 'uploader_id': '990030', | |
375696b1 | 26 | }, |
27 | }, { | |
28 | 'url': 'http://swrmediathek.de/player.htm?show=0e1a8510-ddf2-11e3-9be3-0026b975f2e6', | |
7f739999 | 29 | 'md5': 'b10ab854f912eecc5a6b55cd6fc1f545', |
375696b1 | 30 | 'info_dict': { |
31 | 'id': '0e1a8510-ddf2-11e3-9be3-0026b975f2e6', | |
7f739999 | 32 | 'ext': 'mp4', |
375696b1 | 33 | 'title': 'Nachtcafé - Alltagsdroge Alkohol - zwischen Sektempfang und Komasaufen', |
34 | 'description': 'md5:e0a3adc17e47db2c23aab9ebc36dbee2', | |
35 | 'thumbnail': 're:http://.*\.jpg', | |
7f739999 S |
36 | 'duration': 5305, |
37 | 'upload_date': '20140516', | |
38 | 'uploader': 'SWR Fernsehen', | |
39 | 'uploader_id': '990030', | |
375696b1 | 40 | }, |
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', | |
49 | 'thumbnail': 're:http://.*\.jpg', | |
50 | 'duration': 3366, | |
51 | 'upload_date': '20140520', | |
52 | 'uploader': 'SWR 2', | |
53 | 'uploader_id': '284670', | |
54 | } | |
375696b1 | 55 | }] |
56 | ||
57 | def _real_extract(self, url): | |
58 | mobj = re.match(self._VALID_URL, url) | |
7f739999 | 59 | video_id = mobj.group('id') |
375696b1 | 60 | |
7f739999 S |
61 | video = self._download_json( |
62 | 'http://swrmediathek.de/AjaxEntry?ekey=%s' % video_id, video_id, 'Downloading video JSON') | |
375696b1 | 63 | |
7f739999 S |
64 | attr = video['attr'] |
65 | media_type = attr['entry_etype'] | |
375696b1 | 66 | |
67 | formats = [] | |
7f739999 S |
68 | for entry in video['sub']: |
69 | if entry['name'] != 'entry_media': | |
70 | continue | |
71 | ||
72 | entry_attr = entry['attr'] | |
73 | codec = entry_attr['val0'] | |
74 | quality = int(entry_attr['val1']) | |
375696b1 | 75 | |
7f739999 S |
76 | fmt = { |
77 | 'url': entry_attr['val2'], | |
78 | 'quality': quality, | |
79 | } | |
80 | ||
81 | if media_type == 'Video': | |
82 | fmt.update({ | |
83 | 'format_note': ['144p', '288p', '544p'][quality-1], | |
84 | 'vcodec': codec, | |
85 | }) | |
86 | elif media_type == 'Audio': | |
87 | fmt.update({ | |
88 | 'acodec': codec, | |
89 | }) | |
90 | formats.append(fmt) | |
375696b1 | 91 | |
92 | self._sort_formats(formats) | |
93 | ||
94 | return { | |
95 | 'id': video_id, | |
7f739999 S |
96 | 'title': attr['entry_title'], |
97 | 'description': attr['entry_descl'], | |
98 | 'thumbnail': attr['entry_image_16_9'], | |
99 | 'duration': parse_duration(attr['entry_durat']), | |
100 | 'upload_date': attr['entry_pdatet'][:-4], | |
101 | 'uploader': attr['channel_title'], | |
102 | 'uploader_id': attr['channel_idkey'], | |
375696b1 | 103 | 'formats': formats, |
7f739999 | 104 | } |