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