videopremium.py 1.5 KB

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