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.

51 lines
1.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..compat import compat_urllib_request
  6. class VideoMegaIE(InfoExtractor):
  7. _VALID_URL = r'''(?x)https?://
  8. (?:www\.)?videomega\.tv/
  9. (?:iframe\.php|cdn\.php)?\?ref=(?P<id>[A-Za-z0-9]+)
  10. '''
  11. _TEST = {
  12. 'url': 'http://videomega.tv/?ref=4GNA688SU99US886ANG4',
  13. 'md5': 'bf5c2f95c4c917536e80936af7bc51e1',
  14. 'info_dict': {
  15. 'id': '4GNA688SU99US886ANG4',
  16. 'ext': 'mp4',
  17. 'title': 'BigBuckBunny_320x180',
  18. 'thumbnail': 're:^https?://.*\.jpg$',
  19. }
  20. }
  21. def _real_extract(self, url):
  22. video_id = self._match_id(url)
  23. iframe_url = 'http://videomega.tv/cdn.php?ref=%s' % video_id
  24. req = compat_urllib_request.Request(iframe_url)
  25. req.add_header('Referer', url)
  26. webpage = self._download_webpage(req, video_id)
  27. title = self._html_search_regex(
  28. r'<title>(.*?)</title>', webpage, 'title')
  29. title = re.sub(
  30. r'(?:^[Vv]ideo[Mm]ega\.tv\s-\s?|\s?-\svideomega\.tv$)', '', title)
  31. thumbnail = self._search_regex(
  32. r'<video[^>]+?poster="([^"]+)"', webpage, 'thumbnail', fatal=False)
  33. video_url = self._search_regex(
  34. r'<source[^>]+?src="([^"]+)"', webpage, 'video URL')
  35. return {
  36. 'id': video_id,
  37. 'title': title,
  38. 'url': video_url,
  39. 'thumbnail': thumbnail,
  40. 'http_headers': {
  41. 'Referer': iframe_url,
  42. },
  43. }