summaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/videopremium.py
blob: b9da817b071eb717ef22829d96cf6a246edfd303 (plain)
    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/(?P<id>\w+)(?:/.*)?'
    9     _TEST = {
   10         u'url': u'http://videopremium.tv/4w7oadjsf156',
   11         u'file': u'4w7oadjsf156.f4v',
   12         u'md5': u'e51e4a266aab7531c6ac06f4ffee3b0d',
   13         u'info_dict': {
   14             u"title": u"youtube-dl_test_video____a_________-BaW_jenozKc.mp4.mp4"
   15         }
   16     }
   17 
   18     def _real_extract(self, url):
   19         mobj = re.match(self._VALID_URL, url)
   20 
   21         video_id = mobj.group('id')
   22         webpage_url = 'http://videopremium.tv/' + video_id
   23         webpage = self._download_webpage(webpage_url, video_id)
   24 
   25         if re.match(r"^<html><head><script[^>]*>window.location\s*=", webpage):
   26             # Download again, we need a cookie
   27             webpage = self._download_webpage(
   28                 webpage_url, video_id,
   29                 note=u'Downloading webpage again (with cookie)')
   30 
   31         video_title = self._html_search_regex(
   32             r'<h2(?:.*?)>\s*(.+?)\s*<', webpage, u'video title')
   33 
   34         return {
   35             'id':          video_id,
   36             'url':         "rtmp://e%d.md.iplay.md/play" % random.randint(1, 16),
   37             'play_path':   "mp4:%s.f4v" % video_id,
   38             'page_url':    "http://videopremium.tv/" + video_id,
   39             'player_url':  "http://videopremium.tv/uplayer/uppod.swf",
   40             'ext':         'f4v',
   41             'title':       video_title,
   42         }

Generated by cgit