]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/br.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
13 class BRIE(InfoExtractor
):
14 IE_DESC
= 'Bayerischer Rundfunk Mediathek'
15 _VALID_URL
= r
'https?://(?:www\.)?br\.de/(?:[a-z0-9\-]+/)+(?P<id>[a-z0-9\-]+)\.html'
16 _BASE_URL
= 'http://www.br.de'
20 'url': 'http://www.br.de/mediathek/video/sendungen/heimatsound/heimatsound-festival-2014-trailer-100.html',
21 'md5': '93556dd2bcb2948d9259f8670c516d59',
23 'id': '25e279aa-1ffd-40fd-9955-5325bd48a53a',
25 'title': 'Am 1. und 2. August in Oberammergau',
26 'description': 'md5:dfd224e5aa6819bc1fcbb7826a932021',
30 'url': 'http://www.br.de/mediathek/video/sendungen/unter-unserem-himmel/unter-unserem-himmel-alpen-ueber-den-pass-100.html',
31 'md5': 'ab451b09d861dbed7d7cc9ab0be19ebe',
33 'id': '2c060e69-3a27-4e13-b0f0-668fac17d812',
35 'title': 'Über den Pass',
36 'description': 'Die Eroberung der Alpen: Über den Pass',
40 'url': 'http://www.br.de/nachrichten/schaeuble-haushaltsentwurf-bundestag-100.html',
41 'md5': '3db0df1a9a9cd9fa0c70e6ea8aa8e820',
43 'id': 'c6aae3de-2cf9-43f2-957f-f17fef9afaab',
45 'title': '"Keine neuen Schulden im nächsten Jahr"',
46 'description': 'Haushaltsentwurf: "Keine neuen Schulden im nächsten Jahr"',
50 'url': 'http://www.br.de/radio/bayern1/service/team/videos/team-video-erdelt100.html',
51 'md5': 'dbab0aef2e047060ea7a21fc1ce1078a',
53 'id': '6ba73750-d405-45d3-861d-1ce8c524e059',
55 'title': 'Umweltbewusster Häuslebauer',
56 'description': 'Uwe Erdelt: Umweltbewusster Häuslebauer',
60 'url': 'http://www.br.de/fernsehen/br-alpha/sendungen/kant-fuer-anfaenger/kritik-der-reinen-vernunft/kant-kritik-01-metaphysik100.html',
61 'md5': '23bca295f1650d698f94fc570977dae3',
63 'id': 'd982c9ce-8648-4753-b358-98abb8aec43d',
65 'title': 'Folge 1 - Metaphysik',
66 'description': 'Kant für Anfänger: Folge 1 - Metaphysik',
67 'uploader': 'Eva Maria Steimle',
68 'upload_date': '20140117',
73 def _real_extract(self
, url
):
74 mobj
= re
.match(self
._VALID
_URL
, url
)
75 display_id
= mobj
.group('id')
76 page
= self
._download
_webpage
(url
, display_id
)
77 xml_url
= self
._search
_regex
(
78 r
"return BRavFramework\.register\(BRavFramework\('avPlayer_(?:[a-f0-9-]{36})'\)\.setup\({dataURL:'(/(?:[a-z0-9\-]+/)+[a-z0-9/~_.-]+)'}\)\);", page
, 'XMLURL')
79 xml
= self
._download
_xml
(self
._BASE
_URL
+ xml_url
, None)
83 for xml_media
in xml
.findall('video') + xml
.findall('audio'):
85 'id': xml_media
.get('externalId'),
86 'title': xml_media
.find('title').text
,
87 'formats': self
._extract
_formats
(xml_media
.find('assets')),
88 'thumbnails': self
._extract
_thumbnails
(xml_media
.find('teaserImage/variants')),
89 'description': ' '.join(xml_media
.find('shareTitle').text
.splitlines()),
90 'webpage_url': xml_media
.find('permalink').text
92 if xml_media
.find('author').text
:
93 media
['uploader'] = xml_media
.find('author').text
94 if xml_media
.find('broadcastDate').text
:
95 media
['upload_date'] = ''.join(reversed(xml_media
.find('broadcastDate').text
.split('.')))
99 self
._downloader
.report_warning(
100 'found multiple medias; please '
101 'report this with the video URL to http://yt-dl.org/bug')
103 raise ExtractorError('No media entries found')
106 def _extract_formats(self
, assets
):
108 def text_or_none(asset
, tag
):
109 elem
= asset
.find(tag
)
110 return None if elem
is None else elem
.text
113 'url': text_or_none(asset
, 'downloadUrl'),
114 'ext': text_or_none(asset
, 'mediaType'),
115 'format_id': asset
.get('type'),
116 'width': int_or_none(text_or_none(asset
, 'frameWidth')),
117 'height': int_or_none(text_or_none(asset
, 'frameHeight')),
118 'tbr': int_or_none(text_or_none(asset
, 'bitrateVideo')),
119 'abr': int_or_none(text_or_none(asset
, 'bitrateAudio')),
120 'vcodec': text_or_none(asset
, 'codecVideo'),
121 'acodec': text_or_none(asset
, 'codecAudio'),
122 'container': text_or_none(asset
, 'mediaType'),
123 'filesize': int_or_none(text_or_none(asset
, 'size')),
124 } for asset
in assets
.findall('asset')
125 if asset
.find('downloadUrl') is not None]
127 self
._sort
_formats
(formats
)
130 def _extract_thumbnails(self
, variants
):
132 'url': self
._BASE
_URL
+ variant
.find('url').text
,
133 'width': int_or_none(variant
.find('width').text
),
134 'height': int_or_none(variant
.find('height').text
),
135 } for variant
in variants
.findall('variant')]
136 thumbnails
.sort(key
=lambda x
: x
['width'] * x
['height'], reverse
=True)