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

Code before:
                '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(works['previews']):
            ext = traverse_obj(preview, ('information', 'extension', {str}))
            if ext not in ('mp3', 'mp4'):
                self.report_warning(f'Skipping unsupported extension "{ext}"')
                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,
                'title': f'{work_id}-{idx}',
                'subtitles': subtitles,
                **info,
                **mp3_info,
                **traverse_obj(preview, {
                    'id': ('id', {str_or_none}),
                    'thumbnail': ('poster_url', {url_or_none}),
                    'url': ('url', {url_or_none}),
                }),
                **traverse_obj(preview, ('information', {
                    'duration': ('duration', {int_or_none}),
                    'fps': ('frame_rate', {int_or_none}),
                    'height': ('height', {int_or_none}),
                    'width': ('width', {int_or_none}),
                })),
            })

        return self.playlist_result(entries, work_id)


Review comment (refactor):
subs extraction should be non-fatal
```suggestion
                'subtitles': {
                    'ja': [{
                        'ext': 'vtt',
                        'url': preview['vtt_url'],
                    }],
                } if url_or_none(preview.get('vtt_url')) else None,
                'vcodec': 'none' if ext == 'mp3' else None,
```

Code after:

        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'],
                    }],
                } if url_or_none(preview.get('vtt_url')) else None,
                'vcodec': 'none' if ext == 'mp3' else None,
                **info,
                **traverse_obj(preview, {
                    'id': ('id', {str_or_none}),
                    'thumbnail': ('poster_url', {url_or_none}),
                    'url': ('url', {url_or_none}),
                }),
                **traverse_obj(preview, ('information', {
                    'duration': ('duration', {int_or_none}),
                    'fps': ('frame_rate', {int_or_none}),
                    'height': ('height', {int_or_none}),
                    'width': ('width', {int_or_none}),
                })),
            })

        return self.playlist_result(entries, work_id, **info)