]>
Commit | Line | Data |
---|---|---|
fec2d97c JB |
1 | # encoding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
31f22400 S |
4 | import re |
5 | ||
fec2d97c JB |
6 | from .common import InfoExtractor |
7 | from ..utils import ( | |
6e218b3f | 8 | ExtractorError, |
31f22400 S |
9 | float_or_none, |
10 | xpath_text, | |
fec2d97c JB |
11 | ) |
12 | ||
13 | ||
cc9b9df0 | 14 | class MegaVideozIE(InfoExtractor): |
31f22400 S |
15 | _VALID_URL = r'https?://(?:www\.)?megavideoz\.eu/video/(?P<id>[^/]+)(?:/(?P<display_id>[^/]+))?' |
16 | _TEST = { | |
17 | 'url': 'http://megavideoz.eu/video/WM6UB919XMXH/SMPTE-Universal-Film-Leader', | |
18 | 'info_dict': { | |
19 | 'id': '48723', | |
20 | 'display_id': 'SMPTE-Universal-Film-Leader', | |
21 | 'ext': 'mp4', | |
22 | 'title': 'SMPTE Universal Film Leader', | |
23 | 'thumbnail': 're:https?://.*?\.jpg', | |
24 | 'duration': 10.93, | |
f32cb5cb | 25 | } |
31f22400 | 26 | } |
fec2d97c JB |
27 | |
28 | def _real_extract(self, url): | |
31f22400 S |
29 | mobj = re.match(self._VALID_URL, url) |
30 | video_id = mobj.group('id') | |
31 | display_id = mobj.group('display_id') or video_id | |
fec2d97c | 32 | |
31f22400 | 33 | webpage = self._download_webpage(url, display_id) |
fec2d97c | 34 | |
163965d8 | 35 | if any(p in webpage for p in ('>Video Not Found<', '>404 Error<')): |
6e218b3f S |
36 | raise ExtractorError('Video %s does not exist' % video_id, expected=True) |
37 | ||
31f22400 S |
38 | config = self._download_xml( |
39 | self._search_regex( | |
40 | r"var\s+cnf\s*=\s*'([^']+)'", webpage, 'cnf url'), | |
41 | display_id) | |
fec2d97c | 42 | |
31f22400 S |
43 | video_url = xpath_text(config, './file', 'video url', fatal=True) |
44 | title = xpath_text(config, './title', 'title', fatal=True) | |
45 | thumbnail = xpath_text(config, './image', 'thumbnail') | |
46 | duration = float_or_none(xpath_text(config, './duration', 'duration')) | |
47 | video_id = xpath_text(config, './mediaid', 'video id') or video_id | |
fec2d97c JB |
48 | |
49 | return { | |
50 | 'id': video_id, | |
31f22400 | 51 | 'display_id': display_id, |
fec2d97c JB |
52 | 'url': video_url, |
53 | 'title': title, | |
31f22400 | 54 | 'thumbnail': thumbnail, |
fec2d97c JB |
55 | 'duration': duration |
56 | } |