]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/pornez.py
[ie/box] Fix formats extraction (#8649)
[yt-dlp.git] / yt_dlp / extractor / pornez.py
CommitLineData
768145d4 1from .common import InfoExtractor
cbdf9408 2from ..utils import (
3 clean_html,
4 int_or_none,
5 get_element_by_class,
6 urljoin,
7)
768145d4
ML
8
9
10class PornezIE(InfoExtractor):
cbdf9408 11 _VALID_URL = r'https?://(?:www\.)?pornez\.net/(?:video(?P<id>\w+)|watch)/'
12 _TESTS = [{
768145d4 13 'url': 'https://pornez.net/video344819/mistresst-funny_penis_names-wmv/',
768145d4
ML
14 'info_dict': {
15 'id': '344819',
16 'ext': 'mp4',
cbdf9408 17 'title': 'mistresst funny_penis_names wmv',
768145d4
ML
18 'thumbnail': r're:^https?://.*\.jpg$',
19 'age_limit': 18,
cbdf9408 20 },
21 'params': {'skip_download': 'm3u8'},
22 }, {
23 'url': 'https://pornez.net/watch/leana+lovings+stiff+for+stepdaughter/',
24 'info_dict': {
25 'id': '156161',
26 'ext': 'mp4',
27 'title': 'Watch leana lovings stiff for stepdaughter porn video.',
28 'age_limit': 18,
29 },
30 'params': {'skip_download': 'm3u8'},
31 }, {
32 'url': 'https://pornez.net/videovzs27fj/tutor4k-e14-blue-wave-1080p-nbq-tutor4k-e14-blue-wave/',
33 'only_matching': True,
34 }]
768145d4
ML
35
36 def _real_extract(self, url):
37 video_id = self._match_id(url)
38 webpage = self._download_webpage(url, video_id)
cbdf9408 39 if not video_id:
40 video_id = self._search_regex(
41 r'<link[^>]+\bhref=["\']https?://pornez.net/\?p=(\w+)["\']', webpage, 'id')
42
43 iframe_src = self._html_search_regex(r'<iframe[^>]+src="([^"]+)"', webpage, 'iframe')
44 iframe = self._download_webpage(urljoin('https://pornez.net', iframe_src), video_id)
45
46 entries = self._parse_html5_media_entries(iframe_src, iframe, video_id)[0]
47 for fmt in entries['formats']:
48 height = self._search_regex(r'_(\d+)\.m3u8', fmt['url'], 'height')
49 fmt['format_id'] = '%sp' % height
50 fmt['height'] = int_or_none(height)
768145d4
ML
51
52 entries.update({
53 'id': video_id,
cbdf9408 54 'title': (clean_html(get_element_by_class('video-title', webpage))
55 or self._html_search_meta(
56 ['twitter:title', 'og:title', 'description'], webpage, 'title', default=None)),
57 'thumbnail': self._html_search_meta(['thumbnailUrl'], webpage, 'thumb', default=None),
58 'age_limit': 18,
768145d4
ML
59 })
60 return entries