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.

45 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. u'skip': u'Test file has been deleted.',
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. video_id = mobj.group('id')
  20. webpage_url = 'http://videopremium.tv/' + video_id
  21. webpage = self._download_webpage(webpage_url, video_id)
  22. if re.match(r"^<html><head><script[^>]*>window.location\s*=", webpage):
  23. # Download again, we need a cookie
  24. webpage = self._download_webpage(
  25. webpage_url, video_id,
  26. note=u'Downloading webpage again (with cookie)')
  27. video_title = self._html_search_regex(
  28. r'<h2(?:.*?)>\s*(.+?)\s*<', webpage, u'video title')
  29. return {
  30. 'id': video_id,
  31. 'url': "rtmp://e%d.md.iplay.md/play" % random.randint(1, 16),
  32. 'play_path': "mp4:%s.f4v" % video_id,
  33. 'page_url': "http://videopremium.tv/" + video_id,
  34. 'player_url': "http://videopremium.tv/uplayer/uppod.swf",
  35. 'ext': 'f4v',
  36. 'title': video_title,
  37. }