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.

46 lines
1.5 KiB

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