]>
Commit | Line | Data |
---|---|---|
5537dce8 | 1 | from .common import InfoExtractor |
b42a2a72 S |
2 | from ..utils import ( |
3 | ExtractorError, | |
4 | parse_duration, | |
5 | ) | |
6 | ||
5537dce8 DF |
7 | |
8 | class MojvideoIE(InfoExtractor): | |
b42a2a72 | 9 | _VALID_URL = r'https?://(?:www\.)?mojvideo\.com/video-(?P<display_id>[^/]+)/(?P<id>[a-f0-9]+)' |
5537dce8 DF |
10 | _TEST = { |
11 | 'url': 'http://www.mojvideo.com/video-v-avtu-pred-mano-rdecelaska-alfi-nipic/3d1ed4497707730b2906', | |
12 | 'md5': 'f7fd662cc8ce2be107b0d4f2c0483ae7', | |
13 | 'info_dict': { | |
14 | 'id': '3d1ed4497707730b2906', | |
b42a2a72 | 15 | 'display_id': 'v-avtu-pred-mano-rdecelaska-alfi-nipic', |
5537dce8 DF |
16 | 'ext': 'mp4', |
17 | 'title': 'V avtu pred mano rdečelaska - Alfi Nipič', | |
ec85ded8 | 18 | 'thumbnail': r're:^http://.*\.jpg$', |
b42a2a72 | 19 | 'duration': 242, |
5537dce8 DF |
20 | } |
21 | } | |
22 | ||
23 | def _real_extract(self, url): | |
5ad28e7f | 24 | mobj = self._match_valid_url(url) |
5537dce8 | 25 | video_id = mobj.group('id') |
b42a2a72 S |
26 | display_id = mobj.group('display_id') |
27 | ||
28 | # XML is malformed | |
29 | playerapi = self._download_webpage( | |
30 | 'http://www.mojvideo.com/playerapi.php?v=%s&t=1' % video_id, display_id) | |
5537dce8 | 31 | |
b42a2a72 S |
32 | if '<error>true</error>' in playerapi: |
33 | error_desc = self._html_search_regex( | |
34 | r'<errordesc>([^<]*)</errordesc>', playerapi, 'error description', fatal=False) | |
35 | raise ExtractorError('%s said: %s' % (self.IE_NAME, error_desc), expected=True) | |
36 | ||
04f3fd2c | 37 | title = self._html_extract_title(playerapi) |
b42a2a72 S |
38 | video_url = self._html_search_regex( |
39 | r'<file>([^<]+)</file>', playerapi, 'video URL') | |
40 | thumbnail = self._html_search_regex( | |
41 | r'<preview>([^<]+)</preview>', playerapi, 'thumbnail', fatal=False) | |
42 | duration = parse_duration(self._html_search_regex( | |
43 | r'<duration>([^<]+)</duration>', playerapi, 'duration', fatal=False)) | |
5537dce8 DF |
44 | |
45 | return { | |
46 | 'id': video_id, | |
b42a2a72 S |
47 | 'display_id': display_id, |
48 | 'url': video_url, | |
5537dce8 | 49 | 'title': title, |
b42a2a72 S |
50 | 'thumbnail': thumbnail, |
51 | 'duration': duration, | |
5f6a1245 | 52 | } |