[ie/dplay] Fix extractors (#10471)
[yt-dlp3.git] / yt_dlp / extractor / nubilesporn.py
blobc2079d8b07c5cb0117611ea1e8c2b583551756d1
1 import re
3 from .common import InfoExtractor
4 from ..utils import (
5 clean_html,
6 float_or_none,
7 format_field,
8 get_element_by_class,
9 get_element_by_id,
10 get_element_html_by_class,
11 get_elements_by_class,
12 int_or_none,
13 try_call,
14 unified_timestamp,
15 urlencode_postdata,
19 class NubilesPornIE(InfoExtractor):
20 _NETRC_MACHINE = 'nubiles-porn'
21 _VALID_URL = r'''(?x)
22 https://members\.nubiles-porn\.com/video/watch/(?P<id>\d+)
23 (?:/(?P<display_id>[\w\-]+-s(?P<season>\d+)e(?P<episode>\d+)))?
24 '''
26 _TESTS = [{
27 'url': 'https://members.nubiles-porn.com/video/watch/165320/trying-to-focus-my-one-track-mind-s3e1',
28 'md5': 'fa7f09da8027c35e4bdf0f94f55eac82',
29 'info_dict': {
30 'id': '165320',
31 'title': 'Trying To Focus My One Track Mind - S3:E1',
32 'ext': 'mp4',
33 'display_id': 'trying-to-focus-my-one-track-mind-s3e1',
34 'thumbnail': 'https://images.nubiles-porn.com/videos/trying_to_focus_my_one_track_mind/samples/cover1280.jpg',
35 'description': 'md5:81f3d4372e0e39bff5c801da277a5141',
36 'timestamp': 1676160000,
37 'upload_date': '20230212',
38 'channel': 'Younger Mommy',
39 'channel_id': '64',
40 'channel_url': 'https://members.nubiles-porn.com/video/website/64',
41 'like_count': int,
42 'average_rating': float,
43 'age_limit': 18,
44 'categories': ['Big Boobs', 'Big Naturals', 'Blowjob', 'Brunette', 'Cowgirl', 'Girl Orgasm', 'Girl-Boy',
45 'Glasses', 'Hardcore', 'Milf', 'Shaved Pussy', 'Tattoos', 'YoungerMommy.com'],
46 'tags': list,
47 'cast': ['Kenzie Love'],
48 'availability': 'needs_auth',
49 'series': 'Younger Mommy',
50 'series_id': '64',
51 'season': 'Season 3',
52 'season_number': 3,
53 'episode': 'Episode 1',
54 'episode_number': 1,
58 def _perform_login(self, username, password):
59 login_webpage = self._download_webpage('https://nubiles-porn.com/login', video_id=None)
60 inputs = self._hidden_inputs(login_webpage)
61 inputs.update({'username': username, 'password': password})
62 self._request_webpage('https://nubiles-porn.com/authentication/login', None, data=urlencode_postdata(inputs))
64 def _real_extract(self, url):
65 url_match = self._match_valid_url(url)
66 video_id = url_match.group('id')
67 page = self._download_webpage(url, video_id)
69 media_entries = self._parse_html5_media_entries(
70 url, get_element_by_class('watch-page-video-wrapper', page), video_id)[0]
72 channel_id, channel_name = self._search_regex(
73 r'/video/website/(?P<id>\d+).+>(?P<name>\w+).com', get_element_html_by_class('site-link', page),
74 'channel', fatal=False, group=('id', 'name')) or (None, None)
75 channel_name = re.sub(r'([^A-Z]+)([A-Z]+)', r'\1 \2', channel_name)
77 return {
78 'id': video_id,
79 'title': self._search_regex('<h2>([^<]+)</h2>', page, 'title', fatal=False),
80 'formats': media_entries.get('formats'),
81 'display_id': url_match.group('display_id'),
82 'thumbnail': media_entries.get('thumbnail'),
83 'description': clean_html(get_element_html_by_class('content-pane-description', page)),
84 'timestamp': unified_timestamp(get_element_by_class('date', page)),
85 'channel': channel_name,
86 'channel_id': channel_id,
87 'channel_url': format_field(channel_id, None, 'https://members.nubiles-porn.com/video/website/%s'),
88 'like_count': int_or_none(get_element_by_id('likecount', page)),
89 'average_rating': float_or_none(get_element_by_class('score', page)),
90 'age_limit': 18,
91 'categories': try_call(lambda: list(map(clean_html, get_elements_by_class('btn', get_element_by_class('categories', page))))),
92 'tags': try_call(lambda: list(map(clean_html, get_elements_by_class('btn', get_elements_by_class('tags', page)[1])))),
93 'cast': get_elements_by_class('content-pane-performer', page),
94 'availability': 'needs_auth',
95 'series': channel_name,
96 'series_id': channel_id,
97 'season_number': int_or_none(url_match.group('season')),
98 'episode_number': int_or_none(url_match.group('episode')),