]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/yourporn.py
[ie/asobistage] Add extractor (#8735)
[yt-dlp.git] / yt_dlp / extractor / yourporn.py
1 from .common import InfoExtractor
2 from ..compat import compat_str
3 from ..utils import (
4 parse_duration,
5 urljoin,
6 )
7
8
9 class YourPornIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?sxyprn\.com/post/(?P<id>[^/?#&.]+)'
11 _TESTS = [{
12 'url': 'https://sxyprn.com/post/57ffcb2e1179b.html',
13 'md5': '6f8682b6464033d87acaa7a8ff0c092e',
14 'info_dict': {
15 'id': '57ffcb2e1179b',
16 'ext': 'mp4',
17 'title': 'md5:c9f43630bd968267672651ba905a7d35',
18 'thumbnail': r're:^https?://.*\.jpg$',
19 'duration': 165,
20 'age_limit': 18,
21 },
22 'params': {
23 'skip_download': True,
24 },
25 }, {
26 'url': 'https://sxyprn.com/post/57ffcb2e1179b.html',
27 'only_matching': True,
28 }]
29
30 def _real_extract(self, url):
31 video_id = self._match_id(url)
32
33 webpage = self._download_webpage(url, video_id)
34
35 parts = self._parse_json(
36 self._search_regex(
37 r'data-vnfo=(["\'])(?P<data>{.+?})\1', webpage, 'data info',
38 group='data'),
39 video_id)[video_id].split('/')
40
41 num = 0
42 for c in parts[6] + parts[7]:
43 if c.isnumeric():
44 num += int(c)
45 parts[5] = compat_str(int(parts[5]) - num)
46 parts[1] += '8'
47 video_url = urljoin(url, '/'.join(parts))
48
49 title = (self._search_regex(
50 r'<[^>]+\bclass=["\']PostEditTA[^>]+>([^<]+)', webpage, 'title',
51 default=None) or self._og_search_description(webpage)).strip()
52 thumbnail = self._og_search_thumbnail(webpage)
53 duration = parse_duration(self._search_regex(
54 r'duration\s*:\s*<[^>]+>([\d:]+)', webpage, 'duration',
55 default=None))
56
57 return {
58 'id': video_id,
59 'url': video_url,
60 'title': title,
61 'thumbnail': thumbnail,
62 'duration': duration,
63 'age_limit': 18,
64 'ext': 'mp4',
65 }