]>
Commit | Line | Data |
---|---|---|
d3b5101a PH |
1 | from __future__ import unicode_literals |
2 | ||
ea62a2da FV |
3 | import re |
4 | import random | |
5 | ||
6 | from .common import InfoExtractor | |
7 | ||
8 | ||
9 | class VideoPremiumIE(InfoExtractor): | |
d3b5101a | 10 | _VALID_URL = r'https?://(?:www\.)?videopremium\.(?:tv|me)/(?P<id>\w+)(?:/.*)?' |
ea62a2da | 11 | _TEST = { |
d3b5101a PH |
12 | 'url': 'http://videopremium.tv/4w7oadjsf156', |
13 | 'info_dict': { | |
14 | 'id': '4w7oadjsf156', | |
15 | 'ext': 'f4v', | |
16 | 'title': 'youtube-dl_test_video____a_________-BaW_jenozKc.mp4.mp4' | |
ea62a2da | 17 | }, |
d3b5101a PH |
18 | 'params': { |
19 | 'skip_download': True, | |
ea62a2da | 20 | }, |
d3b5101a | 21 | 'skip': 'Test file has been deleted.', |
ea62a2da FV |
22 | } |
23 | ||
24 | def _real_extract(self, url): | |
d3b5101a | 25 | video_id = self._match_id(url) |
ea62a2da FV |
26 | webpage_url = 'http://videopremium.tv/' + video_id |
27 | webpage = self._download_webpage(webpage_url, video_id) | |
28 | ||
c4864091 PH |
29 | if re.match(r"^<html><head><script[^>]*>window.location\s*=", webpage): |
30 | # Download again, we need a cookie | |
31 | webpage = self._download_webpage( | |
32 | webpage_url, video_id, | |
d3b5101a | 33 | note='Downloading webpage again (with cookie)') |
ea62a2da | 34 | |
c4864091 | 35 | video_title = self._html_search_regex( |
d3b5101a | 36 | r'<h2(?:.*?)>\s*(.+?)\s*<', webpage, 'video title') |
ea62a2da | 37 | |
c4864091 | 38 | return { |
8bcc8756 JW |
39 | 'id': video_id, |
40 | 'url': "rtmp://e%d.md.iplay.md/play" % random.randint(1, 16), | |
41 | 'play_path': "mp4:%s.f4v" % video_id, | |
42 | 'page_url': "http://videopremium.tv/" + video_id, | |
43 | 'player_url': "http://videopremium.tv/uplayer/uppod.swf", | |
44 | 'ext': 'f4v', | |
45 | 'title': video_title, | |
4b19e389 | 46 | } |