]>
Commit | Line | Data |
---|---|---|
67abbe95 NJ |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
67abbe95 | 4 | from .common import InfoExtractor |
1cc79574 | 5 | from ..compat import ( |
67abbe95 | 6 | compat_urllib_parse, |
1cc79574 PH |
7 | ) |
8 | from ..utils import ( | |
67abbe95 NJ |
9 | remove_start, |
10 | ) | |
11 | ||
12 | ||
13 | class VideoMegaIE(InfoExtractor): | |
14 | _VALID_URL = r'''(?x)https?:// | |
15 | (?:www\.)?videomega\.tv/ | |
16 | (?:iframe\.php)?\?ref=(?P<id>[A-Za-z0-9]+) | |
17 | ''' | |
18 | _TEST = { | |
19 | 'url': 'http://videomega.tv/?ref=GKeGPVedBe', | |
20 | 'md5': '240fb5bcf9199961f48eb17839b084d6', | |
21 | 'info_dict': { | |
22 | 'id': 'GKeGPVedBe', | |
23 | 'ext': 'mp4', | |
24 | 'title': 'XXL - All Sports United', | |
25 | 'thumbnail': 're:^https?://.*\.jpg$', | |
26 | } | |
27 | } | |
28 | ||
29 | def _real_extract(self, url): | |
1cc79574 | 30 | video_id = self._match_id(url) |
67abbe95 NJ |
31 | url = 'http://videomega.tv/iframe.php?ref={0:}'.format(video_id) |
32 | webpage = self._download_webpage(url, video_id) | |
33 | ||
34 | escaped_data = self._search_regex( | |
0e59b9ff | 35 | r'unescape\("([^"]+)"\)', webpage, 'escaped data') |
67abbe95 NJ |
36 | playlist = compat_urllib_parse.unquote(escaped_data) |
37 | ||
38 | thumbnail = self._search_regex( | |
39 | r'image:\s*"([^"]+)"', playlist, 'thumbnail', fatal=False) | |
40 | url = self._search_regex(r'file:\s*"([^"]+)"', playlist, 'URL') | |
0e59b9ff PH |
41 | title = remove_start(self._html_search_regex( |
42 | r'<title>(.*?)</title>', webpage, 'title'), 'VideoMega.tv - ') | |
67abbe95 | 43 | |
0e59b9ff | 44 | formats = [{ |
67abbe95 NJ |
45 | 'format_id': 'sd', |
46 | 'url': url, | |
0e59b9ff PH |
47 | }] |
48 | self._sort_formats(formats) | |
67abbe95 NJ |
49 | |
50 | return { | |
51 | 'id': video_id, | |
52 | 'title': title, | |
53 | 'formats': formats, | |
54 | 'thumbnail': thumbnail, | |
55 | } |