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