]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/br.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
18 class BRIE(InfoExtractor
):
19 IE_DESC
= 'Bayerischer Rundfunk'
20 _VALID_URL
= r
'(?P<base_url>https?://(?:www\.)?br(?:-klassik)?\.de)/(?:[a-z0-9\-_]+/)+(?P<id>[a-z0-9\-_]+)\.html'
24 'url': 'http://www.br.de/mediathek/video/sendungen/abendschau/betriebliche-altersvorsorge-104.html',
25 'md5': '83a0477cf0b8451027eb566d88b51106',
27 'id': '48f656ef-287e-486f-be86-459122db22cc',
29 'title': 'Die böse Überraschung',
30 'description': 'md5:ce9ac81b466ce775b8018f6801b48ac9',
32 'uploader': 'Reinhard Weber',
33 'upload_date': '20150422',
35 'skip': '404 not found',
38 'url': 'http://www.br.de/nachrichten/oberbayern/inhalt/muenchner-polizeipraesident-schreiber-gestorben-100.html',
39 'md5': 'af3a3a4aa43ff0ce6a89504c67f427ef',
41 'id': 'a4b83e34-123d-4b81-9f4e-c0d3121a4e05',
43 'title': 'Manfred Schreiber ist tot',
44 'description': 'md5:b454d867f2a9fc524ebe88c3f5092d97',
47 'skip': '404 not found',
50 'url': 'https://www.br-klassik.de/audio/peeping-tom-premierenkritik-dance-festival-muenchen-100.html',
51 'md5': '8b5b27c0b090f3b35eac4ab3f7a73d3d',
53 'id': '74c603c9-26d3-48bb-b85b-079aeed66e0b',
55 'title': 'Kurzweilig und sehr bewegend',
56 'description': 'md5:0351996e3283d64adeb38ede91fac54e',
59 'skip': '404 not found',
62 'url': 'http://www.br.de/radio/bayern1/service/team/videos/team-video-erdelt100.html',
63 'md5': 'dbab0aef2e047060ea7a21fc1ce1078a',
65 'id': '6ba73750-d405-45d3-861d-1ce8c524e059',
67 'title': 'Umweltbewusster Häuslebauer',
68 'description': 'md5:d52dae9792d00226348c1dbb13c9bae2',
73 'url': 'http://www.br.de/fernsehen/br-alpha/sendungen/kant-fuer-anfaenger/kritik-der-reinen-vernunft/kant-kritik-01-metaphysik100.html',
74 'md5': '23bca295f1650d698f94fc570977dae3',
76 'id': 'd982c9ce-8648-4753-b358-98abb8aec43d',
78 'title': 'Folge 1 - Metaphysik',
79 'description': 'md5:bb659990e9e59905c3d41e369db1fbe3',
81 'uploader': 'Eva Maria Steimle',
82 'upload_date': '20170208',
87 def _real_extract(self
, url
):
88 base_url
, display_id
= self
._match
_valid
_url
(url
).groups()
89 page
= self
._download
_webpage
(url
, display_id
)
90 xml_url
= self
._search
_regex
(
91 r
"return BRavFramework\.register\(BRavFramework\('avPlayer_(?:[a-f0-9-]{36})'\)\.setup\({dataURL:'(/(?:[a-z0-9\-]+/)+[a-z0-9/~_.-]+)'}\)\);", page
, 'XMLURL')
92 xml
= self
._download
_xml
(base_url
+ xml_url
, display_id
)
96 for xml_media
in xml
.findall('video') + xml
.findall('audio'):
97 media_id
= xml_media
.get('externalId')
100 'title': xpath_text(xml_media
, 'title', 'title', True),
101 'duration': parse_duration(xpath_text(xml_media
, 'duration')),
102 'formats': self
._extract
_formats
(xpath_element(
103 xml_media
, 'assets'), media_id
),
104 'thumbnails': self
._extract
_thumbnails
(xpath_element(
105 xml_media
, 'teaserImage/variants'), base_url
),
106 'description': xpath_text(xml_media
, 'desc'),
107 'webpage_url': xpath_text(xml_media
, 'permalink'),
108 'uploader': xpath_text(xml_media
, 'author'),
110 broadcast_date
= xpath_text(xml_media
, 'broadcastDate')
112 media
['upload_date'] = ''.join(reversed(broadcast_date
.split('.')))
117 'found multiple medias; please '
118 'report this with the video URL to http://yt-dl.org/bug')
120 raise ExtractorError('No media entries found')
123 def _extract_formats(self
, assets
, media_id
):
125 for asset
in assets
.findall('asset'):
126 format_url
= xpath_text(asset
, ['downloadUrl', 'url'])
127 asset_type
= asset
.get('type')
128 if asset_type
.startswith('HDS'):
129 formats
.extend(self
._extract
_f
4m
_formats
(
130 format_url
+ '?hdcore=3.2.0', media_id
, f4m_id
='hds', fatal
=False))
131 elif asset_type
.startswith('HLS'):
132 formats
.extend(self
._extract
_m
3u8_formats
(
133 format_url
, media_id
, 'mp4', 'm3u8_native', m3u8_id
='hds', fatal
=False))
136 'ext': xpath_text(asset
, 'mediaType'),
137 'width': int_or_none(xpath_text(asset
, 'frameWidth')),
138 'height': int_or_none(xpath_text(asset
, 'frameHeight')),
139 'tbr': int_or_none(xpath_text(asset
, 'bitrateVideo')),
140 'abr': int_or_none(xpath_text(asset
, 'bitrateAudio')),
141 'vcodec': xpath_text(asset
, 'codecVideo'),
142 'acodec': xpath_text(asset
, 'codecAudio'),
143 'container': xpath_text(asset
, 'mediaType'),
144 'filesize': int_or_none(xpath_text(asset
, 'size')),
146 format_url
= self
._proto
_relative
_url
(format_url
)
148 http_format_info
= format_info
.copy()
149 http_format_info
.update({
151 'format_id': 'http-%s' % asset_type
,
153 formats
.append(http_format_info
)
154 server_prefix
= xpath_text(asset
, 'serverPrefix')
156 rtmp_format_info
= format_info
.copy()
157 rtmp_format_info
.update({
158 'url': server_prefix
,
159 'play_path': xpath_text(asset
, 'fileName'),
160 'format_id': 'rtmp-%s' % asset_type
,
162 formats
.append(rtmp_format_info
)
163 self
._sort
_formats
(formats
)
166 def _extract_thumbnails(self
, variants
, base_url
):
168 'url': base_url
+ xpath_text(variant
, 'url'),
169 'width': int_or_none(xpath_text(variant
, 'width')),
170 'height': int_or_none(xpath_text(variant
, 'height')),
171 } for variant
in variants
.findall('variant') if xpath_text(variant
, 'url')]
172 thumbnails
.sort(key
=lambda x
: x
['width'] * x
['height'], reverse
=True)
176 class BRMediathekIE(InfoExtractor
):
177 IE_DESC
= 'Bayerischer Rundfunk Mediathek'
178 _VALID_URL
= r
'https?://(?:www\.)?br\.de/mediathek/video/[^/?&#]*?-(?P<id>av:[0-9a-f]{24})'
181 'url': 'https://www.br.de/mediathek/video/gesundheit-die-sendung-vom-28112017-av:5a1e6a6e8fce6d001871cc8e',
182 'md5': 'fdc3d485835966d1622587d08ba632ec',
184 'id': 'av:5a1e6a6e8fce6d001871cc8e',
186 'title': 'Die Sendung vom 28.11.2017',
187 'description': 'md5:6000cdca5912ab2277e5b7339f201ccc',
188 'timestamp': 1511942766,
189 'upload_date': '20171129',
193 def _real_extract(self
, url
):
194 clip_id
= self
._match
_id
(url
)
196 clip
= self
._download
_json
(
197 'https://proxy-base.master.mango.express/graphql',
198 clip_id
, data
=json
.dumps({
245 }""" % clip_id
}).encode(), headers
={
246 'Content-Type': 'application/json',
247 })['data']['viewer']['clip']
248 title
= clip
['title']
251 for edge
in clip
.get('videoFiles', {}).get('edges', []):
252 node
= edge
.get('node', {})
253 n_url
= node
.get('publicLocation')
256 ext
= determine_ext(n_url
)
258 formats
.extend(self
._extract
_m
3u8_formats
(
259 n_url
, clip_id
, 'mp4', 'm3u8_native',
260 m3u8_id
='hls', fatal
=False))
262 video_profile
= node
.get('videoProfile', {})
263 tbr
= int_or_none(video_profile
.get('bitrate'))
266 format_id
+= '-%d' % tbr
268 'format_id': format_id
,
270 'width': int_or_none(video_profile
.get('width')),
271 'height': int_or_none(video_profile
.get('height')),
273 'filesize': int_or_none(node
.get('fileSize')),
275 self
._sort
_formats
(formats
)
278 for edge
in clip
.get('captionFiles', {}).get('edges', []):
279 node
= edge
.get('node', {})
280 n_url
= node
.get('publicLocation')
283 subtitles
.setdefault('de', []).append({
288 for edge
in clip
.get('teaserImages', {}).get('edges', []):
289 for image_edge
in edge
.get('node', {}).get('imageFiles', {}
).get('edges', []):
290 node
= image_edge
.get('node', {})
291 n_url
= node
.get('publicLocation')
296 'width': int_or_none(node
.get('width')),
297 'height': int_or_none(node
.get('height')),
303 'description': clip
.get('description'),
304 'duration': int_or_none(clip
.get('duration')),
305 'timestamp': parse_iso8601(clip
.get('createdAt')),
306 'age_limit': int_or_none(clip
.get('ageRestriction')),
308 'subtitles': subtitles
,
309 'thumbnails': thumbnails
,