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

Code before:
            'ext': 'm4a',
            'title': 'Nemarios eilės: apie pragarus ir skaistyklas su Aiste Kiltinavičiūte',
            'description': 'md5:5eee9a0e86a55bf547bd67596204625d',
            'timestamp': 1726143120,
            'upload_date': '20240912',
            'tags': list,
            'thumbnail': r're:https?://.+/.+\.jpe?g',
            'categories': list,
        },
    }, {
        'url': 'https://www.lrt.lt/radioteka/irasas/2000304654/vakaras-su-knyga-svetlana-aleksijevic-cernobylio-malda-v-dalis?season=%2Fmediateka%2Faudio%2Fvakaras-su-knyga%2F2023',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        video_id, path = self._match_valid_url(url).groups()

        base_url = 'https://www.lrt.lt'
        api_url = 'https://www.lrt.lt/radioteka/api/media'
        media_url = f'/mediateka/irasas/{video_id}/{path}'
        media = self._download_json(api_url, video_id, query={'url': media_url})
        return traverse_obj(media, {
            'id': ('id', {int}, {str_or_none}),
            'title': ('title', {str}),
            'tags': ('tags', ..., 'name'),
            'categories': ('playlist_item', 'category', {lambda x: [x]}),
            'description': ('content', {clean_html}, {str}),
            'timestamp': ('date', {lambda x: x.replace('.', '/')}, {unified_timestamp}),
            'thumbnail': ('playlist_item', 'image', {lambda x: f'{base_url}{x}'}, {url_or_none}),
            'formats': ('playlist_item', 'file', {lambda x: self._extract_m3u8_formats(x, video_id)}),
        })


Review comment (suggestion):
`{lambda x: [x]}` can return `[None]`, since transformations are always called (even if the path starts to return `None` before the transformation).

Here we can use `all`, which in a traversal path will reset branching and return a list of all results (and since we weren't branching, it will just be a list of the 1 result). Filter out empty strings before and filter out an empty list after.
```suggestion
            'categories': ('playlist_item', 'category', {str}, filter, all, filter),
```

Code after:
            'ext': 'm4a',
            'title': 'Nemarios eilės: apie pragarus ir skaistyklas su Aiste Kiltinavičiūte',
            'description': 'md5:5eee9a0e86a55bf547bd67596204625d',
            'timestamp': 1726143120,
            'upload_date': '20240912',
            'tags': 'count:5',
            'thumbnail': r're:https?://.+/.+\.jpe?g',
            'categories': ['Daiktiniai įrodymai'],
        },
    }, {
        'url': 'https://www.lrt.lt/radioteka/irasas/2000304654/vakaras-su-knyga-svetlana-aleksijevic-cernobylio-malda-v-dalis?season=%2Fmediateka%2Faudio%2Fvakaras-su-knyga%2F2023',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        video_id, path = self._match_valid_url(url).group('id', 'path')
        media = self._download_json(
            'https://www.lrt.lt/radioteka/api/media', video_id,
            query={'url': f'/mediateka/irasas/{video_id}/{path}'})

        return traverse_obj(media, {
            'id': ('id', {int}, {str_or_none}),
            'title': ('title', {str}),
            'tags': ('tags', ..., 'name', {str}),
            'categories': ('playlist_item', 'category', {str}, filter, all, filter),
            'description': ('content', {clean_html}, {str}),
            'timestamp': ('date', {lambda x: x.replace('.', '/')}, {unified_timestamp}),
            'thumbnail': ('playlist_item', 'image', {urljoin('https://www.lrt.lt')}),
            'formats': ('playlist_item', 'file', {lambda x: self._extract_m3u8_formats(x, video_id)}),
        })