2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..compat import compat_urllib_request
10 class VideoMegaIE(InfoExtractor):
11 _VALID_URL = r'(?:videomega:|https?://(?:www\.)?videomega\.tv/(?:(?:view|iframe|cdn)\.php)?\?ref=)(?P<id>[A-Za-z0-9]+)'
13 'url': 'http://videomega.tv/cdn.php?ref=AOSQBJYKIDDIKYJBQSOA',
14 'md5': 'cc1920a58add3f05c6a93285b84fb3aa',
16 'id': 'AOSQBJYKIDDIKYJBQSOA',
19 'thumbnail': 're:^https?://.*\.jpg$',
22 'url': 'http://videomega.tv/cdn.php?ref=AOSQBJYKIDDIKYJBQSOA&width=1070&height=600',
23 'only_matching': True,
25 'url': 'http://videomega.tv/view.php?ref=090051111052065112106089103052052103089106112065052111051090',
26 'only_matching': True,
29 def _real_extract(self, url):
30 video_id = self._match_id(url)
32 iframe_url = 'http://videomega.tv/cdn.php?ref=%s' % video_id
33 req = compat_urllib_request.Request(iframe_url)
34 req.add_header('Referer', url)
35 req.add_header('Cookie', 'noadvtday=0')
36 webpage = self._download_webpage(req, video_id)
38 title = self._html_search_regex(
39 r'<title>(.+?)</title>', webpage, 'title')
41 r'(?:^[Vv]ideo[Mm]ega\.tv\s-\s*|\s*-\svideomega\.tv$)', '', title)
42 thumbnail = self._search_regex(
43 r'<video[^>]+?poster="([^"]+)"', webpage, 'thumbnail', fatal=False)
44 video_url = self._search_regex(
45 r'<source[^>]+?src="([^"]+)"', webpage, 'video URL')
51 'thumbnail': thumbnail,
53 'Referer': iframe_url,