Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/nubilesporn.py (Python)

Code before:


class NubilesPornIE(InfoExtractor):
    _NETRC_MACHINE: str = 'nubiles-porn'

    _BASE_DOMAIN: str = 'nubiles-porn.com'
    _BASE_URL: str = f'https://{_BASE_DOMAIN}'
    _MEMBERS_URL = f'https://members.{_BASE_DOMAIN}'

    _VALID_URL: str = r'https://members.nubiles-porn.com/video/watch/(?P<id>\d+)/(?P<display_id>[a-z\d\-]+-(s(?P<season>\d+)e(?P<episode>\d+))$)'
    _VALID_VIDEO_URL: str = f're:https://content2a.{_BASE_DOMAIN}/exclusive/' + r'(?:[a-z_]+)/videos/(?:[a-z\d_]+).mp4\?st=(?:[\w\-]{22})&e=(?:[0-9]{10})&tr=(?:[A-Z0-9]{154})'

    _TESTS = [{
        'url': f'{_MEMBERS_URL}/video/watch/165320/trying-to-focus-my-one-track-mind-s3e1',
        'md5': 'fa7f09da8027c35e4bdf0f94f55eac82',
        'info_dict': {
            'id': '165320',
            'title': 'Trying To Focus My One Track Mind - S3:E1',
            'formats': [
                {'url': _VALID_VIDEO_URL, 'format_id': 'mp4_480_270', 'width': 480, 'height': 270},
                {'url': _VALID_VIDEO_URL, 'format_id': 'mp4_640_360', 'width': 640, 'height': 360},
                {'url': _VALID_VIDEO_URL, 'format_id': 'mp4_960_540', 'width': 960, 'height': 540},
                {'url': _VALID_VIDEO_URL, 'format_id': 'mp4_1280_720', 'width': 1280, 'height': 720},
                {'url': _VALID_VIDEO_URL, 'format_id': 'mp4_1920_1080', 'width': 1920, 'height': 1080},
                {'url': _VALID_VIDEO_URL, 'format_id': 'mp4_3840_2160', 'width': 3840, 'height': 2160}
            ],
            'ext': 'mp4',
            'display_id': 'trying-to-focus-my-one-track-mind-s3e1',
            'thumbnail': f'https://images.{_BASE_DOMAIN}/videos/trying_to_focus_my_one_track_mind/samples/cover1280.jpg',
            'description': 'md5:81f3d4372e0e39bff5c801da277a5141',
            'creator': 'NubilesPorn',
            'release_timestamp': 1676160000,
            'release_date': '20230212',
            'uploader': 'NubilesPorn',
            'uploader_url': _MEMBERS_URL,
            'timestamp': 1676160000,
            'upload_date': '20230212',
            'channel': 'Younger Mommy',
            'channel_id': 64,
            'channel_url': f'{_MEMBERS_URL}/video/website/64',
            'like_count': int,
            'average_rating': float,
            'age_limit': 18,
            'webpage_url': f'{_MEMBERS_URL}/video/watch/165320/trying-to-focus-my-one-track-mind-s3e1',
            'categories': ['Big Boobs', 'Big Naturals', 'Blowjob', 'Brunette', 'Cowgirl', 'Girl Orgasm', 'Girl-Boy',
                           'Glasses', 'Hardcore', 'Milf', 'Shaved Pussy', 'Tattoos', 'YoungerMommy.com'],
            'tags': list,
            'cast': ['Kenzie Love'],
            'availability': 'needs_auth',
            'series': 'Younger Mommy',
            'series_id': 64,

Review comment (suggestion):
Tests aren't meant to check the format URLs. You can keep the check for format metadata if u think it'll remain consistent, but it isn't needed imo

Tip: Remove all fields except ext/id and run the test. It'll tell you which fields are needed. 

Code after:
    get_element_by_id,
    get_element_html_by_class,
    get_elements_by_class,
    int_or_none,
    try_call,
    unified_timestamp,
    urlencode_postdata,
)


class NubilesPornIE(InfoExtractor):
    _NETRC_MACHINE = 'nubiles-porn'
    _VALID_URL = r'''(?x)
        https://members.nubiles-porn.com/video/watch/(?P<id>\d+)
        (?:/(?P<display_id>[\w\-]+-s(?P<season>\d+)e(?P<episode>\d+)))?
    '''

    _TESTS = [{
        'url': 'https://members.nubiles-porn.com/video/watch/165320/trying-to-focus-my-one-track-mind-s3e1',
        'md5': 'fa7f09da8027c35e4bdf0f94f55eac82',
        'info_dict': {
            'id': '165320',
            'title': 'Trying To Focus My One Track Mind - S3:E1',
            'ext': 'mp4',
            'display_id': 'trying-to-focus-my-one-track-mind-s3e1',
            'thumbnail': 'https://images.nubiles-porn.com/videos/trying_to_focus_my_one_track_mind/samples/cover1280.jpg',
            'description': 'md5:81f3d4372e0e39bff5c801da277a5141',
            'timestamp': 1676160000,
            'upload_date': '20230212',
            'channel': 'Younger Mommy',
            'channel_id': '64',
            'channel_url': 'https://members.nubiles-porn.com/video/website/64',
            'like_count': int,
            'average_rating': float,
            'age_limit': 18,
            'categories': ['Big Boobs', 'Big Naturals', 'Blowjob', 'Brunette', 'Cowgirl', 'Girl Orgasm', 'Girl-Boy',
                           'Glasses', 'Hardcore', 'Milf', 'Shaved Pussy', 'Tattoos', 'YoungerMommy.com'],
            'tags': list,
            'cast': ['Kenzie Love'],
            'availability': 'needs_auth',
            'series': 'Younger Mommy',
            'series_id': '64',
            'season': 'Season 3',
            'season_number': 3,
            'episode': 'Episode 1',
            'episode_number': 1
        }
    }]

    def _perform_login(self, username, password):
        login_webpage = self._download_webpage('https://nubiles-porn.com/login', video_id=None)