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