]>
Commit | Line | Data |
---|---|---|
7906d199 DD |
1 | # encoding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
5e1a5ac8 | 4 | import re |
7906d199 | 5 | from .common import InfoExtractor |
7906d199 DD |
6 | |
7 | ||
8 | class RTL2IE(InfoExtractor): | |
3dee7826 | 9 | _VALID_URL = r'http?://(?:www\.)?rtl2\.de/[^?#]*?/(?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', | |
16 | 'description': 'Matthias, Det und Helge treten gegeneinander an.' | |
7906d199 | 17 | }, |
4932a817 YCH |
18 | 'params': { |
19 | # rtmp download | |
20 | 'skip_download': True, | |
21 | }, | |
3dee7826 PH |
22 | }, { |
23 | 'url': 'http://www.rtl2.de/sendung/koeln-50667/video/5512-anna/21040-anna-erwischt-alex/', | |
3dee7826 PH |
24 | 'info_dict': { |
25 | 'id': '21040-anna-erwischt-alex', | |
26 | 'ext': 'mp4', | |
27 | 'title': 'Anna erwischt Alex!', | |
28 | 'description': 'Anna ist Alex\' Tochter bei Köln 50667.' | |
7906d199 | 29 | }, |
5e1a5ac8 YCH |
30 | 'params': { |
31 | # rtmp download | |
32 | 'skip_download': True, | |
33 | }, | |
3dee7826 | 34 | }] |
7906d199 DD |
35 | |
36 | def _real_extract(self, url): | |
3dee7826 PH |
37 | # Some rtl2 urls have no slash at the end, so append it. |
38 | if not url.endswith('/'): | |
fe41ddbb | 39 | url += '/' |
7906d199 | 40 | |
3dee7826 | 41 | video_id = self._match_id(url) |
fe41ddbb DD |
42 | webpage = self._download_webpage(url, video_id) |
43 | ||
5e1a5ac8 YCH |
44 | mobj = re.search( |
45 | r'<div[^>]+data-collection="(?P<vico_id>\d+)"[^>]+data-video="(?P<vivi_id>\d+)"', | |
46 | webpage) | |
47 | if mobj: | |
48 | vico_id = mobj.group('vico_id') | |
49 | vivi_id = mobj.group('vivi_id') | |
50 | else: | |
51 | vico_id = self._html_search_regex( | |
52 | r'vico_id\s*:\s*([0-9]+)', webpage, 'vico_id') | |
53 | vivi_id = self._html_search_regex( | |
54 | r'vivi_id\s*:\s*([0-9]+)', webpage, 'vivi_id') | |
7906d199 | 55 | info_url = 'http://www.rtl2.de/video/php/get_video.php?vico_id=' + vico_id + '&vivi_id=' + vivi_id |
7906d199 | 56 | |
3dee7826 PH |
57 | info = self._download_json(info_url, video_id) |
58 | video_info = info['video'] | |
59 | title = video_info['titel'] | |
60 | description = video_info.get('beschreibung') | |
61 | thumbnail = video_info.get('image') | |
7906d199 | 62 | |
3dee7826 PH |
63 | download_url = video_info['streamurl'] |
64 | download_url = download_url.replace('\\', '') | |
65 | stream_url = 'mp4:' + self._html_search_regex(r'ondemand/(.*)', download_url, 'stream URL') | |
66 | rtmp_conn = ["S:connect", "O:1", "NS:pageUrl:" + url, "NB:fpad:0", "NN:videoFunction:1", "O:0"] | |
7906d199 | 67 | |
fe41ddbb | 68 | formats = [{ |
3dee7826 PH |
69 | 'url': download_url, |
70 | 'play_path': stream_url, | |
71 | 'player_url': 'http://www.rtl2.de/flashplayer/vipo_player.swf', | |
72 | 'page_url': url, | |
73 | 'flash_version': 'LNX 11,2,202,429', | |
74 | 'rtmp_conn': rtmp_conn, | |
75 | 'no_resume': True, | |
76 | }] | |
77 | self._sort_formats(formats) | |
7906d199 DD |
78 | |
79 | return { | |
80 | 'id': video_id, | |
81 | 'title': title, | |
3dee7826 PH |
82 | 'thumbnail': thumbnail, |
83 | 'description': description, | |
7906d199 DD |
84 | 'formats': formats, |
85 | } |