videomega.py 1.9 KB

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