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

Code before:
            'thumbnail': ('event_file', {str}),
            'categories': ('category', {lambda c: [c]}),
            'url': ('livestream_recording', {str}),
            'title': ('event_title', {str}),
            'upload_date': ('event_start_ts', {lambda ts: datetime.date.fromtimestamp(ts).strftime('%Y%m%d')}),
        })

    def _real_extract(self, url):
        video_id = self._match_id(url)
        video_info = self._get_video_info(video_id)
        full_recording_url = self._build_recording_url(video_info['url'])
        formats = self._get_formats(full_recording_url, video_info['channel'], is_live=False)

        return {
            'id': video_id,
            'url': url,
            'formats': formats,
            'is_live': False,
            **video_info,
        }


class PartiLivestreamIE(PartiBaseIE):
    IE_NAME = 'parti:livestream'
    IE_DESC = 'Download a stream from parti.com'
    _VALID_URL = r'https://parti\.com/creator/(parti|discord|telegram)/(?P<id>[\w-]+)'
    _TESTS = [
        {
            'url': 'https://parti.com/creator/parti/SpartanTheDog',
            'info_dict': {
                'id': 'SpartanTheDog',
                'ext': 'mp4',
                'title': str,
                'description': str,
                'upload_date': str,
                'is_live': True,
                'live_status': 'is_live',
            },
            'params': {'skip_download': 'm3u8'},
        },
    ]
    _CREATOR_API = 'https://api-backend.parti.com/parti_v2/profile/get_user_by_social_media/parti'

    def _get_creator_id(self, creator):
        """ The creator ID is a number returned as plain text """
        url = self._CREATOR_API + '/' + creator
        page = self._download_webpage(url, None, 'Fetching creator id')
        return str(page)

    def _get_live_playback_data(self, creator_id):
        """ If the stream is live, we can use this URL to download. """

Review comment (suggestion):
There are other URL patterns as well such as `twitter`. We also need to know the service for the `get_user_by_social_media` request
```suggestion
    _VALID_URL = r'https?://(?:www\.)?parti\.com/creator/(?P<service>[\w]+)/(?P<id>[\w/-]+)'
```
There are additionally URLs such as `https://parti.com/creator/discord/simo_hayha_710/0` where the additional `/0` is also relevant.

Code after:
    _VALID_URL = r'https?://(?:www\.)?parti\.com/creator/(?P<service>[\w]+)/(?P<id>[\w/-]+)'
    _TESTS = [{
        'url': 'https://parti.com/creator/parti/Capt_Robs_Adventures',
        'info_dict': {
            'id': 'Capt_Robs_Adventures',
            'ext': 'mp4',
            'title': r"re:I'm Live on Parti \d{4}-\d{2}-\d{2} \d{2}:\d{2}",
            'view_count': int,
            'thumbnail': r're:https://assets\.parti\.com/.+\.png',
            'timestamp': 1743879776,
            'upload_date': '20250405',
            'live_status': 'is_live',
        },
        'params': {'skip_download': 'm3u8'},
    }, {
        'url': 'https://parti.com/creator/discord/sazboxgaming/0',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        service, creator_slug = self._match_valid_url(url).group('service', 'id')

        encoded_creator_slug = creator_slug.replace('/', '%23')
        creator_id = self._call_api(
            f'get_user_by_social_media/{service}/{encoded_creator_slug}',
            creator_slug, note='Fetching user ID')

        data = self._call_api(
            f'get_livestream_channel_info/{creator_id}', creator_id,
            note='Fetching user profile feed')['channel_info']

        if not traverse_obj(data, ('channel', 'is_live', {bool})):
            raise UserNotLive(video_id=creator_id)

        channel_info = data['channel']

        return {
            'id': creator_slug,
            'formats': self._extract_m3u8_formats(
                channel_info['playback_url'], creator_slug, live=True, query={
                    'token': channel_info['playback_auth_token'],
                    'player_version': '1.17.0',
                }),
            'is_live': True,
            **traverse_obj(data, {
                'title': ('livestream_event_info', 'event_name', {str}),
                'description': ('livestream_event_info', 'event_description', {str}),
                'thumbnail': ('livestream_event_info', 'livestream_preview_file', {url_or_none}),
                'timestamp': ('stream', 'start_time', {parse_iso8601}),
                'view_count': ('stream', 'viewer_count', {int_or_none}),
            }),