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.

57 lines
1.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. compat_urllib_parse,
  7. remove_start,
  8. )
  9. class VideoMegaIE(InfoExtractor):
  10. _VALID_URL = r'''(?x)https?://
  11. (?:www\.)?videomega\.tv/
  12. (?:iframe\.php)?\?ref=(?P<id>[A-Za-z0-9]+)
  13. '''
  14. _TEST = {
  15. 'url': 'http://videomega.tv/?ref=GKeGPVedBe',
  16. 'md5': '240fb5bcf9199961f48eb17839b084d6',
  17. 'info_dict': {
  18. 'id': 'GKeGPVedBe',
  19. 'ext': 'mp4',
  20. 'title': 'XXL - All Sports United',
  21. 'thumbnail': 're:^https?://.*\.jpg$',
  22. }
  23. }
  24. def _real_extract(self, url):
  25. mobj = re.match(self._VALID_URL, url)
  26. video_id = mobj.group('id')
  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. }