2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..compat
import compat_urlparse
15 class MDRIE(InfoExtractor
):
16 IE_DESC
= 'MDR.DE and KiKA'
17 _VALID_URL
= r
'https?://(?:www\.)?(?:mdr|kika)\.de/(?:.*)/[a-z]+(?P<id>\d+)(?:_.+?)?\.html'
20 # MDR regularily deletes its videos
21 'url': 'http://www.mdr.de/fakt/video189002.html',
22 'only_matching': True,
25 'url': 'http://www.mdr.de/kultur/audio1312272_zc-15948bad_zs-86171fdd.html',
26 'md5': '64c4ee50f0a791deb9479cd7bbe9d2fa',
30 'title': 'Feuilleton vom 30. Oktober 2015',
32 'uploader': 'MITTELDEUTSCHER RUNDFUNK',
35 'url': 'http://www.kika.de/baumhaus/videos/video19636.html',
36 'md5': '4930515e36b06c111213e80d1e4aad0e',
40 'title': 'Baumhaus vom 30. Oktober 2015',
45 'url': 'http://www.kika.de/sendungen/einzelsendungen/weihnachtsprogramm/videos/video8182.html',
46 'md5': '5fe9c4dd7d71e3b238f04b8fdd588357',
50 'title': 'Beutolomäus und der geheime Weihnachtswunsch',
51 'description': 'md5:b69d32d7b2c55cbe86945ab309d39bbd',
52 'timestamp': 1419047100,
53 'upload_date': '20141220',
58 'url': 'http://www.kika.de/baumhaus/sendungen/video19636_zc-fea7f8a0_zs-4bf89c60.html',
59 'only_matching': True,
61 'url': 'http://www.kika.de/sendungen/einzelsendungen/weihnachtsprogramm/einzelsendung2534.html',
62 'only_matching': True,
65 def _real_extract(self
, url
):
66 video_id
= self
._match
_id
(url
)
68 webpage
= self
._download
_webpage
(url
, video_id
)
70 data_url
= self
._search
_regex
(
71 r
'dataURL\s*:\s*(["\'])(?P
<url
>/.+/(?
:video|audio
)[0-9]+-avCustom\
.xml
)\
1',
72 webpage, 'data url
', group='url
')
74 doc = self._download_xml(
75 compat_urlparse.urljoin(url, data_url), video_id)
77 title = xpath_text(doc, ['./title
', './broadcast
/broadcastName
'], 'title
', fatal=True)
81 for asset in doc.findall('./assets
/asset
'):
83 'progressiveDownload
',
84 'dynamicHttpStreamingRedirector
',
85 'adaptiveHttpStreamingRedirector
'):
86 url_el = asset.find('./%sUrl
' % source)
90 video_url = url_el.text
91 if video_url in processed_urls:
94 processed_urls.append(video_url)
96 vbr = int_or_none(xpath_text(asset, './bitrateVideo
', 'vbr
'), 1000)
97 abr = int_or_none(xpath_text(asset, './bitrateAudio
', 'abr
'), 1000)
99 ext = determine_ext(url_el.text)
101 url_formats = self._extract_m3u8_formats(
102 video_url, video_id, 'mp4
', entry_protocol='m3u8_native
',
103 preference=0, m3u8_id='HLS
', fatal=False)
105 url_formats = self._extract_f4m_formats(
106 video_url + '?hdcore
=3.7.0&plugin
=aasp
-3.7.0.39.44', video_id,
107 preference=0, f4m_id='HDS
', fatal=False)
109 media_type = xpath_text(asset, './mediaType
', 'media
type', default='MP4
')
110 vbr = int_or_none(xpath_text(asset, './bitrateVideo
', 'vbr
'), 1000)
111 abr = int_or_none(xpath_text(asset, './bitrateAudio
', 'abr
'), 1000)
112 filesize = int_or_none(xpath_text(asset, './fileSize
', 'file size
'))
116 'format_id
': '%s-%d' % (media_type, vbr or abr),
117 'filesize
': filesize,
123 width = int_or_none(xpath_text(asset, './frameWidth
', 'width
'))
124 height = int_or_none(xpath_text(asset, './frameHeight
', 'height
'))
137 for f in url_formats:
138 abr = f.get('tbr
') or abr
146 formats.extend(url_formats)
148 self._sort_formats(formats)
150 description = xpath_text(doc, './broadcast
/broadcastDescription
', 'description
')
151 timestamp = parse_iso8601(
154 './broadcast
/broadcastDate
',
155 './broadcast
/broadcastStartDate
',
156 './broadcast
/broadcastEndDate
'],
157 'timestamp
', default=None))
158 duration = parse_duration(xpath_text(doc, './duration
', 'duration
'))
159 uploader = xpath_text(doc, './rights
', 'uploader
')
164 'description
': description,
165 'timestamp
': timestamp,
166 'duration
': duration,
167 'uploader
': uploader,