]>
Commit | Line | Data |
---|---|---|
dbda1b51 | 1 | # encoding: utf-8 |
f945612b PH |
2 | from __future__ import unicode_literals |
3 | ||
dbda1b51 | 4 | import re |
5 | ||
6 | from .common import InfoExtractor | |
739674cd | 7 | from ..utils import ( |
739674cd | 8 | ExtractorError, |
1bb92aff S |
9 | clean_html, |
10 | unified_strdate, | |
1bb92aff | 11 | int_or_none, |
739674cd | 12 | ) |
dbda1b51 | 13 | |
1d87e3a1 | 14 | |
dbda1b51 | 15 | class RTLnowIE(InfoExtractor): |
4c62a16f | 16 | """Information Extractor for RTL NOW, RTL2 NOW, RTL NITRO, SUPER RTL NOW, VOX NOW and n-tv NOW""" |
1bb92aff S |
17 | _VALID_URL = r'''(?x) |
18 | (?:https?://)? | |
19 | (?P<url> | |
20 | (?P<domain> | |
21 | rtl-now\.rtl\.de| | |
22 | rtl2now\.rtl2\.de| | |
23 | (?:www\.)?voxnow\.de| | |
24 | (?:www\.)?rtlnitronow\.de| | |
25 | (?:www\.)?superrtlnow\.de| | |
26 | (?:www\.)?n-tvnow\.de) | |
27 | /+[a-zA-Z0-9-]+/[a-zA-Z0-9-]+\.php\? | |
28 | (?:container_id|film_id)=(?P<video_id>[0-9]+)& | |
29 | player=1(?:&season=[0-9]+)?(?:&.*)? | |
30 | )''' | |
31 | ||
32 | _TESTS = [ | |
33 | { | |
34 | 'url': 'http://rtl-now.rtl.de/ahornallee/folge-1.php?film_id=90419&player=1&season=1', | |
35 | 'info_dict': { | |
36 | 'id': '90419', | |
37 | 'ext': 'flv', | |
38 | 'title': 'Ahornallee - Folge 1 - Der Einzug', | |
39 | 'description': 'md5:ce843b6b5901d9a7f7d04d1bbcdb12de', | |
40 | 'upload_date': '20070416', | |
41 | 'duration': 1685, | |
42 | }, | |
43 | 'params': { | |
44 | 'skip_download': True, | |
45 | }, | |
46 | 'skip': 'Only works from Germany', | |
ea55b2a4 | 47 | }, |
1bb92aff S |
48 | { |
49 | 'url': 'http://rtl2now.rtl2.de/aerger-im-revier/episode-15-teil-1.php?film_id=69756&player=1&season=2&index=5', | |
50 | 'info_dict': { | |
51 | 'id': '69756', | |
52 | 'ext': 'flv', | |
53 | 'title': 'Ärger im Revier - Ein junger Ladendieb, ein handfester Streit u.a.', | |
54 | 'description': 'md5:3fb247005ed21a935ffc82b7dfa70cf0', | |
55 | 'thumbnail': 'http://autoimg.static-fra.de/rtl2now/219850/1500x1500/image2.jpg', | |
56 | 'upload_date': '20120519', | |
57 | 'duration': 1245, | |
58 | }, | |
59 | 'params': { | |
60 | 'skip_download': True, | |
61 | }, | |
62 | 'skip': 'Only works from Germany', | |
d68730a5 | 63 | }, |
1bb92aff S |
64 | { |
65 | 'url': 'http://www.voxnow.de/voxtours/suedafrika-reporter-ii.php?film_id=13883&player=1&season=17', | |
66 | 'info_dict': { | |
67 | 'id': '13883', | |
68 | 'ext': 'flv', | |
69 | 'title': 'Voxtours - Südafrika-Reporter II', | |
70 | 'description': 'md5:de7f8d56be6fd4fed10f10f57786db00', | |
71 | 'upload_date': '20090627', | |
72 | 'duration': 1800, | |
73 | }, | |
74 | 'params': { | |
75 | 'skip_download': True, | |
76 | }, | |
d68730a5 | 77 | }, |
1bb92aff S |
78 | { |
79 | 'url': 'http://superrtlnow.de/medicopter-117/angst.php?film_id=99205&player=1', | |
80 | 'info_dict': { | |
81 | 'id': '99205', | |
82 | 'ext': 'flv', | |
83 | 'title': 'Medicopter 117 - Angst!', | |
84 | 'description': 'md5:895b1df01639b5f61a04fc305a5cb94d', | |
85 | 'thumbnail': 'http://autoimg.static-fra.de/superrtlnow/287529/1500x1500/image2.jpg', | |
86 | 'upload_date': '20080928', | |
87 | 'duration': 2691, | |
88 | }, | |
89 | 'params': { | |
90 | 'skip_download': True, | |
91 | }, | |
4c62a16f | 92 | }, |
1bb92aff | 93 | { |
995befe0 | 94 | 'url': 'http://www.n-tvnow.de/deluxe-alles-was-spass-macht/thema-ua-luxushotel-fuer-vierbeiner.php?container_id=153819&player=1&season=0', |
1bb92aff | 95 | 'info_dict': { |
995befe0 | 96 | 'id': '153819', |
1bb92aff | 97 | 'ext': 'flv', |
995befe0 S |
98 | 'title': 'Deluxe - Alles was Spaß macht - Thema u.a.: Luxushotel für Vierbeiner', |
99 | 'description': 'md5:c3705e1bb32e1a5b2bcd634fc065c631', | |
100 | 'thumbnail': 'http://autoimg.static-fra.de/ntvnow/383157/1500x1500/image2.jpg', | |
101 | 'upload_date': '20140221', | |
102 | 'duration': 2429, | |
1bb92aff S |
103 | }, |
104 | 'skip': 'Only works from Germany', | |
4c62a16f | 105 | }, |
1bb92aff | 106 | ] |
dbda1b51 | 107 | |
f945612b | 108 | def _real_extract(self, url): |
dbda1b51 | 109 | mobj = re.match(self._VALID_URL, url) |
1bb92aff | 110 | video_page_url = 'http://%s/' % mobj.group('domain') |
f945612b | 111 | video_id = mobj.group('video_id') |
dbda1b51 | 112 | |
1bb92aff S |
113 | webpage = self._download_webpage('http://' + mobj.group('url'), video_id) |
114 | ||
115 | mobj = re.search(r'(?s)<div style="margin-left: 20px; font-size: 13px;">(.*?)<div id="playerteaser">', webpage) | |
116 | if mobj: | |
117 | raise ExtractorError(clean_html(mobj.group(1)), expected=True) | |
118 | ||
119 | title = self._og_search_title(webpage) | |
120 | description = self._og_search_description(webpage) | |
121 | thumbnail = self._og_search_thumbnail(webpage, default=None) | |
739674cd | 122 | |
1bb92aff | 123 | upload_date = unified_strdate(self._html_search_meta('uploadDate', webpage, 'upload date')) |
739674cd | 124 | |
33f1f2c4 S |
125 | mobj = re.search(r'<meta itemprop="duration" content="PT(?P<seconds>\d+)S" />', webpage) |
126 | duration = int(mobj.group('seconds')) if mobj else None | |
127 | ||
f945612b | 128 | playerdata_url = self._html_search_regex( |
1bb92aff | 129 | r"'playerdata': '(?P<playerdata_url>[^']+)'", webpage, 'playerdata_url') |
dbda1b51 | 130 | |
1bb92aff | 131 | playerdata = self._download_xml(playerdata_url, video_id, 'Downloading player data XML') |
dbda1b51 | 132 | |
1bb92aff | 133 | videoinfo = playerdata.find('./playlist/videoinfo') |
33f1f2c4 | 134 | |
1bb92aff S |
135 | formats = [] |
136 | for filename in videoinfo.findall('filename'): | |
137 | mobj = re.search(r'(?P<url>rtmpe://(?:[^/]+/){2})(?P<play_path>.+)', filename.text) | |
138 | if mobj: | |
139 | fmt = { | |
140 | 'url': mobj.group('url'), | |
141 | 'play_path': 'mp4:' + mobj.group('play_path'), | |
142 | 'page_url': video_page_url, | |
143 | 'player_url': video_page_url + 'includes/vodplayer.swf', | |
144 | } | |
145 | else: | |
146 | fmt = { | |
147 | 'url': filename.text, | |
148 | } | |
149 | fmt.update({ | |
150 | 'width': int_or_none(filename.get('width')), | |
151 | 'height': int_or_none(filename.get('height')), | |
152 | 'vbr': int_or_none(filename.get('bitrate')), | |
153 | 'ext': 'flv', | |
154 | }) | |
155 | formats.append(fmt) | |
dbda1b51 | 156 | |
f945612b PH |
157 | return { |
158 | 'id': video_id, | |
1bb92aff S |
159 | 'title': title, |
160 | 'description': description, | |
161 | 'thumbnail': thumbnail, | |
162 | 'upload_date': upload_date, | |
163 | 'duration': duration, | |
164 | 'formats': formats, | |
165 | } |