]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cliphunter.py
debian/changelog: Start new release.
[youtubedl] / youtube_dl / extractor / cliphunter.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7
8 translation_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 }
14
15
16 class CliphunterIE(InfoExtractor):
17 IE_NAME = 'cliphunter'
18
19 _VALID_URL = r'''(?x)http://(?:www\.)?cliphunter\.com/w/
20 (?P<id>[0-9]+)/
21 (?P<seo>.+?)(?:$|[#\?])
22 '''
23 _TEST = {
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',
29 }
30 }
31
32 def _real_extract(self, url):
33 mobj = re.match(self._VALID_URL, url)
34 video_id = mobj.group('id')
35
36 webpage = self._download_webpage(url, video_id)
37
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')
44
45 video_url = ''.join(translation_table.get(c, c) for c in pl_fiji)
46
47 formats = [{
48 'url': video_url,
49 'format_id': pl_c_qual,
50 }]
51
52 return {
53 'id': video_id,
54 'title': video_title,
55 'formats': formats,
56 }