]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/videopremium.py
Imported Upstream version 2013.12.04
[youtubedl] / youtube_dl / extractor / videopremium.py
1 import re
2 import random
3
4 from .common import InfoExtractor
5
6
7 class VideoPremiumIE(InfoExtractor):
8 _VALID_URL = r'(?:https?://)?(?:www\.)?videopremium\.(?:tv|me)/(?P<id>\w+)(?:/.*)?'
9 _TEST = {
10 u'url': u'http://videopremium.tv/4w7oadjsf156',
11 u'file': u'4w7oadjsf156.f4v',
12 u'info_dict': {
13 u"title": u"youtube-dl_test_video____a_________-BaW_jenozKc.mp4.mp4"
14 },
15 u'params': {
16 u'skip_download': True,
17 },
18 }
19
20 def _real_extract(self, url):
21 mobj = re.match(self._VALID_URL, url)
22
23 video_id = mobj.group('id')
24 webpage_url = 'http://videopremium.tv/' + video_id
25 webpage = self._download_webpage(webpage_url, video_id)
26
27 if re.match(r"^<html><head><script[^>]*>window.location\s*=", webpage):
28 # Download again, we need a cookie
29 webpage = self._download_webpage(
30 webpage_url, video_id,
31 note=u'Downloading webpage again (with cookie)')
32
33 video_title = self._html_search_regex(
34 r'<h2(?:.*?)>\s*(.+?)\s*<', webpage, u'video title')
35
36 return {
37 'id': video_id,
38 'url': "rtmp://e%d.md.iplay.md/play" % random.randint(1, 16),
39 'play_path': "mp4:%s.f4v" % video_id,
40 'page_url': "http://videopremium.tv/" + video_id,
41 'player_url': "http://videopremium.tv/uplayer/uppod.swf",
42 'ext': 'f4v',
43 'title': video_title,
44 }