]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/peekvids.py
[cleanup] Upgrade syntax
[yt-dlp.git] / yt_dlp / extractor / peekvids.py
1 from .common import InfoExtractor
2
3
4 class PeekVidsIE(InfoExtractor):
5 _VALID_URL = r'''(?x)
6 https?://(?:www\.)?peekvids\.com/
7 (?:(?:[^/?#]+/){2}|embed/?\?(?:[^#]*&)?v=)
8 (?P<id>[^/?&#]*)
9 '''
10 _TESTS = [{
11 'url': 'https://peekvids.com/pc/dane-jones-cute-redhead-with-perfect-tits-with-mini-vamp/BSyLMbN0YCd',
12 'md5': 'a00940646c428e232407e3e62f0e8ef5',
13 'info_dict': {
14 'id': 'BSyLMbN0YCd',
15 'title': ' Dane Jones - Cute redhead with perfect tits with Mini Vamp, SEXYhub',
16 'ext': 'mp4',
17 'thumbnail': r're:^https?://.*\.jpg$',
18 'description': 'Watch Dane Jones - Cute redhead with perfect tits with Mini Vamp (7 min), uploaded by SEXYhub.com',
19 'timestamp': 1642579329,
20 'upload_date': '20220119',
21 'duration': 416,
22 'view_count': int,
23 'age_limit': 18,
24 },
25 }]
26 _DOMAIN = 'www.peekvids.com'
27
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
30 webpage = self._download_webpage(url, video_id)
31
32 short_video_id = self._html_search_regex(r'<video [^>]*data-id="(.+?)"', webpage, 'short video ID')
33 srcs = self._download_json(
34 f'https://{self._DOMAIN}/v-alt/{short_video_id}', video_id,
35 note='Downloading list of source files')
36 formats = [{
37 'url': url,
38 'ext': 'mp4',
39 'format_id': name[8:],
40 } for name, url in srcs.items() if len(name) > 8 and name.startswith('data-src')]
41 if not formats:
42 formats = [{'url': url} for url in srcs.values()]
43 self._sort_formats(formats)
44
45 info = self._search_json_ld(webpage, video_id, expected_type='VideoObject')
46 info.update({
47 'id': video_id,
48 'age_limit': 18,
49 'formats': formats,
50 })
51 return info
52
53
54 class PlayVidsIE(PeekVidsIE):
55 _VALID_URL = r'https?://(?:www\.)?playvids\.com/(?:embed/|[^/]{2}/)?(?P<id>[^/?#]*)'
56 _TESTS = [{
57 'url': 'https://www.playvids.com/U3pBrYhsjXM/pc/dane-jones-cute-redhead-with-perfect-tits-with-mini-vamp',
58 'md5': 'cd7dfd8a2e815a45402369c76e3c1825',
59 'info_dict': {
60 'id': 'U3pBrYhsjXM',
61 'title': ' Dane Jones - Cute redhead with perfect tits with Mini Vamp, SEXYhub',
62 'ext': 'mp4',
63 'thumbnail': r're:^https?://.*\.jpg$',
64 'description': 'Watch Dane Jones - Cute redhead with perfect tits with Mini Vamp video in HD, uploaded by SEXYhub.com',
65 'timestamp': 1640435839,
66 'upload_date': '20211225',
67 'duration': 416,
68 'view_count': int,
69 'age_limit': 18,
70 },
71 }, {
72 'url': 'https://www.playvids.com/es/U3pBrYhsjXM/pc/dane-jones-cute-redhead-with-perfect-tits-with-mini-vamp',
73 'only_matching': True,
74 }, {
75 'url': 'https://www.playvids.com/embed/U3pBrYhsjXM',
76 'only_matching': True,
77 }]
78 _DOMAIN = 'www.playvids.com'