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)
101 ext = determine_ext(url_el.text)
103 url_formats = self._extract_m3u8_formats(
104 video_url, video_id, 'mp4
', entry_protocol='m3u8_native
',
105 preference=0, m3u8_id='HLS
', fatal=False)
107 url_formats = self._extract_f4m_formats(
108 video_url + '?hdcore
=3.7.0&plugin
=aasp
-3.7.0.39.44', video_id,
109 preference=0, f4m_id='HDS
', fatal=False)
111 media_type = xpath_text(asset, './mediaType
', 'media
type', default='MP4
')
112 vbr = int_or_none(xpath_text(asset, './bitrateVideo
', 'vbr
'), 1000)
113 abr = int_or_none(xpath_text(asset, './bitrateAudio
', 'abr
'), 1000)
114 filesize = int_or_none(xpath_text(asset, './fileSize
', 'file size
'))
118 'format_id
': '%s-%d' % (media_type, vbr or abr),
119 'filesize
': filesize,
125 width = int_or_none(xpath_text(asset, './frameWidth
', 'width
'))
126 height = int_or_none(xpath_text(asset, './frameHeight
', 'height
'))
133 url_formats.append(f)
136 for f in url_formats:
137 abr = f.get('tbr
') or abr
146 formats.extend(url_formats)
147 self._sort_formats(formats)
149 description = xpath_text(doc, './broadcast
/broadcastDescription
', 'description
')
150 timestamp = parse_iso8601(
153 './broadcast
/broadcastDate
',
154 './broadcast
/broadcastStartDate
',
155 './broadcast
/broadcastEndDate
'],
156 'timestamp
', default=None))
157 duration = parse_duration(xpath_text(doc, './duration
', 'duration
'))
158 uploader = xpath_text(doc, './rights
', 'uploader
')
163 'description
': description,
164 'timestamp
': timestamp,
165 'duration
': duration,
166 'uploader
': uploader,