]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/videopremium.py
Update changelog.
[youtubedl] / youtube_dl / extractor / videopremium.py
1 from __future__ import unicode_literals
2
3 import re
4 import random
5
6 from .common import InfoExtractor
7
8
9 class VideoPremiumIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?videopremium\.(?:tv|me)/(?P<id>\w+)(?:/.*)?'
11 _TEST = {
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'
17 },
18 'params': {
19 'skip_download': True,
20 },
21 'skip': 'Test file has been deleted.',
22 }
23
24 def _real_extract(self, url):
25 video_id = self._match_id(url)
26 webpage_url = 'http://videopremium.tv/' + video_id
27 webpage = self._download_webpage(webpage_url, video_id)
28
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,
33 note='Downloading webpage again (with cookie)')
34
35 video_title = self._html_search_regex(
36 r'<h2(?:.*?)>\s*(.+?)\s*<', webpage, 'video title')
37
38 return {
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,
46 }