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'''(?x)https?://
12 (?:www\.)?videomega\.tv/
13 (?:iframe\.php|cdn\.php)?\?ref=(?P<id>[A-Za-z0-9]+)
16 'url': 'http://videomega.tv/?ref=4GNA688SU99US886ANG4',
17 'md5': 'bf5c2f95c4c917536e80936af7bc51e1',
19 'id': '4GNA688SU99US886ANG4',
21 'title': 'BigBuckBunny_320x180',
22 'thumbnail': 're:^https?://.*\.jpg$',
26 def _real_extract(self, url):
27 video_id = self._match_id(url)
29 iframe_url = 'http://videomega.tv/cdn.php?ref=%s' % video_id
30 req = compat_urllib_request.Request(iframe_url)
31 req.add_header('Referer', url)
32 webpage = self._download_webpage(req, video_id)
34 title = self._html_search_regex(
35 r'<title>(.*?)</title>', webpage, 'title')
37 r'(?:^[Vv]ideo[Mm]ega\.tv\s-\s?|\s?-\svideomega\.tv$)', '', title)
38 thumbnail = self._search_regex(
39 r'<video[^>]+?poster="([^"]+)"', webpage, 'thumbnail', fatal=False)
40 video_url = self._search_regex(
41 r'<source[^>]+?src="([^"]+)"', webpage, 'video URL')
47 'thumbnail': thumbnail,
49 'Referer': iframe_url,