]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cliphunter.py
ab651d1c8632fe08c29d44334cb4ba4a6ea2fddf
[youtubedl] / youtube_dl / extractor / cliphunter.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..utils import int_or_none
5
6
7 _translation_table = {
8 'a': 'h', 'd': 'e', 'e': 'v', 'f': 'o', 'g': 'f', 'i': 'd', 'l': 'n',
9 'm': 'a', 'n': 'm', 'p': 'u', 'q': 't', 'r': 's', 'v': 'p', 'x': 'r',
10 'y': 'l', 'z': 'i',
11 '$': ':', '&': '.', '(': '=', '^': '&', '=': '/',
12 }
13
14
15 def _decode(s):
16 return ''.join(_translation_table.get(c, c) for c in s)
17
18
19 class CliphunterIE(InfoExtractor):
20 IE_NAME = 'cliphunter'
21
22 _VALID_URL = r'''(?x)https?://(?:www\.)?cliphunter\.com/w/
23 (?P<id>[0-9]+)/
24 (?P<seo>.+?)(?:$|[#\?])
25 '''
26 _TESTS = [{
27 'url': 'http://www.cliphunter.com/w/1012420/Fun_Jynx_Maze_solo',
28 'md5': 'b7c9bbd4eb3a226ab91093714dcaa480',
29 'info_dict': {
30 'id': '1012420',
31 'ext': 'flv',
32 'title': 'Fun Jynx Maze solo',
33 'thumbnail': r're:^https?://.*\.jpg$',
34 'age_limit': 18,
35 },
36 'skip': 'Video gone',
37 }, {
38 'url': 'http://www.cliphunter.com/w/2019449/ShesNew__My_booty_girlfriend_Victoria_Paradices_pussy_filled_with_jizz',
39 'md5': '55a723c67bfc6da6b0cfa00d55da8a27',
40 'info_dict': {
41 'id': '2019449',
42 'ext': 'mp4',
43 'title': 'ShesNew - My booty girlfriend, Victoria Paradice\'s pussy filled with jizz',
44 'thumbnail': r're:^https?://.*\.jpg$',
45 'age_limit': 18,
46 },
47 }]
48
49 def _real_extract(self, url):
50 video_id = self._match_id(url)
51 webpage = self._download_webpage(url, video_id)
52
53 video_title = self._search_regex(
54 r'mediaTitle = "([^"]+)"', webpage, 'title')
55
56 gexo_files = self._parse_json(
57 self._search_regex(
58 r'var\s+gexoFiles\s*=\s*({.+?});', webpage, 'gexo files'),
59 video_id)
60
61 formats = []
62 for format_id, f in gexo_files.items():
63 video_url = f.get('url')
64 if not video_url:
65 continue
66 fmt = f.get('fmt')
67 height = f.get('h')
68 format_id = '%s_%sp' % (fmt, height) if fmt and height else format_id
69 formats.append({
70 'url': _decode(video_url),
71 'format_id': format_id,
72 'width': int_or_none(f.get('w')),
73 'height': int_or_none(height),
74 'tbr': int_or_none(f.get('br')),
75 })
76 self._sort_formats(formats)
77
78 thumbnail = self._search_regex(
79 r"var\s+mov_thumb\s*=\s*'([^']+)';",
80 webpage, 'thumbnail', fatal=False)
81
82 return {
83 'id': video_id,
84 'title': video_title,
85 'formats': formats,
86 'age_limit': self._rta_search(webpage),
87 'thumbnail': thumbnail,
88 }