1 from .common
import InfoExtractor
11 class BRIE(InfoExtractor
):
13 IE_DESC
= 'Bayerischer Rundfunk'
14 _VALID_URL
= r
'(?P<base_url>https?://(?:www\.)?br(?:-klassik)?\.de)/(?:[a-z0-9\-_]+/)+(?P<id>[a-z0-9\-_]+)\.html'
18 'url': 'http://www.br.de/mediathek/video/sendungen/abendschau/betriebliche-altersvorsorge-104.html',
19 'md5': '83a0477cf0b8451027eb566d88b51106',
21 'id': '48f656ef-287e-486f-be86-459122db22cc',
23 'title': 'Die böse Überraschung',
24 'description': 'md5:ce9ac81b466ce775b8018f6801b48ac9',
26 'uploader': 'Reinhard Weber',
27 'upload_date': '20150422',
29 'skip': '404 not found',
32 'url': 'http://www.br.de/nachrichten/oberbayern/inhalt/muenchner-polizeipraesident-schreiber-gestorben-100.html',
33 'md5': 'af3a3a4aa43ff0ce6a89504c67f427ef',
35 'id': 'a4b83e34-123d-4b81-9f4e-c0d3121a4e05',
37 'title': 'Manfred Schreiber ist tot',
38 'description': 'md5:b454d867f2a9fc524ebe88c3f5092d97',
41 'skip': '404 not found',
44 'url': 'https://www.br-klassik.de/audio/peeping-tom-premierenkritik-dance-festival-muenchen-100.html',
45 'md5': '8b5b27c0b090f3b35eac4ab3f7a73d3d',
47 'id': '74c603c9-26d3-48bb-b85b-079aeed66e0b',
49 'title': 'Kurzweilig und sehr bewegend',
50 'description': 'md5:0351996e3283d64adeb38ede91fac54e',
53 'skip': '404 not found',
56 'url': 'http://www.br.de/radio/bayern1/service/team/videos/team-video-erdelt100.html',
57 'md5': 'dbab0aef2e047060ea7a21fc1ce1078a',
59 'id': '6ba73750-d405-45d3-861d-1ce8c524e059',
61 'title': 'Umweltbewusster Häuslebauer',
62 'description': 'md5:d52dae9792d00226348c1dbb13c9bae2',
67 'url': 'http://www.br.de/fernsehen/br-alpha/sendungen/kant-fuer-anfaenger/kritik-der-reinen-vernunft/kant-kritik-01-metaphysik100.html',
68 'md5': '23bca295f1650d698f94fc570977dae3',
70 'id': 'd982c9ce-8648-4753-b358-98abb8aec43d',
72 'title': 'Folge 1 - Metaphysik',
73 'description': 'md5:bb659990e9e59905c3d41e369db1fbe3',
75 'uploader': 'Eva Maria Steimle',
76 'upload_date': '20170208',
81 def _real_extract(self
, url
):
82 base_url
, display_id
= self
._match
_valid
_url
(url
).groups()
83 page
= self
._download
_webpage
(url
, display_id
)
84 xml_url
= self
._search
_regex
(
85 r
"return BRavFramework\.register\(BRavFramework\('avPlayer_(?:[a-f0-9-]{36})'\)\.setup\({dataURL:'(/(?:[a-z0-9\-]+/)+[a-z0-9/~_.-]+)'}\)\);", page
, 'XMLURL')
86 xml
= self
._download
_xml
(base_url
+ xml_url
, display_id
)
90 for xml_media
in xml
.findall('video') + xml
.findall('audio'):
91 media_id
= xml_media
.get('externalId')
94 'title': xpath_text(xml_media
, 'title', 'title', True),
95 'duration': parse_duration(xpath_text(xml_media
, 'duration')),
96 'formats': self
._extract
_formats
(xpath_element(
97 xml_media
, 'assets'), media_id
),
98 'thumbnails': self
._extract
_thumbnails
(xpath_element(
99 xml_media
, 'teaserImage/variants'), base_url
),
100 'description': xpath_text(xml_media
, 'desc'),
101 'webpage_url': xpath_text(xml_media
, 'permalink'),
102 'uploader': xpath_text(xml_media
, 'author'),
104 broadcast_date
= xpath_text(xml_media
, 'broadcastDate')
106 media
['upload_date'] = ''.join(reversed(broadcast_date
.split('.')))
111 'found multiple medias; please '
112 'report this with the video URL to http://yt-dl.org/bug')
114 raise ExtractorError('No media entries found')
117 def _extract_formats(self
, assets
, media_id
):
119 for asset
in assets
.findall('asset'):
120 format_url
= xpath_text(asset
, ['downloadUrl', 'url'])
121 asset_type
= asset
.get('type')
122 if asset_type
.startswith('HDS'):
123 formats
.extend(self
._extract
_f
4m
_formats
(
124 format_url
+ '?hdcore=3.2.0', media_id
, f4m_id
='hds', fatal
=False))
125 elif asset_type
.startswith('HLS'):
126 formats
.extend(self
._extract
_m
3u8_formats
(
127 format_url
, media_id
, 'mp4', 'm3u8_native', m3u8_id
='hds', fatal
=False))
130 'ext': xpath_text(asset
, 'mediaType'),
131 'width': int_or_none(xpath_text(asset
, 'frameWidth')),
132 'height': int_or_none(xpath_text(asset
, 'frameHeight')),
133 'tbr': int_or_none(xpath_text(asset
, 'bitrateVideo')),
134 'abr': int_or_none(xpath_text(asset
, 'bitrateAudio')),
135 'vcodec': xpath_text(asset
, 'codecVideo'),
136 'acodec': xpath_text(asset
, 'codecAudio'),
137 'container': xpath_text(asset
, 'mediaType'),
138 'filesize': int_or_none(xpath_text(asset
, 'size')),
140 format_url
= self
._proto
_relative
_url
(format_url
)
142 http_format_info
= format_info
.copy()
143 http_format_info
.update({
145 'format_id': f
'http-{asset_type}',
147 formats
.append(http_format_info
)
148 server_prefix
= xpath_text(asset
, 'serverPrefix')
150 rtmp_format_info
= format_info
.copy()
151 rtmp_format_info
.update({
152 'url': server_prefix
,
153 'play_path': xpath_text(asset
, 'fileName'),
154 'format_id': f
'rtmp-{asset_type}',
156 formats
.append(rtmp_format_info
)
159 def _extract_thumbnails(self
, variants
, base_url
):
161 'url': base_url
+ xpath_text(variant
, 'url'),
162 'width': int_or_none(xpath_text(variant
, 'width')),
163 'height': int_or_none(xpath_text(variant
, 'height')),
164 } for variant
in variants
.findall('variant') if xpath_text(variant
, 'url')]
165 thumbnails
.sort(key
=lambda x
: x
['width'] * x
['height'], reverse
=True)