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

Code before:
            '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 {
            'id': video_id,
            **traverse_obj(media, {
                '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)}),
            }),
        }


Review comment (refactor):
if we're unpacking a traversal call now, we can pull `formats` out of there too
```suggestion
            'id': video_id,
            'formats': self._extract_m3u8_formats(media['playlist_item']['file'], video_id, 'mp4'),
            **traverse_obj(media, {
                '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')}),
```

Code after:
            '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 {
            'id': video_id,
            'formats': self._extract_m3u8_formats(media['playlist_item']['file'], video_id),
            **traverse_obj(media, {
                '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')}),
            }),
        }