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

Code before:
    }]

    def _call_api(self, uploader_id, work_id):
        return self._download_json(
            f'https://skeb.jp/api/users/{uploader_id}/works/{work_id}', work_id, headers={
                'Accept': 'application/json',
                'Authorization': 'Bearer null',
                'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36',
            })

    def _real_extract(self, url):
        uploader_id, work_id = self._match_valid_url(url).group('uploader_id', 'id')
        try:
            works = self._call_api(uploader_id, work_id)
        except ExtractorError as e:
            if not isinstance(e.cause, HTTPError) or e.cause.status != 429:
                raise
            webpage = e.cause.response.read().decode()
            value = self._search_regex(
                r'document\.cookie\s*=\s*["\']request_key=([^;"\']+)', webpage, 'request key')
            self._set_cookie('skeb.jp', 'request_key', value)
            works = self._call_api(uploader_id, work_id)

        info = {
            'title': work_id,
            'display_id': work_id,
            'uploader_id': uploader_id,
            **traverse_obj(works, {
                'age_limit': ('nsfw', {bool}, {lambda x: 18 if x else None}),
                'description': (('source_body', 'body'), {clean_html}, filter, any),
                'genres': ('genre', {str}, filter, all, filter),
                'tags': ('tag_list', ..., {str}, filter, all, filter),
                'uploader': ('creator', 'name', {str}),
            }),
        }

        entries = []
        for preview in works['previews']:
            ext = traverse_obj(preview, ('information', 'extension', {str}))
            if ext not in ('mp3', 'mp4'):
                continue
            mp3_info = {'abr': 128, 'vcodec': 'none'} if ext == 'mp3' else {}

            subtitles = {}
            subtitles.setdefault('ja', []).append({
                'ext': 'vtt',
                'url': preview['vtt_url'],
            })

            entries.append({
                'ext': ext,

Review comment (suggestion):
I don't like duplicating the playlist id as the entries' `title` and `display_id`

`display_id` is redundant if it's the same as the playlist id, could be removed

if there's really no alternative we could use for the entries' `title`, then let's enumerate the `previews` and use `{work_id}-{idx}`

Code after:
            'genres': ['video'],
        },
        'playlist_count': 2,
        'expected_warnings': ['Skipping unsupported extension'],
    }]

    def _call_api(self, uploader_id, work_id):
        return self._download_json(
            f'https://skeb.jp/api/users/{uploader_id}/works/{work_id}', work_id, headers={
                'Accept': 'application/json',
                'Authorization': 'Bearer null',
            })

    def _real_extract(self, url):
        uploader_id, work_id = self._match_valid_url(url).group('uploader_id', 'id')
        try:
            works = self._call_api(uploader_id, work_id)
        except ExtractorError as e:
            if not isinstance(e.cause, HTTPError) or e.cause.status != 429:
                raise
            webpage = e.cause.response.read().decode()
            value = self._search_regex(
                r'document\.cookie\s*=\s*["\']request_key=([^;"\']+)', webpage, 'request key')
            self._set_cookie('skeb.jp', 'request_key', value)
            works = self._call_api(uploader_id, work_id)

        info = {
            'uploader_id': uploader_id,
            **traverse_obj(works, {
                'age_limit': ('nsfw', {bool}, {lambda x: 18 if x else None}),
                'description': (('source_body', 'body'), {clean_html}, filter, any),
                'genres': ('genre', {str}, filter, all, filter),
                'tags': ('tag_list', ..., {str}, filter, all, filter),
                'uploader': ('creator', 'name', {str}),
            }),
        }

        entries = []
        for idx, preview in enumerate(traverse_obj(works, ('previews', lambda _, v: url_or_none(v['url']))), 1):
            ext = traverse_obj(preview, ('information', 'extension', {str}))
            if ext not in ('mp3', 'mp4'):
                self.report_warning(f'Skipping unsupported extension "{ext}"')
                continue

            entries.append({
                'ext': ext,
                'title': f'{work_id}-{idx}',
                'subtitles': {
                    'ja': [{
                        'ext': 'vtt',
                        'url': preview['vtt_url'],