]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/rtl2.py
[rtl2] Add new extractor
[yt-dlp.git] / youtube_dl / extractor / rtl2.py
CommitLineData
7906d199
DD
1# encoding: utf-8
2from __future__ import unicode_literals
3
4import re
5import json
6
7from .common import InfoExtractor
8from ..utils import (
9 ExtractorError,
10 clean_html,
11 unified_strdate,
12 int_or_none,
13)
14
15
16class RTL2IE(InfoExtractor):
17 """Information Extractor for RTL NOW, RTL2 NOW, RTL NITRO, SUPER RTL NOW, VOX NOW and n-tv NOW"""
18 _VALID_URL = r'http?://(?P<url>(?P<domain>(www\.)?rtl2\.de)/.*/(?P<video_id>.*))'
19 _TESTS = [{
20 'url': 'http://www.rtl2.de/sendung/grip-das-motormagazin/folge/folge-203-0',
21 'info_dict': {
22 'id': 'folge-203-0',
23 'ext': 'f4v',
24 'title': 'GRIP sucht den Sommerk\xf6nig',
25 'description' : 'Matthias, Det und Helge treten gegeneinander an.'
26 },
27 'params': {
28 # rtmp download
29 #'skip_download': True,
30 },
31 },
32 {
33 'url': 'http://www.rtl2.de/sendung/koeln-50667/video/5512-anna/21040-anna-erwischt-alex/',
34 'info_dict': {
35 'id': '21040-anna-erwischt-alex',
36 'ext': 'f4v',
37 'title': 'GRIP sucht den Sommerk\xf6nig',
38 'description' : 'Matthias, Det und Helge treten gegeneinander an.'
39 },
40 'params': {
41 # rtmp download
42 #'skip_download': True,
43 },
44 },
45 ]
46
47 def _real_extract(self, url):
48 mobj = re.match(self._VALID_URL, url)
49 video_page_url = 'http://%s/' % mobj.group('domain')
50 video_id = mobj.group('video_id')
51
52 webpage = self._download_webpage('http://' + mobj.group('url'), video_id)
53
54 vico_id = self._html_search_regex(r'vico_id\s*:\s*([0-9]+)', webpage, '%s');
55 vivi_id = self._html_search_regex(r'vivi_id\s*:\s*([0-9]+)', webpage, '%s');
56
57 info_url = 'http://www.rtl2.de/video/php/get_video.php?vico_id=' + vico_id + '&vivi_id=' + vivi_id
58 webpage = self._download_webpage(info_url, '')
59
60 video_info = json.loads(webpage)
61
62 download_url = video_info["video"]["streamurl"] # self._html_search_regex(r'streamurl\":\"(.*?)\"', webpage, '%s');
63 title = video_info["video"]["titel"] # self._html_search_regex(r'titel\":\"(.*?)\"', webpage, '%s');
64 description = video_info["video"]["beschreibung"] # self._html_search_regex(r'beschreibung\":\"(.*?)\"', webpage, '%s');
65 #ext = self._html_search_regex(r'streamurl\":\".*?(\..{2,4})\"', webpage, '%s');
66
67 thumbnail = video_info["video"]["image"]
68
69 download_url = download_url.replace("\\", "")
70
71 stream_url = 'mp4:' + self._html_search_regex(r'ondemand/(.*)', download_url, '%s')
72
73 #print(download_url)
74 #print(stream_url)
75 #print(title)
76 #print(description)
77 #print(video_id)
78
79 formats = []
80
81 fmt = {
82 'url' : download_url,
83 #'app': 'ondemand?_fcs_vhost=cp108781.edgefcs.net',
84 'play_path': stream_url,
85 'player_url': 'http://www.rtl2.de/flashplayer/vipo_player.swf',
86 'page_url': url,
87 'flash_version' : "LNX 11,2,202,429",
88 'rtmp_conn' : ["S:connect", "O:1", "NS:pageUrl:" + url, "NB:fpad:0", "NN:videoFunction:1", "O:0"],
89 'no_resume' : 1,
90 }
91
92 formats.append(fmt)
93
94 return {
95 'id': video_id,
96 'title': title,
97 'thumbnail' : thumbnail,
98 'description' : description,
99 'formats': formats,
100 }