You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.5 KiB

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