]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/yourporn.py
[ChangeLog] Actualize
[youtube-dl.git] / youtube_dl / extractor / yourporn.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..compat import compat_str
5 from ..utils import (
6     parse_duration,
7     urljoin,
8 )
9
10
11 class YourPornIE(InfoExtractor):
12     _VALID_URL = r'https?://(?:www\.)?sxyprn\.com/post/(?P<id>[^/?#&.]+)'
13     _TESTS = [{
14         'url': 'https://sxyprn.com/post/57ffcb2e1179b.html',
15         'md5': '6f8682b6464033d87acaa7a8ff0c092e',
16         'info_dict': {
17             'id': '57ffcb2e1179b',
18             'ext': 'mp4',
19             'title': 'md5:c9f43630bd968267672651ba905a7d35',
20             'thumbnail': r're:^https?://.*\.jpg$',
21             'duration': 165,
22             'age_limit': 18,
23         },
24         'params': {
25             'skip_download': True,
26         },
27     }, {
28         'url': 'https://sxyprn.com/post/57ffcb2e1179b.html',
29         'only_matching': True,
30     }]
31
32     def _real_extract(self, url):
33         video_id = self._match_id(url)
34
35         webpage = self._download_webpage(url, video_id)
36
37         parts = self._parse_json(
38             self._search_regex(
39                 r'data-vnfo=(["\'])(?P<data>{.+?})\1', webpage, 'data info',
40                 group='data'),
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))
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)
55         duration = parse_duration(self._search_regex(
56             r'duration\s*:\s*<[^>]+>([\d:]+)', webpage, 'duration',
57             default=None))
58
59         return {
60             'id': video_id,
61             'url': video_url,
62             'title': title,
63             'thumbnail': thumbnail,
64             'duration': duration,
65             'age_limit': 18,
66             'ext': 'mp4',
67         }