]>
Commit | Line | Data |
---|---|---|
efc86777 PH |
1 | from __future__ import unicode_literals |
2 | ||
008af866 P |
3 | import re |
4 | import string | |
5 | ||
6 | from .common import InfoExtractor | |
7 | from ..utils import ( | |
008af866 P |
8 | ExtractorError, |
9 | ) | |
10 | ||
b6d3a996 PH |
11 | translation_table = { |
12 | 'a': 'h', 'd': 'e', 'e': 'v', 'f': 'o', 'g': 'f', 'i': 'd', 'l': 'n', | |
13 | 'm': 'a', 'n': 'm', 'p': 'u', 'q': 't', 'r': 's', 'v': 'p', 'x': 'r', | |
14 | 'y': 'l', 'z': 'i', | |
15 | '$': ':', '&': '.', '(': '=', '^': '&', '=': '/', | |
16 | } | |
008af866 P |
17 | |
18 | ||
19 | class CliphunterIE(InfoExtractor): | |
efc86777 | 20 | IE_NAME = 'cliphunter' |
008af866 | 21 | |
b6d3a996 PH |
22 | _VALID_URL = r'''(?x)http://(?:www\.)?cliphunter\.com/w/ |
23 | (?P<id>[0-9]+)/ | |
24 | (?P<seo>.+?)(?:$|[#\?]) | |
25 | ''' | |
26 | _TEST = { | |
efc86777 PH |
27 | 'url': 'http://www.cliphunter.com/w/1012420/Fun_Jynx_Maze_solo', |
28 | 'file': '1012420.flv', | |
29 | 'md5': '15e7740f30428abf70f4223478dc1225', | |
30 | 'info_dict': { | |
31 | 'title': 'Fun Jynx Maze solo', | |
008af866 | 32 | } |
efc86777 | 33 | } |
008af866 P |
34 | |
35 | def _real_extract(self, url): | |
36 | mobj = re.match(self._VALID_URL, url) | |
008af866 P |
37 | video_id = mobj.group('id') |
38 | ||
39 | webpage = self._download_webpage(url, video_id) | |
40 | ||
b6d3a996 PH |
41 | pl_fiji = self._search_regex( |
42 | r'pl_fiji = \'([^\']+)\'', webpage, 'video data') | |
43 | pl_c_qual = self._search_regex( | |
44 | r'pl_c_qual = "(.)"', webpage, 'video quality') | |
45 | video_title = self._search_regex( | |
46 | r'mediaTitle = "([^"]+)"', webpage, 'title') | |
008af866 | 47 | |
b6d3a996 | 48 | video_url = ''.join(translation_table.get(c, c) for c in pl_fiji) |
008af866 P |
49 | |
50 | formats = [{ | |
51 | 'url': video_url, | |
008af866 P |
52 | 'format_id': pl_c_qual, |
53 | }] | |
54 | ||
55 | return { | |
56 | 'id': video_id, | |
57 | 'title': video_title, | |
58 | 'formats': formats, | |
008af866 | 59 | } |