]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/cliphunter.py
[extractor] Deprecate `_sort_formats`
[yt-dlp.git] / yt_dlp / extractor / cliphunter.py
1 from .common import InfoExtractor
2 from ..utils import (
3 int_or_none,
4 url_or_none,
5 )
6
7
8 class CliphunterIE(InfoExtractor):
9 IE_NAME = 'cliphunter'
10
11 _VALID_URL = r'''(?x)https?://(?:www\.)?cliphunter\.com/w/
12 (?P<id>[0-9]+)/
13 (?P<seo>.+?)(?:$|[#\?])
14 '''
15 _TESTS = [{
16 'url': 'http://www.cliphunter.com/w/1012420/Fun_Jynx_Maze_solo',
17 'md5': 'b7c9bbd4eb3a226ab91093714dcaa480',
18 'info_dict': {
19 'id': '1012420',
20 'ext': 'flv',
21 'title': 'Fun Jynx Maze solo',
22 'thumbnail': r're:^https?://.*\.jpg$',
23 'age_limit': 18,
24 },
25 'skip': 'Video gone',
26 }, {
27 'url': 'http://www.cliphunter.com/w/2019449/ShesNew__My_booty_girlfriend_Victoria_Paradices_pussy_filled_with_jizz',
28 'md5': '55a723c67bfc6da6b0cfa00d55da8a27',
29 'info_dict': {
30 'id': '2019449',
31 'ext': 'mp4',
32 'title': 'ShesNew - My booty girlfriend, Victoria Paradice\'s pussy filled with jizz',
33 'thumbnail': r're:^https?://.*\.jpg$',
34 'age_limit': 18,
35 },
36 }]
37
38 def _real_extract(self, url):
39 video_id = self._match_id(url)
40 webpage = self._download_webpage(url, video_id)
41
42 video_title = self._search_regex(
43 r'mediaTitle = "([^"]+)"', webpage, 'title')
44
45 gexo_files = self._parse_json(
46 self._search_regex(
47 r'var\s+gexoFiles\s*=\s*({.+?});', webpage, 'gexo files'),
48 video_id)
49
50 formats = []
51 for format_id, f in gexo_files.items():
52 video_url = url_or_none(f.get('url'))
53 if not video_url:
54 continue
55 fmt = f.get('fmt')
56 height = f.get('h')
57 format_id = '%s_%sp' % (fmt, height) if fmt and height else format_id
58 formats.append({
59 'url': video_url,
60 'format_id': format_id,
61 'width': int_or_none(f.get('w')),
62 'height': int_or_none(height),
63 'tbr': int_or_none(f.get('br')),
64 })
65
66 thumbnail = self._search_regex(
67 r"var\s+mov_thumb\s*=\s*'([^']+)';",
68 webpage, 'thumbnail', fatal=False)
69
70 return {
71 'id': video_id,
72 'title': video_title,
73 'formats': formats,
74 'age_limit': self._rta_search(webpage),
75 'thumbnail': thumbnail,
76 }