]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/br.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
9 class BRIE(InfoExtractor
):
10 IE_DESC
= "Bayerischer Rundfunk Mediathek"
11 _VALID_URL
= r
"^https?://(?:www\.)?br\.de/mediathek/video/(?:sendungen/)?(?P<id>[a-z0-9\-]+)\.html$"
12 _BASE_URL
= "http://www.br.de"
15 "url": "http://www.br.de/mediathek/video/anselm-gruen-114.html",
16 "md5": "c4f83cf0f023ba5875aba0bf46860df2",
18 "id": "2c8d81c5-6fb7-4a74-88d4-e768e5856532",
20 "title": "Feiern und Verzichten",
21 "description": "Anselm GrĂ¼n: Feiern und Verzichten",
22 "uploader": "BR/Birgit Baier",
23 "upload_date": "20140301"
27 def _real_extract(self
, url
):
28 mobj
= re
.match(self
._VALID
_URL
, url
)
29 display_id
= mobj
.group('id')
30 page
= self
._download
_webpage
(url
, display_id
)
31 xml_url
= self
._search
_regex
(
32 r
"return BRavFramework\.register\(BRavFramework\('avPlayer_(?:[a-f0-9-]{36})'\)\.setup\({dataURL:'(/mediathek/video/[a-z0-9/~_.-]+)'}\)\);", page
, "XMLURL")
33 xml
= self
._download
_xml
(self
._BASE
_URL
+ xml_url
, None)
36 "id": xml_video
.get("externalId"),
37 "title": xml_video
.find("title").text
,
38 "formats": self
._extract
_formats
(xml_video
.find("assets")),
39 "thumbnails": self
._extract
_thumbnails
(xml_video
.find("teaserImage/variants")),
40 "description": " ".join(xml_video
.find("shareTitle").text
.splitlines()),
41 "uploader": xml_video
.find("author").text
,
42 "upload_date": "".join(reversed(xml_video
.find("broadcastDate").text
.split("."))),
43 "webpage_url": xml_video
.find("permalink").text
,
44 } for xml_video
in xml
.findall("video")]
47 self
._downloader
.report_warning(
48 'found multiple videos; please '
49 'report this with the video URL to http://yt-dl.org/bug')
51 raise ExtractorError('No video entries found')
54 def _extract_formats(self
, assets
):
56 "url": asset
.find("downloadUrl").text
,
57 "ext": asset
.find("mediaType").text
,
58 "format_id": asset
.get("type"),
59 "width": int(asset
.find("frameWidth").text
),
60 "height": int(asset
.find("frameHeight").text
),
61 "tbr": int(asset
.find("bitrateVideo").text
),
62 "abr": int(asset
.find("bitrateAudio").text
),
63 "vcodec": asset
.find("codecVideo").text
,
64 "container": asset
.find("mediaType").text
,
65 "filesize": int(asset
.find("size").text
),
66 } for asset
in assets
.findall("asset")
67 if asset
.find("downloadUrl") is not None]
69 self
._sort
_formats
(formats
)
72 def _extract_thumbnails(self
, variants
):
74 "url": self
._BASE
_URL
+ variant
.find("url").text
,
75 "width": int(variant
.find("width").text
),
76 "height": int(variant
.find("height").text
),
77 } for variant
in variants
.findall("variant")]
78 thumbnails
.sort(key
=lambda x
: x
["width"] * x
["height"], reverse
=True)