mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.0 KiB
Python
57 lines
2.0 KiB
Python
9 years ago
|
import re
|
||
|
|
||
10 years ago
|
from .common import InfoExtractor
|
||
9 years ago
|
from ..utils import (
|
||
|
js_to_json,
|
||
|
determine_ext,
|
||
|
)
|
||
10 years ago
|
|
||
10 years ago
|
|
||
10 years ago
|
class BpbIE(InfoExtractor):
|
||
10 years ago
|
IE_DESC = 'Bundeszentrale für politische Bildung'
|
||
8 years ago
|
_VALID_URL = r'https?://(?:www\.)?bpb\.de/mediathek/(?P<id>[0-9]+)/'
|
||
10 years ago
|
|
||
|
_TEST = {
|
||
|
'url': 'http://www.bpb.de/mediathek/297/joachim-gauck-zu-1989-und-die-erinnerung-an-die-ddr',
|
||
9 years ago
|
'md5': 'c4f84c8a8044ca9ff68bb8441d300b3f',
|
||
10 years ago
|
'info_dict': {
|
||
|
'id': '297',
|
||
|
'ext': 'mp4',
|
||
|
'title': 'Joachim Gauck zu 1989 und die Erinnerung an die DDR',
|
||
|
'description': 'Joachim Gauck, erster Beauftragter für die Stasi-Unterlagen, spricht auf dem Geschichtsforum über die friedliche Revolution 1989 und eine "gewisse Traurigkeit" im Umgang mit der DDR-Vergangenheit.'
|
||
|
}
|
||
|
}
|
||
|
|
||
|
def _real_extract(self, url):
|
||
|
video_id = self._match_id(url)
|
||
|
webpage = self._download_webpage(url, video_id)
|
||
|
|
||
|
title = self._html_search_regex(
|
||
|
r'<h2 class="white">(.*?)</h2>', webpage, 'title')
|
||
9 years ago
|
video_info_dicts = re.findall(
|
||
7 years ago
|
r"({\s*src\s*:\s*'https?://film\.bpb\.de/[^}]+})", webpage)
|
||
9 years ago
|
|
||
|
formats = []
|
||
|
for video_info in video_info_dicts:
|
||
7 years ago
|
video_info = self._parse_json(
|
||
|
video_info, video_id, transform_source=js_to_json, fatal=False)
|
||
|
if not video_info:
|
||
|
continue
|
||
|
video_url = video_info.get('src')
|
||
|
if not video_url:
|
||
|
continue
|
||
|
quality = 'high' if '_high' in video_url else 'low'
|
||
9 years ago
|
formats.append({
|
||
|
'url': video_url,
|
||
4 years ago
|
'quality': 10 if quality == 'high' else 0,
|
||
9 years ago
|
'format_note': quality,
|
||
|
'format_id': '%s-%s' % (quality, determine_ext(video_url)),
|
||
|
})
|
||
|
|
||
10 years ago
|
return {
|
||
|
'id': video_id,
|
||
9 years ago
|
'formats': formats,
|
||
10 years ago
|
'title': title,
|
||
|
'description': self._og_search_description(webpage),
|
||
|
}
|