]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/br.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
12 class BRIE(InfoExtractor
):
13 IE_DESC
= 'Bayerischer Rundfunk Mediathek'
14 _VALID_URL
= r
'https?://(?:www\.)?br\.de/(?:[a-z0-9\-_]+/)+(?P<id>[a-z0-9\-_]+)\.html'
15 _BASE_URL
= 'http://www.br.de'
19 'url': 'http://www.br.de/mediathek/video/sendungen/abendschau/betriebliche-altersvorsorge-104.html',
20 'md5': '83a0477cf0b8451027eb566d88b51106',
22 'id': '48f656ef-287e-486f-be86-459122db22cc',
24 'title': 'Die böse Überraschung',
25 'description': 'Betriebliche Altersvorsorge: Die böse Überraschung',
27 'uploader': 'Reinhard Weber',
28 'upload_date': '20150422',
32 'url': 'http://www.br.de/nachrichten/oberbayern/inhalt/muenchner-polizeipraesident-schreiber-gestorben-100.html',
33 'md5': 'a44396d73ab6a68a69a568fae10705bb',
35 'id': 'a4b83e34-123d-4b81-9f4e-c0d3121a4e05',
37 'title': 'Manfred Schreiber ist tot',
38 'description': 'Abendschau kompakt: Manfred Schreiber ist tot',
43 'url': 'http://www.br.de/radio/br-klassik/sendungen/allegro/premiere-urauffuehrung-the-land-2015-dance-festival-muenchen-100.html',
44 'md5': '8b5b27c0b090f3b35eac4ab3f7a73d3d',
46 'id': '74c603c9-26d3-48bb-b85b-079aeed66e0b',
48 'title': 'Kurzweilig und sehr bewegend',
49 'description': '"The Land" von Peeping Tom: Kurzweilig und sehr bewegend',
54 'url': 'http://www.br.de/radio/bayern1/service/team/videos/team-video-erdelt100.html',
55 'md5': 'dbab0aef2e047060ea7a21fc1ce1078a',
57 'id': '6ba73750-d405-45d3-861d-1ce8c524e059',
59 'title': 'Umweltbewusster Häuslebauer',
60 'description': 'Uwe Erdelt: Umweltbewusster Häuslebauer',
65 'url': 'http://www.br.de/fernsehen/br-alpha/sendungen/kant-fuer-anfaenger/kritik-der-reinen-vernunft/kant-kritik-01-metaphysik100.html',
66 'md5': '23bca295f1650d698f94fc570977dae3',
68 'id': 'd982c9ce-8648-4753-b358-98abb8aec43d',
70 'title': 'Folge 1 - Metaphysik',
71 'description': 'Kant für Anfänger: Folge 1 - Metaphysik',
73 'uploader': 'Eva Maria Steimle',
74 'upload_date': '20140117',
79 def _real_extract(self
, url
):
80 display_id
= self
._match
_id
(url
)
81 page
= self
._download
_webpage
(url
, display_id
)
82 xml_url
= self
._search
_regex
(
83 r
"return BRavFramework\.register\(BRavFramework\('avPlayer_(?:[a-f0-9-]{36})'\)\.setup\({dataURL:'(/(?:[a-z0-9\-]+/)+[a-z0-9/~_.-]+)'}\)\);", page
, 'XMLURL')
84 xml
= self
._download
_xml
(self
._BASE
_URL
+ xml_url
, None)
88 for xml_media
in xml
.findall('video') + xml
.findall('audio'):
90 'id': xml_media
.get('externalId'),
91 'title': xml_media
.find('title').text
,
92 'duration': parse_duration(xml_media
.find('duration').text
),
93 'formats': self
._extract
_formats
(xml_media
.find('assets')),
94 'thumbnails': self
._extract
_thumbnails
(xml_media
.find('teaserImage/variants')),
95 'description': ' '.join(xml_media
.find('shareTitle').text
.splitlines()),
96 'webpage_url': xml_media
.find('permalink').text
98 if xml_media
.find('author').text
:
99 media
['uploader'] = xml_media
.find('author').text
100 if xml_media
.find('broadcastDate').text
:
101 media
['upload_date'] = ''.join(reversed(xml_media
.find('broadcastDate').text
.split('.')))
105 self
._downloader
.report_warning(
106 'found multiple medias; please '
107 'report this with the video URL to http://yt-dl.org/bug')
109 raise ExtractorError('No media entries found')
112 def _extract_formats(self
, assets
):
114 def text_or_none(asset
, tag
):
115 elem
= asset
.find(tag
)
116 return None if elem
is None else elem
.text
119 'url': text_or_none(asset
, 'downloadUrl'),
120 'ext': text_or_none(asset
, 'mediaType'),
121 'format_id': asset
.get('type'),
122 'width': int_or_none(text_or_none(asset
, 'frameWidth')),
123 'height': int_or_none(text_or_none(asset
, 'frameHeight')),
124 'tbr': int_or_none(text_or_none(asset
, 'bitrateVideo')),
125 'abr': int_or_none(text_or_none(asset
, 'bitrateAudio')),
126 'vcodec': text_or_none(asset
, 'codecVideo'),
127 'acodec': text_or_none(asset
, 'codecAudio'),
128 'container': text_or_none(asset
, 'mediaType'),
129 'filesize': int_or_none(text_or_none(asset
, 'size')),
130 } for asset
in assets
.findall('asset')
131 if asset
.find('downloadUrl') is not None]
133 self
._sort
_formats
(formats
)
136 def _extract_thumbnails(self
, variants
):
138 'url': self
._BASE
_URL
+ variant
.find('url').text
,
139 'width': int_or_none(variant
.find('width').text
),
140 'height': int_or_none(variant
.find('height').text
),
141 } for variant
in variants
.findall('variant')]
142 thumbnails
.sort(key
=lambda x
: x
['width'] * x
['height'], reverse
=True)