]>
Commit | Line | Data |
---|---|---|
355682be | 1 | # coding: utf-8 |
355682be OJ |
2 | from __future__ import unicode_literals |
3 | ||
566bda51 YCH |
4 | import re |
5 | ||
355682be | 6 | from .common import InfoExtractor |
566bda51 YCH |
7 | from ..utils import ( |
8 | js_to_json, | |
9 | determine_ext, | |
10 | ) | |
355682be | 11 | |
3d960a22 | 12 | |
355682be | 13 | class BpbIE(InfoExtractor): |
3d960a22 | 14 | IE_DESC = 'Bundeszentrale für politische Bildung' |
92519402 | 15 | _VALID_URL = r'https?://(?:www\.)?bpb\.de/mediathek/(?P<id>[0-9]+)/' |
3d960a22 PH |
16 | |
17 | _TEST = { | |
18 | 'url': 'http://www.bpb.de/mediathek/297/joachim-gauck-zu-1989-und-die-erinnerung-an-die-ddr', | |
566bda51 YCH |
19 | # md5 fails in Python 2.6 due to buggy server response and wrong handling of urllib2 |
20 | 'md5': 'c4f84c8a8044ca9ff68bb8441d300b3f', | |
3d960a22 PH |
21 | 'info_dict': { |
22 | 'id': '297', | |
23 | 'ext': 'mp4', | |
24 | 'title': 'Joachim Gauck zu 1989 und die Erinnerung an die DDR', | |
25 | '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.' | |
26 | } | |
27 | } | |
28 | ||
29 | def _real_extract(self, url): | |
30 | video_id = self._match_id(url) | |
31 | webpage = self._download_webpage(url, video_id) | |
32 | ||
33 | title = self._html_search_regex( | |
34 | r'<h2 class="white">(.*?)</h2>', webpage, 'title') | |
566bda51 | 35 | video_info_dicts = re.findall( |
c1c1585b | 36 | r"({\s*src\s*:\s*'https?://film\.bpb\.de/[^}]+})", webpage) |
566bda51 YCH |
37 | |
38 | formats = [] | |
39 | for video_info in video_info_dicts: | |
c1c1585b S |
40 | video_info = self._parse_json( |
41 | video_info, video_id, transform_source=js_to_json, fatal=False) | |
42 | if not video_info: | |
43 | continue | |
44 | video_url = video_info.get('src') | |
45 | if not video_url: | |
46 | continue | |
47 | quality = 'high' if '_high' in video_url else 'low' | |
566bda51 YCH |
48 | formats.append({ |
49 | 'url': video_url, | |
f983b875 | 50 | 'quality': 10 if quality == 'high' else 0, |
566bda51 YCH |
51 | 'format_note': quality, |
52 | 'format_id': '%s-%s' % (quality, determine_ext(video_url)), | |
53 | }) | |
54 | ||
55 | self._sort_formats(formats) | |
3d960a22 PH |
56 | |
57 | return { | |
58 | 'id': video_id, | |
566bda51 | 59 | 'formats': formats, |
3d960a22 PH |
60 | 'title': title, |
61 | 'description': self._og_search_description(webpage), | |
62 | } |