]>
Commit | Line | Data |
---|---|---|
5e1a5ac8 | 1 | import re |
9c5b5f21 | 2 | |
7906d199 | 3 | from .common import InfoExtractor |
9751a457 | 4 | from ..utils import int_or_none |
7906d199 DD |
5 | |
6 | ||
7 | class RTL2IE(InfoExtractor): | |
b68e00b0 | 8 | IE_NAME = 'rtl2' |
4f7db468 | 9 | _VALID_URL = r'https?://(?:www\.)?rtl2\.de/sendung/[^/]+/(?:video/(?P<vico_id>\d+)[^/]+/(?P<vivi_id>\d+)-|folge/)(?P<id>[^/?#]+)' |
7906d199 | 10 | _TESTS = [{ |
3dee7826 | 11 | 'url': 'http://www.rtl2.de/sendung/grip-das-motormagazin/folge/folge-203-0', |
3dee7826 PH |
12 | 'info_dict': { |
13 | 'id': 'folge-203-0', | |
14 | 'ext': 'f4v', | |
15 | 'title': 'GRIP sucht den Sommerkönig', | |
add96eb9 | 16 | 'description': 'md5:e3adbb940fd3c6e76fa341b8748b562f', |
7906d199 | 17 | }, |
4932a817 YCH |
18 | 'params': { |
19 | # rtmp download | |
20 | 'skip_download': True, | |
21 | }, | |
4f7db468 | 22 | 'expected_warnings': ['Unable to download f4m manifest', 'Failed to download m3u8 information'], |
3dee7826 PH |
23 | }, { |
24 | 'url': 'http://www.rtl2.de/sendung/koeln-50667/video/5512-anna/21040-anna-erwischt-alex/', | |
3dee7826 | 25 | 'info_dict': { |
4f7db468 | 26 | 'id': 'anna-erwischt-alex', |
3dee7826 PH |
27 | 'ext': 'mp4', |
28 | 'title': 'Anna erwischt Alex!', | |
add96eb9 | 29 | 'description': 'Anna nimmt ihrem Vater nicht ab, dass er nicht spielt. Und tatsächlich erwischt sie ihn auf frischer Tat.', |
7906d199 | 30 | }, |
5e1a5ac8 YCH |
31 | 'params': { |
32 | # rtmp download | |
33 | 'skip_download': True, | |
34 | }, | |
4f7db468 | 35 | 'expected_warnings': ['Unable to download f4m manifest', 'Failed to download m3u8 information'], |
3dee7826 | 36 | }] |
7906d199 DD |
37 | |
38 | def _real_extract(self, url): | |
5ad28e7f | 39 | vico_id, vivi_id, display_id = self._match_valid_url(url).groups() |
4f7db468 RA |
40 | if not vico_id: |
41 | webpage = self._download_webpage(url, display_id) | |
42 | ||
43 | mobj = re.search( | |
44 | r'data-collection="(?P<vico_id>\d+)"[^>]+data-video="(?P<vivi_id>\d+)"', | |
45 | webpage) | |
46 | if mobj: | |
47 | vico_id = mobj.group('vico_id') | |
48 | vivi_id = mobj.group('vivi_id') | |
49 | else: | |
50 | vico_id = self._html_search_regex( | |
51 | r'vico_id\s*:\s*([0-9]+)', webpage, 'vico_id') | |
52 | vivi_id = self._html_search_regex( | |
53 | r'vivi_id\s*:\s*([0-9]+)', webpage, 'vivi_id') | |
7906d199 | 54 | |
9c5b5f21 | 55 | info = self._download_json( |
4f7db468 RA |
56 | 'https://service.rtl2.de/api-player-vipo/video.php', |
57 | display_id, query={ | |
9c5b5f21 RA |
58 | 'vico_id': vico_id, |
59 | 'vivi_id': vivi_id, | |
60 | }) | |
3dee7826 PH |
61 | video_info = info['video'] |
62 | title = video_info['titel'] | |
7906d199 | 63 | |
9c5b5f21 RA |
64 | formats = [] |
65 | ||
66 | rtmp_url = video_info.get('streamurl') | |
67 | if rtmp_url: | |
68 | rtmp_url = rtmp_url.replace('\\', '') | |
69 | stream_url = 'mp4:' + self._html_search_regex(r'/ondemand/(.+)', rtmp_url, 'stream URL') | |
70 | rtmp_conn = ['S:connect', 'O:1', 'NS:pageUrl:' + url, 'NB:fpad:0', 'NN:videoFunction:1', 'O:0'] | |
71 | ||
72 | formats.append({ | |
73 | 'format_id': 'rtmp', | |
74 | 'url': rtmp_url, | |
75 | 'play_path': stream_url, | |
977a7821 | 76 | 'player_url': 'https://www.rtl2.de/sites/default/modules/rtl2/jwplayer/jwplayer-7.6.0/jwplayer.flash.swf', |
9c5b5f21 RA |
77 | 'page_url': url, |
78 | 'flash_version': 'LNX 11,2,202,429', | |
79 | 'rtmp_conn': rtmp_conn, | |
80 | 'no_resume': True, | |
f983b875 | 81 | 'quality': 1, |
9c5b5f21 RA |
82 | }) |
83 | ||
84 | m3u8_url = video_info.get('streamurl_hls') | |
85 | if m3u8_url: | |
4f7db468 | 86 | formats.extend(self._extract_akamai_formats(m3u8_url, display_id)) |
7906d199 | 87 | |
7906d199 | 88 | return { |
4f7db468 | 89 | 'id': display_id, |
7906d199 | 90 | 'title': title, |
9c5b5f21 RA |
91 | 'thumbnail': video_info.get('image'), |
92 | 'description': video_info.get('beschreibung'), | |
93 | 'duration': int_or_none(video_info.get('duration')), | |
7906d199 DD |
94 | 'formats': formats, |
95 | } |