2024-06-11 19:09:58 -04:00
|
|
|
import urllib.parse
|
|
|
|
|
2013-12-10 12:40:50 -05:00
|
|
|
from .common import InfoExtractor
|
2015-10-31 12:17:09 -04:00
|
|
|
from ..utils import (
|
|
|
|
determine_ext,
|
|
|
|
int_or_none,
|
2021-11-05 21:05:24 -04:00
|
|
|
join_nonempty,
|
2015-10-31 12:17:09 -04:00
|
|
|
parse_duration,
|
|
|
|
parse_iso8601,
|
2021-01-01 07:26:37 -05:00
|
|
|
url_or_none,
|
2015-10-31 12:17:09 -04:00
|
|
|
xpath_text,
|
|
|
|
)
|
2013-12-10 12:40:50 -05:00
|
|
|
|
2013-12-15 23:44:34 -05:00
|
|
|
|
2013-12-10 12:40:50 -05:00
|
|
|
class MDRIE(InfoExtractor):
|
2024-09-01 19:28:51 -04:00
|
|
|
IE_DESC = 'MDR.DE'
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?mdr\.de/(?:.*)/[a-z-]+-?(?P<id>\d+)(?:_.+?)?\.html'
|
2014-11-23 14:41:03 -05:00
|
|
|
|
2021-01-01 07:26:37 -05:00
|
|
|
_GEO_COUNTRIES = ['DE']
|
|
|
|
|
2015-10-31 12:17:09 -04:00
|
|
|
_TESTS = [{
|
2016-01-10 10:17:47 -05:00
|
|
|
# MDR regularly deletes its videos
|
2014-04-21 00:25:21 -04:00
|
|
|
'url': 'http://www.mdr.de/fakt/video189002.html',
|
|
|
|
'only_matching': True,
|
2015-10-31 13:00:36 -04:00
|
|
|
}, {
|
2015-10-31 12:24:21 -04:00
|
|
|
# audio
|
|
|
|
'url': 'http://www.mdr.de/kultur/audio1312272_zc-15948bad_zs-86171fdd.html',
|
|
|
|
'md5': '64c4ee50f0a791deb9479cd7bbe9d2fa',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '1312272',
|
|
|
|
'ext': 'mp3',
|
|
|
|
'title': 'Feuilleton vom 30. Oktober 2015',
|
|
|
|
'duration': 250,
|
|
|
|
'uploader': 'MITTELDEUTSCHER RUNDFUNK',
|
|
|
|
},
|
2017-02-26 04:24:54 -05:00
|
|
|
'skip': '404 not found',
|
|
|
|
}, {
|
|
|
|
# audio with alternative playerURL pattern
|
|
|
|
'url': 'http://www.mdr.de/kultur/videos-und-audios/audio-radio/operation-mindfuck-robert-wilson100.html',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '100',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Feature: Operation Mindfuck - Robert Anton Wilson',
|
|
|
|
'duration': 3239,
|
|
|
|
'uploader': 'MITTELDEUTSCHER RUNDFUNK',
|
|
|
|
},
|
2024-09-01 19:28:51 -04:00
|
|
|
'skip': '404 not found',
|
2016-02-29 14:24:26 -05:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.mdr.de/mediathek/mdr-videos/a/video-1334.html',
|
|
|
|
'only_matching': True,
|
2015-10-31 12:17:09 -04:00
|
|
|
}]
|
2013-12-10 12:40:50 -05:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2015-10-31 12:17:09 -04:00
|
|
|
video_id = self._match_id(url)
|
|
|
|
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
2013-12-10 12:40:50 -05:00
|
|
|
|
2015-10-31 12:17:09 -04:00
|
|
|
data_url = self._search_regex(
|
2017-02-26 04:24:54 -05:00
|
|
|
r'(?:dataURL|playerXml(?:["\'])?)\s*:\s*(["\'])(?P<url>.+?-avCustom\.xml)\1',
|
2017-01-02 07:08:07 -05:00
|
|
|
webpage, 'data url', group='url').replace(r'\/', '/')
|
2013-12-10 12:40:50 -05:00
|
|
|
|
2015-10-31 12:17:09 -04:00
|
|
|
doc = self._download_xml(
|
2024-06-11 19:09:58 -04:00
|
|
|
urllib.parse.urljoin(url, data_url), video_id)
|
2015-10-31 12:17:09 -04:00
|
|
|
|
2015-10-31 12:45:45 -04:00
|
|
|
title = xpath_text(doc, ['./title', './broadcast/broadcastName'], 'title', fatal=True)
|
2013-12-15 23:44:34 -05:00
|
|
|
|
2021-01-01 07:26:37 -05:00
|
|
|
type_ = xpath_text(doc, './type', default=None)
|
|
|
|
|
2013-12-15 23:44:34 -05:00
|
|
|
formats = []
|
2015-10-31 12:17:09 -04:00
|
|
|
processed_urls = []
|
|
|
|
for asset in doc.findall('./assets/asset'):
|
|
|
|
for source in (
|
2021-01-01 07:26:37 -05:00
|
|
|
'download',
|
2015-10-31 12:17:09 -04:00
|
|
|
'progressiveDownload',
|
|
|
|
'dynamicHttpStreamingRedirector',
|
|
|
|
'adaptiveHttpStreamingRedirector'):
|
2024-06-11 19:09:58 -04:00
|
|
|
url_el = asset.find(f'./{source}Url')
|
2015-10-31 12:17:09 -04:00
|
|
|
if url_el is None:
|
|
|
|
continue
|
|
|
|
|
2021-01-01 07:26:37 -05:00
|
|
|
video_url = url_or_none(url_el.text)
|
|
|
|
if not video_url or video_url in processed_urls:
|
2015-10-31 12:17:09 -04:00
|
|
|
continue
|
|
|
|
|
|
|
|
processed_urls.append(video_url)
|
|
|
|
|
2021-01-01 07:26:37 -05:00
|
|
|
ext = determine_ext(video_url)
|
2015-10-31 12:17:09 -04:00
|
|
|
if ext == 'm3u8':
|
2021-01-01 07:26:37 -05:00
|
|
|
formats.extend(self._extract_m3u8_formats(
|
2015-10-31 12:17:09 -04:00
|
|
|
video_url, video_id, 'mp4', entry_protocol='m3u8_native',
|
2021-02-18 17:03:16 -05:00
|
|
|
quality=1, m3u8_id='HLS', fatal=False))
|
2015-10-31 12:17:09 -04:00
|
|
|
elif ext == 'f4m':
|
2021-01-01 07:26:37 -05:00
|
|
|
formats.extend(self._extract_f4m_formats(
|
2015-10-31 12:17:09 -04:00
|
|
|
video_url + '?hdcore=3.7.0&plugin=aasp-3.7.0.39.44', video_id,
|
2021-02-18 17:03:16 -05:00
|
|
|
quality=1, f4m_id='HDS', fatal=False))
|
2015-10-31 12:17:09 -04:00
|
|
|
else:
|
|
|
|
media_type = xpath_text(asset, './mediaType', 'media type', default='MP4')
|
|
|
|
vbr = int_or_none(xpath_text(asset, './bitrateVideo', 'vbr'), 1000)
|
|
|
|
abr = int_or_none(xpath_text(asset, './bitrateAudio', 'abr'), 1000)
|
|
|
|
filesize = int_or_none(xpath_text(asset, './fileSize', 'file size'))
|
|
|
|
|
|
|
|
f = {
|
|
|
|
'url': video_url,
|
2021-11-05 21:05:24 -04:00
|
|
|
'format_id': join_nonempty(media_type, vbr or abr),
|
2015-10-31 12:17:09 -04:00
|
|
|
'filesize': filesize,
|
|
|
|
'abr': abr,
|
2021-01-01 07:26:37 -05:00
|
|
|
'vbr': vbr,
|
2015-10-31 12:17:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if vbr:
|
|
|
|
f.update({
|
2021-01-01 07:26:37 -05:00
|
|
|
'width': int_or_none(xpath_text(asset, './frameWidth', 'width')),
|
|
|
|
'height': int_or_none(xpath_text(asset, './frameHeight', 'height')),
|
2015-10-31 12:17:09 -04:00
|
|
|
})
|
|
|
|
|
2021-01-01 07:26:37 -05:00
|
|
|
if type_ == 'audio':
|
|
|
|
f['vcodec'] = 'none'
|
2015-10-31 12:17:09 -04:00
|
|
|
|
2021-01-01 07:26:37 -05:00
|
|
|
formats.append(f)
|
2015-10-31 14:01:08 -04:00
|
|
|
|
2015-10-31 12:17:09 -04:00
|
|
|
description = xpath_text(doc, './broadcast/broadcastDescription', 'description')
|
|
|
|
timestamp = parse_iso8601(
|
2015-10-31 12:45:45 -04:00
|
|
|
xpath_text(
|
|
|
|
doc, [
|
|
|
|
'./broadcast/broadcastDate',
|
|
|
|
'./broadcast/broadcastStartDate',
|
|
|
|
'./broadcast/broadcastEndDate'],
|
|
|
|
'timestamp', default=None))
|
2015-10-31 12:17:09 -04:00
|
|
|
duration = parse_duration(xpath_text(doc, './duration', 'duration'))
|
|
|
|
uploader = xpath_text(doc, './rights', 'uploader')
|
|
|
|
|
2013-12-15 23:44:34 -05:00
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
2015-10-31 12:17:09 -04:00
|
|
|
'description': description,
|
|
|
|
'timestamp': timestamp,
|
|
|
|
'duration': duration,
|
|
|
|
'uploader': uploader,
|
2013-12-15 23:44:34 -05:00
|
|
|
'formats': formats,
|
|
|
|
}
|