]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/mdr.py
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 regularly 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',
34 'skip': '404 not found',
36 'url': 'http://www.kika.de/baumhaus/videos/video19636.html',
37 'md5': '4930515e36b06c111213e80d1e4aad0e',
41 'title': 'Baumhaus vom 30. Oktober 2015',
45 'skip': '404 not found',
47 'url': 'http://www.kika.de/sendungen/einzelsendungen/weihnachtsprogramm/videos/video8182.html',
48 'md5': '5fe9c4dd7d71e3b238f04b8fdd588357',
52 'title': 'Beutolomäus und der geheime Weihnachtswunsch',
53 'description': 'md5:b69d32d7b2c55cbe86945ab309d39bbd',
54 'timestamp': 1482541200,
55 'upload_date': '20161224',
60 # audio with alternative playerURL pattern
61 'url': 'http://www.mdr.de/kultur/videos-und-audios/audio-radio/operation-mindfuck-robert-wilson100.html',
65 'title': 'Feature: Operation Mindfuck - Robert Anton Wilson',
67 'uploader': 'MITTELDEUTSCHER RUNDFUNK',
70 'url': 'http://www.kika.de/baumhaus/sendungen/video19636_zc-fea7f8a0_zs-4bf89c60.html',
71 'only_matching': True,
73 'url': 'http://www.kika.de/sendungen/einzelsendungen/weihnachtsprogramm/einzelsendung2534.html',
74 'only_matching': True,
76 'url': 'http://www.mdr.de/mediathek/mdr-videos/a/video-1334.html',
77 'only_matching': True,
80 def _real_extract(self
, url
):
81 video_id
= self
._match
_id
(url
)
83 webpage
= self
._download
_webpage
(url
, video_id
)
85 data_url
= self
._search
_regex
(
86 r
'(?:dataURL|playerXml(?:["\'])?
)\s
*:\s
*(["\'])(?P<url>.+?-avCustom\.xml)\1',
87 webpage, 'data url', group='url').replace(r'\/', '/')
89 doc = self._download_xml(
90 compat_urlparse.urljoin(url, data_url), video_id)
92 title = xpath_text(doc, ['./title', './broadcast/broadcastName'], 'title', fatal=True)
96 for asset in doc.findall('./assets/asset'):
98 'progressiveDownload',
99 'dynamicHttpStreamingRedirector',
100 'adaptiveHttpStreamingRedirector'):
101 url_el = asset.find('./%sUrl' % source)
105 video_url = url_el.text
106 if video_url in processed_urls:
109 processed_urls.append(video_url)
111 vbr = int_or_none(xpath_text(asset, './bitrateVideo', 'vbr'), 1000)
112 abr = int_or_none(xpath_text(asset, './bitrateAudio', 'abr'), 1000)
114 ext = determine_ext(url_el.text)
116 url_formats = self._extract_m3u8_formats(
117 video_url, video_id, 'mp4', entry_protocol='m3u8_native',
118 preference=0, m3u8_id='HLS', fatal=False)
120 url_formats = self._extract_f4m_formats(
121 video_url + '?hdcore=3.7.0&plugin=aasp-3.7.0.39.44', video_id,
122 preference=0, f4m_id='HDS', fatal=False)
124 media_type = xpath_text(asset, './mediaType', 'media type', default='MP4')
125 vbr = int_or_none(xpath_text(asset, './bitrateVideo', 'vbr'), 1000)
126 abr = int_or_none(xpath_text(asset, './bitrateAudio', 'abr'), 1000)
127 filesize = int_or_none(xpath_text(asset, './fileSize', 'file size'))
131 'format_id': '%s-%d' % (media_type, vbr or abr),
132 'filesize': filesize,
138 width = int_or_none(xpath_text(asset, './frameWidth', 'width'))
139 height = int_or_none(xpath_text(asset, './frameHeight', 'height'))
152 for f in url_formats:
153 abr = f.get('tbr') or abr
161 formats.extend(url_formats)
163 self._sort_formats(formats)
165 description = xpath_text(doc, './broadcast/broadcastDescription', 'description')
166 timestamp = parse_iso8601(
169 './broadcast/broadcastDate',
170 './broadcast/broadcastStartDate',
171 './broadcast/broadcastEndDate'],
172 'timestamp', default=None))
173 duration = parse_duration(xpath_text(doc, './duration', 'duration'))
174 uploader = xpath_text(doc, './rights', 'uploader')
179 'description': description,
180 'timestamp': timestamp,
181 'duration': duration,
182 'uploader': uploader,