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

Code before:
import datetime

from yt_dlp.utils._utils import UserNotLive

from .common import InfoExtractor
from ..utils import (
    int_or_none,
    traverse_obj,
)


class PartiBaseIE(InfoExtractor):
    _RECORDING_BASE_URL = 'https://watch.parti.com'
    _GET_LIVESTREAM_API = 'https://api-backend.parti.com/parti_v2/profile/get_livestream_channel_info'
    _PLAYBACK_VERSION = '1.17.0'

    def _get_formats(self, stream_url, creator, is_live):
        return self._extract_m3u8_formats(stream_url, creator, 'mp4', live=is_live)

    def _build_recording_url(self, path):
        return self._RECORDING_BASE_URL + '/' + path


class PartiVideoIE(PartiBaseIE):
    IE_NAME = 'parti:video'
    IE_DESC = 'Download a video from parti.com'
    _VALID_URL = r'https://parti\.com/video/(?P<id>\d+)'
    _TESTS = [
        {
            'url': 'https://parti.com/video/66284',
            'info_dict': {
                'id': '66284',
                'ext': 'mp4',
                'title': str,
                'upload_date': str,
                'is_live': False,
                'categories': list,
                'thumbnail': str,
                'channel': str,
            },
            'params': {'skip_download': 'm3u8'},
        },
    ]

    def _get_video_info(self, video_id):
        url = self._GET_LIVESTREAM_API + '/recent/' + video_id

Review comment (suggestion):
```suggestion
    def _call_api(self, path, video_id, note=None):
        return self._download_json(
            f'https://api-backend.parti.com/parti_v2/profile/{path}', video_id, note)
```

Code after:
from .common import InfoExtractor
from ..utils import UserNotLive, int_or_none, parse_iso8601, url_or_none, urljoin
from ..utils.traversal import traverse_obj


class PartiBaseIE(InfoExtractor):
    def _call_api(self, path, video_id, note=None):
        return self._download_json(
            f'https://api-backend.parti.com/parti_v2/profile/{path}', video_id, note)


class PartiVideoIE(PartiBaseIE):
    IE_NAME = 'parti:video'
    _VALID_URL = r'https?://(?:www\.)?parti\.com/video/(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://parti.com/video/66284',
        'info_dict': {
            'id': '66284',
            'ext': 'mp4',
            'title': 'NOW LIVE ',
            'upload_date': '20250327',
            'categories': ['Gaming'],
            'thumbnail': 'https://assets.parti.com/351424_eb9e5250-2821-484a-9c5f-ca99aa666c87.png',
            'channel': 'ItZTMGG',
            'timestamp': 1743044379,
        },
        'params': {'skip_download': 'm3u8'},
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        data = self._call_api(f'get_livestream_channel_info/recent/{video_id}', video_id)

        return {
            'id': video_id,
            'formats': self._extract_m3u8_formats(
                urljoin('https://watch.parti.com', data['livestream_recording']), video_id, 'mp4'),
            **traverse_obj(data, {
                'title': ('event_title', {str}),
                'channel': ('user_name', {str}),
                'thumbnail': ('event_file', {url_or_none}),
                'categories': ('category_name', {str}, filter, all),
                'timestamp': ('event_start_ts', {int_or_none}),
            }),
        }