]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/br.py
3 from .common
import InfoExtractor
15 class BRIE(InfoExtractor
):
16 IE_DESC
= 'Bayerischer Rundfunk'
17 _VALID_URL
= r
'(?P<base_url>https?://(?:www\.)?br(?:-klassik)?\.de)/(?:[a-z0-9\-_]+/)+(?P<id>[a-z0-9\-_]+)\.html'
21 'url': 'http://www.br.de/mediathek/video/sendungen/abendschau/betriebliche-altersvorsorge-104.html',
22 'md5': '83a0477cf0b8451027eb566d88b51106',
24 'id': '48f656ef-287e-486f-be86-459122db22cc',
26 'title': 'Die böse Überraschung',
27 'description': 'md5:ce9ac81b466ce775b8018f6801b48ac9',
29 'uploader': 'Reinhard Weber',
30 'upload_date': '20150422',
32 'skip': '404 not found',
35 'url': 'http://www.br.de/nachrichten/oberbayern/inhalt/muenchner-polizeipraesident-schreiber-gestorben-100.html',
36 'md5': 'af3a3a4aa43ff0ce6a89504c67f427ef',
38 'id': 'a4b83e34-123d-4b81-9f4e-c0d3121a4e05',
40 'title': 'Manfred Schreiber ist tot',
41 'description': 'md5:b454d867f2a9fc524ebe88c3f5092d97',
44 'skip': '404 not found',
47 'url': 'https://www.br-klassik.de/audio/peeping-tom-premierenkritik-dance-festival-muenchen-100.html',
48 'md5': '8b5b27c0b090f3b35eac4ab3f7a73d3d',
50 'id': '74c603c9-26d3-48bb-b85b-079aeed66e0b',
52 'title': 'Kurzweilig und sehr bewegend',
53 'description': 'md5:0351996e3283d64adeb38ede91fac54e',
56 'skip': '404 not found',
59 'url': 'http://www.br.de/radio/bayern1/service/team/videos/team-video-erdelt100.html',
60 'md5': 'dbab0aef2e047060ea7a21fc1ce1078a',
62 'id': '6ba73750-d405-45d3-861d-1ce8c524e059',
64 'title': 'Umweltbewusster Häuslebauer',
65 'description': 'md5:d52dae9792d00226348c1dbb13c9bae2',
70 'url': 'http://www.br.de/fernsehen/br-alpha/sendungen/kant-fuer-anfaenger/kritik-der-reinen-vernunft/kant-kritik-01-metaphysik100.html',
71 'md5': '23bca295f1650d698f94fc570977dae3',
73 'id': 'd982c9ce-8648-4753-b358-98abb8aec43d',
75 'title': 'Folge 1 - Metaphysik',
76 'description': 'md5:bb659990e9e59905c3d41e369db1fbe3',
78 'uploader': 'Eva Maria Steimle',
79 'upload_date': '20170208',
84 def _real_extract(self
, url
):
85 base_url
, display_id
= self
._match
_valid
_url
(url
).groups()
86 page
= self
._download
_webpage
(url
, display_id
)
87 xml_url
= self
._search
_regex
(
88 r
"return BRavFramework\.register\(BRavFramework\('avPlayer_(?:[a-f0-9-]{36})'\)\.setup\({dataURL:'(/(?:[a-z0-9\-]+/)+[a-z0-9/~_.-]+)'}\)\);", page
, 'XMLURL')
89 xml
= self
._download
_xml
(base_url
+ xml_url
, display_id
)
93 for xml_media
in xml
.findall('video') + xml
.findall('audio'):
94 media_id
= xml_media
.get('externalId')
97 'title': xpath_text(xml_media
, 'title', 'title', True),
98 'duration': parse_duration(xpath_text(xml_media
, 'duration')),
99 'formats': self
._extract
_formats
(xpath_element(
100 xml_media
, 'assets'), media_id
),
101 'thumbnails': self
._extract
_thumbnails
(xpath_element(
102 xml_media
, 'teaserImage/variants'), base_url
),
103 'description': xpath_text(xml_media
, 'desc'),
104 'webpage_url': xpath_text(xml_media
, 'permalink'),
105 'uploader': xpath_text(xml_media
, 'author'),
107 broadcast_date
= xpath_text(xml_media
, 'broadcastDate')
109 media
['upload_date'] = ''.join(reversed(broadcast_date
.split('.')))
114 'found multiple medias; please '
115 'report this with the video URL to http://yt-dl.org/bug')
117 raise ExtractorError('No media entries found')
120 def _extract_formats(self
, assets
, media_id
):
122 for asset
in assets
.findall('asset'):
123 format_url
= xpath_text(asset
, ['downloadUrl', 'url'])
124 asset_type
= asset
.get('type')
125 if asset_type
.startswith('HDS'):
126 formats
.extend(self
._extract
_f
4m
_formats
(
127 format_url
+ '?hdcore=3.2.0', media_id
, f4m_id
='hds', fatal
=False))
128 elif asset_type
.startswith('HLS'):
129 formats
.extend(self
._extract
_m
3u8_formats
(
130 format_url
, media_id
, 'mp4', 'm3u8_native', m3u8_id
='hds', fatal
=False))
133 'ext': xpath_text(asset
, 'mediaType'),
134 'width': int_or_none(xpath_text(asset
, 'frameWidth')),
135 'height': int_or_none(xpath_text(asset
, 'frameHeight')),
136 'tbr': int_or_none(xpath_text(asset
, 'bitrateVideo')),
137 'abr': int_or_none(xpath_text(asset
, 'bitrateAudio')),
138 'vcodec': xpath_text(asset
, 'codecVideo'),
139 'acodec': xpath_text(asset
, 'codecAudio'),
140 'container': xpath_text(asset
, 'mediaType'),
141 'filesize': int_or_none(xpath_text(asset
, 'size')),
143 format_url
= self
._proto
_relative
_url
(format_url
)
145 http_format_info
= format_info
.copy()
146 http_format_info
.update({
148 'format_id': 'http-%s' % asset_type
,
150 formats
.append(http_format_info
)
151 server_prefix
= xpath_text(asset
, 'serverPrefix')
153 rtmp_format_info
= format_info
.copy()
154 rtmp_format_info
.update({
155 'url': server_prefix
,
156 'play_path': xpath_text(asset
, 'fileName'),
157 'format_id': 'rtmp-%s' % asset_type
,
159 formats
.append(rtmp_format_info
)
162 def _extract_thumbnails(self
, variants
, base_url
):
164 'url': base_url
+ xpath_text(variant
, 'url'),
165 'width': int_or_none(xpath_text(variant
, 'width')),
166 'height': int_or_none(xpath_text(variant
, 'height')),
167 } for variant
in variants
.findall('variant') if xpath_text(variant
, 'url')]
168 thumbnails
.sort(key
=lambda x
: x
['width'] * x
['height'], reverse
=True)
172 class BRMediathekIE(InfoExtractor
):
173 IE_DESC
= 'Bayerischer Rundfunk Mediathek'
174 _VALID_URL
= r
'https?://(?:www\.)?br\.de/mediathek//?video/(?:[^/?&#]+?-)?(?P<id>av:[0-9a-f]{24})'
177 'url': 'https://www.br.de/mediathek/video/gesundheit-die-sendung-vom-28112017-av:5a1e6a6e8fce6d001871cc8e',
178 'md5': 'fdc3d485835966d1622587d08ba632ec',
180 'id': 'av:5a1e6a6e8fce6d001871cc8e',
182 'title': 'Die Sendung vom 28.11.2017',
183 'description': 'md5:6000cdca5912ab2277e5b7339f201ccc',
184 'timestamp': 1511942766,
185 'upload_date': '20171129',
188 'url': 'https://www.br.de/mediathek//video/av:61b0db581aed360007558c12',
189 'only_matching': True,
192 def _real_extract(self
, url
):
193 clip_id
= self
._match
_id
(url
)
195 clip
= self
._download
_json
(
196 'https://proxy-base.master.mango.express/graphql',
197 clip_id
, data
=json
.dumps({
244 }""" % clip_id
}).encode(), headers
={
245 'Content-Type': 'application/json',
246 })['data']['viewer']['clip']
247 title
= clip
['title']
250 for edge
in clip
.get('videoFiles', {}).get('edges', []):
251 node
= edge
.get('node', {})
252 n_url
= node
.get('publicLocation')
255 ext
= determine_ext(n_url
)
257 formats
.extend(self
._extract
_m
3u8_formats
(
258 n_url
, clip_id
, 'mp4', 'm3u8_native',
259 m3u8_id
='hls', fatal
=False))
261 video_profile
= node
.get('videoProfile', {})
262 tbr
= int_or_none(video_profile
.get('bitrate'))
265 format_id
+= '-%d' % tbr
267 'format_id': format_id
,
269 'width': int_or_none(video_profile
.get('width')),
270 'height': int_or_none(video_profile
.get('height')),
272 'filesize': int_or_none(node
.get('fileSize')),
276 for edge
in clip
.get('captionFiles', {}).get('edges', []):
277 node
= edge
.get('node', {})
278 n_url
= node
.get('publicLocation')
281 subtitles
.setdefault('de', []).append({
286 for edge
in clip
.get('teaserImages', {}).get('edges', []):
287 for image_edge
in edge
.get('node', {}).get('imageFiles', {}
).get('edges', []):
288 node
= image_edge
.get('node', {})
289 n_url
= node
.get('publicLocation')
294 'width': int_or_none(node
.get('width')),
295 'height': int_or_none(node
.get('height')),
301 'description': clip
.get('description'),
302 'duration': int_or_none(clip
.get('duration')),
303 'timestamp': parse_iso8601(clip
.get('createdAt')),
304 'age_limit': int_or_none(clip
.get('ageRestriction')),
306 'subtitles': subtitles
,
307 'thumbnails': thumbnails
,