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.

55 lines
1.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import (
  5. compat_urllib_parse,
  6. )
  7. from ..utils import (
  8. remove_start,
  9. )
  10. class VideoMegaIE(InfoExtractor):
  11. _VALID_URL = r'''(?x)https?://
  12. (?:www\.)?videomega\.tv/
  13. (?:iframe\.php)?\?ref=(?P<id>[A-Za-z0-9]+)
  14. '''
  15. _TEST = {
  16. 'url': 'http://videomega.tv/?ref=GKeGPVedBe',
  17. 'md5': '240fb5bcf9199961f48eb17839b084d6',
  18. 'info_dict': {
  19. 'id': 'GKeGPVedBe',
  20. 'ext': 'mp4',
  21. 'title': 'XXL - All Sports United',
  22. 'thumbnail': 're:^https?://.*\.jpg$',
  23. }
  24. }
  25. def _real_extract(self, url):
  26. video_id = self._match_id(url)
  27. url = 'http://videomega.tv/iframe.php?ref={0:}'.format(video_id)
  28. webpage = self._download_webpage(url, video_id)
  29. escaped_data = self._search_regex(
  30. r'unescape\("([^"]+)"\)', webpage, 'escaped data')
  31. playlist = compat_urllib_parse.unquote(escaped_data)
  32. thumbnail = self._search_regex(
  33. r'image:\s*"([^"]+)"', playlist, 'thumbnail', fatal=False)
  34. url = self._search_regex(r'file:\s*"([^"]+)"', playlist, 'URL')
  35. title = remove_start(self._html_search_regex(
  36. r'<title>(.*?)</title>', webpage, 'title'), 'VideoMega.tv - ')
  37. formats = [{
  38. 'format_id': 'sd',
  39. 'url': url,
  40. }]
  41. self._sort_formats(formats)
  42. return {
  43. 'id': video_id,
  44. 'title': title,
  45. 'formats': formats,
  46. 'thumbnail': thumbnail,
  47. }