]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/br.py
45ba5173246575ab617dbab911280b75d61d61e8
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/heimatsound/heimatsound-festival-2014-trailer-100.html',
20 'md5': '93556dd2bcb2948d9259f8670c516d59',
22 'id': '25e279aa-1ffd-40fd-9955-5325bd48a53a',
24 'title': 'Wenn das Traditions-Theater wackelt',
25 'description': 'Heimatsound-Festival 2014: Wenn das Traditions-Theater wackelt',
28 'upload_date': '20140802',
32 'url': 'http://www.br.de/nachrichten/schaeuble-haushaltsentwurf-bundestag-100.html',
33 'md5': '3db0df1a9a9cd9fa0c70e6ea8aa8e820',
35 'id': 'c6aae3de-2cf9-43f2-957f-f17fef9afaab',
37 'title': '"Keine neuen Schulden im nächsten Jahr"',
38 'description': 'Haushaltsentwurf: "Keine neuen Schulden im nächsten Jahr"',
43 'url': 'http://www.br.de/radio/bayern1/service/team/videos/team-video-erdelt100.html',
44 'md5': 'dbab0aef2e047060ea7a21fc1ce1078a',
46 'id': '6ba73750-d405-45d3-861d-1ce8c524e059',
48 'title': 'Umweltbewusster Häuslebauer',
49 'description': 'Uwe Erdelt: Umweltbewusster Häuslebauer',
54 'url': 'http://www.br.de/fernsehen/br-alpha/sendungen/kant-fuer-anfaenger/kritik-der-reinen-vernunft/kant-kritik-01-metaphysik100.html',
55 'md5': '23bca295f1650d698f94fc570977dae3',
57 'id': 'd982c9ce-8648-4753-b358-98abb8aec43d',
59 'title': 'Folge 1 - Metaphysik',
60 'description': 'Kant für Anfänger: Folge 1 - Metaphysik',
62 'uploader': 'Eva Maria Steimle',
63 'upload_date': '20140117',
68 def _real_extract(self
, url
):
69 display_id
= self
._match
_id
(url
)
70 page
= self
._download
_webpage
(url
, display_id
)
71 xml_url
= self
._search
_regex
(
72 r
"return BRavFramework\.register\(BRavFramework\('avPlayer_(?:[a-f0-9-]{36})'\)\.setup\({dataURL:'(/(?:[a-z0-9\-]+/)+[a-z0-9/~_.-]+)'}\)\);", page
, 'XMLURL')
73 xml
= self
._download
_xml
(self
._BASE
_URL
+ xml_url
, None)
77 for xml_media
in xml
.findall('video') + xml
.findall('audio'):
79 'id': xml_media
.get('externalId'),
80 'title': xml_media
.find('title').text
,
81 'duration': parse_duration(xml_media
.find('duration').text
),
82 'formats': self
._extract
_formats
(xml_media
.find('assets')),
83 'thumbnails': self
._extract
_thumbnails
(xml_media
.find('teaserImage/variants')),
84 'description': ' '.join(xml_media
.find('shareTitle').text
.splitlines()),
85 'webpage_url': xml_media
.find('permalink').text
87 if xml_media
.find('author').text
:
88 media
['uploader'] = xml_media
.find('author').text
89 if xml_media
.find('broadcastDate').text
:
90 media
['upload_date'] = ''.join(reversed(xml_media
.find('broadcastDate').text
.split('.')))
94 self
._downloader
.report_warning(
95 'found multiple medias; please '
96 'report this with the video URL to http://yt-dl.org/bug')
98 raise ExtractorError('No media entries found')
101 def _extract_formats(self
, assets
):
103 def text_or_none(asset
, tag
):
104 elem
= asset
.find(tag
)
105 return None if elem
is None else elem
.text
108 'url': text_or_none(asset
, 'downloadUrl'),
109 'ext': text_or_none(asset
, 'mediaType'),
110 'format_id': asset
.get('type'),
111 'width': int_or_none(text_or_none(asset
, 'frameWidth')),
112 'height': int_or_none(text_or_none(asset
, 'frameHeight')),
113 'tbr': int_or_none(text_or_none(asset
, 'bitrateVideo')),
114 'abr': int_or_none(text_or_none(asset
, 'bitrateAudio')),
115 'vcodec': text_or_none(asset
, 'codecVideo'),
116 'acodec': text_or_none(asset
, 'codecAudio'),
117 'container': text_or_none(asset
, 'mediaType'),
118 'filesize': int_or_none(text_or_none(asset
, 'size')),
119 } for asset
in assets
.findall('asset')
120 if asset
.find('downloadUrl') is not None]
122 self
._sort
_formats
(formats
)
125 def _extract_thumbnails(self
, variants
):
127 'url': self
._BASE
_URL
+ variant
.find('url').text
,
128 'width': int_or_none(variant
.find('width').text
),
129 'height': int_or_none(variant
.find('height').text
),
130 } for variant
in variants
.findall('variant')]
131 thumbnails
.sort(key
=lambda x
: x
['width'] * x
['height'], reverse
=True)