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