[ie/dropbox] Fix password-protected video extraction (#11636)
[yt-dlp3.git] / yt_dlp / extractor / nubilesporn.py
blob47c7be61d55a63fcff06e6b137c9a4f43f09cecc
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 unified_timestamp,
14 urlencode_postdata,
16 from ..utils.traversal import find_element, find_elements, traverse_obj
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) or '',
74 'channel', fatal=False, group=('id', 'name')) or (None, None)
76 return {
77 'id': video_id,
78 'title': self._search_regex('<h2>([^<]+)</h2>', page, 'title', fatal=False),
79 'formats': media_entries.get('formats'),
80 'display_id': url_match.group('display_id'),
81 'thumbnail': media_entries.get('thumbnail'),
82 'description': clean_html(get_element_html_by_class('content-pane-description', page)),
83 'timestamp': unified_timestamp(get_element_by_class('date', page)),
84 'channel': re.sub(r'([^A-Z]+)([A-Z]+)', r'\1 \2', channel_name) if channel_name else None,
85 'channel_id': channel_id,
86 'channel_url': format_field(channel_id, None, 'https://members.nubiles-porn.com/video/website/%s'),
87 'like_count': int_or_none(get_element_by_id('likecount', page)),
88 'average_rating': float_or_none(get_element_by_class('score', page)),
89 'age_limit': 18,
90 'categories': traverse_obj(page, ({find_element(cls='categories')}, {find_elements(cls='btn')}, ..., {clean_html})),
91 'tags': traverse_obj(page, ({find_elements(cls='tags')}, 1, {find_elements(cls='btn')}, ..., {clean_html})),
92 'cast': get_elements_by_class('content-pane-performer', page),
93 'availability': 'needs_auth',
94 'series': channel_name,
95 'series_id': channel_id,
96 'season_number': int_or_none(url_match.group('season')),
97 'episode_number': int_or_none(url_match.group('episode')),