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

Code before:
from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    UserNotLive,
    int_or_none,
    traverse_obj,
    unified_strdate,
    url_or_none,
    urlencode_postdata,
)


class PandaTVIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.|m\.)?pandalive\.co\.kr/play/(?P<id>[\da-z]+)'
    _TESTS = [{
        'url': 'https://www.pandalive.co.kr/play/bebenim',
        'info_dict': {
            'id': 'bebenim',
            'ext': 'mp4',
            'channel': '릴리ෆ',
            'title': r're:앙앙❤ \d{4}-\d{2}-\d{2} \d{2}:\d{2}',
            'thumbnail': r're:https://cdn\.pandalive\.co\.kr/ivs/v1/.+/thumb.jpg',
            'concurrent_view_count': int,
            'like_count': int,
            'live_status': 'is_live',
            'upload_date': str,
        },
        'skip': 'The channel is not currently live',
    }]

    def _real_extract(self, url):
        channel_id = self._match_id(url)
        http_headers = {'Origin': 'https://www.pandalive.co.kr'}

        video_meta = self._download_json(
            'https://api.pandalive.co.kr/v1/live/play', channel_id,
            'Downloading video meta data', 'Unable to download video meta data',
            data=urlencode_postdata({
                'action': 'watch',
                'userId': channel_id,
                'password': self.get_param('videopassword'),
                'shareLinkType': '',
            }), expected_status=400)

        if not video_meta.get('result'):
            error_code = traverse_obj(video_meta, ('errorData', 'code', {str}))
            if error_code == 'castEnd':

Review comment (suggestion):
```suggestion
            'thumbnail': r're:https://cdn\.pandalive\.co\.kr/ivs/v1/.+/thumb\.jpg',
```

Code after:
from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    UserNotLive,
    filter_dict,
    int_or_none,
    join_nonempty,
    parse_iso8601,
    url_or_none,
    urlencode_postdata,
)
from ..utils.traversal import traverse_obj


class PandaTvIE(InfoExtractor):
    IE_DESC = 'pandalive.co.kr (팬더티비)'
    _VALID_URL = r'https?://(?:www\.|m\.)?pandalive\.co\.kr/play/(?P<id>\w+)'
    _TESTS = [{
        'url': 'https://www.pandalive.co.kr/play/bebenim',
        'info_dict': {
            'id': 'bebenim',
            'ext': 'mp4',
            'channel': '릴리ෆ',
            'title': r're:앙앙❤ \d{4}-\d{2}-\d{2} \d{2}:\d{2}',
            'thumbnail': r're:https://cdn\.pandalive\.co\.kr/ivs/v1/.+/thumb\.jpg',
            'concurrent_view_count': int,
            'like_count': int,
            'live_status': 'is_live',
            'upload_date': str,
        },
        'skip': 'The channel is not currently live',
    }]

    def _real_extract(self, url):
        channel_id = self._match_id(url)
        video_meta = self._download_json(
            'https://api.pandalive.co.kr/v1/live/play', channel_id,
            'Downloading video meta data', 'Unable to download video meta data',
            data=urlencode_postdata(filter_dict({
                'action': 'watch',
                'userId': channel_id,
                'password': self.get_param('videopassword'),
            })), expected_status=400)

        if error_code := traverse_obj(video_meta, ('errorData', 'code', {str})):
            if error_code == 'castEnd':
                raise UserNotLive(video_id=channel_id)