]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/mdr.py
2100583df46ab7955846f8e3b08467d13ed3440e
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',
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': 1450950000,
53 'upload_date': '20151224',
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,
64 'url': 'http://www.mdr.de/mediathek/mdr-videos/a/video-1334.html',
65 'only_matching': True,
68 def _real_extract(self
, url
):
69 video_id
= self
._match
_id
(url
)
71 webpage
= self
._download
_webpage
(url
, video_id
)
73 data_url
= self
._search
_regex
(
74 r
'(?:dataURL|playerXml(?:["\'])?
)\s
*:\s
*(["\'])(?P<url>.+/(?:video|audio)-?[0-9]+-avCustom\.xml)\1',
75 webpage, 'data url', group='url').replace('\/', '/')
77 doc = self._download_xml(
78 compat_urlparse.urljoin(url, data_url), video_id)
80 title = xpath_text(doc, ['./title', './broadcast/broadcastName'], 'title', fatal=True)
84 for asset in doc.findall('./assets/asset'):
86 'progressiveDownload',
87 'dynamicHttpStreamingRedirector',
88 'adaptiveHttpStreamingRedirector'):
89 url_el = asset.find('./%sUrl' % source)
93 video_url = url_el.text
94 if video_url in processed_urls:
97 processed_urls.append(video_url)
99 vbr = int_or_none(xpath_text(asset, './bitrateVideo', 'vbr'), 1000)
100 abr = int_or_none(xpath_text(asset, './bitrateAudio', 'abr'), 1000)
102 ext = determine_ext(url_el.text)
104 url_formats = self._extract_m3u8_formats(
105 video_url, video_id, 'mp4', entry_protocol='m3u8_native',
106 preference=0, m3u8_id='HLS', fatal=False)
108 url_formats = self._extract_f4m_formats(
109 video_url + '?hdcore=3.7.0&plugin=aasp-3.7.0.39.44', video_id,
110 preference=0, f4m_id='HDS', fatal=False)
112 media_type = xpath_text(asset, './mediaType', 'media type', default='MP4')
113 vbr = int_or_none(xpath_text(asset, './bitrateVideo', 'vbr'), 1000)
114 abr = int_or_none(xpath_text(asset, './bitrateAudio', 'abr'), 1000)
115 filesize = int_or_none(xpath_text(asset, './fileSize', 'file size'))
119 'format_id': '%s-%d' % (media_type, vbr or abr),
120 'filesize': filesize,
126 width = int_or_none(xpath_text(asset, './frameWidth', 'width'))
127 height = int_or_none(xpath_text(asset, './frameHeight', 'height'))
140 for f in url_formats:
141 abr = f.get('tbr') or abr
149 formats.extend(url_formats)
151 self._sort_formats(formats)
153 description = xpath_text(doc, './broadcast/broadcastDescription', 'description')
154 timestamp = parse_iso8601(
157 './broadcast/broadcastDate',
158 './broadcast/broadcastStartDate',
159 './broadcast/broadcastEndDate'],
160 'timestamp', default=None))
161 duration = parse_duration(xpath_text(doc, './duration', 'duration'))
162 uploader = xpath_text(doc, './rights', 'uploader')
167 'description': description,
168 'timestamp': timestamp,
169 'duration': duration,
170 'uploader': uploader,