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