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