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

Code before:
        'info_dict': {
            'id': '46k_d23-6000-105',
            'ext': 'mp4',
            'timestamp': 1700586300,
            'duration': 1442,
            'upload_date': '20231121',
            'title': '4. studija. Zolitūdes traģēdija un Inčupes stacija',
            'thumbnail': 'https://ltv.lsm.lv/storage/media/8/7/large/5/1f9604e1.jpg',
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)

        json = self._search_nuxt_data(self.fix_nuxt_data(webpage), video_id)
        embed_id = traverse_obj(json, ('article', 'videoMediaItem', 'video', 'embed_id'))

        return {
            '_type': 'url_transparent',
            'ie_key': 'LSMLTVEmbed',
            'url': f'https://ltv.lsm.lv/embed?c={embed_id}',
            'id': video_id,
            'title': traverse_obj(json, ('article', 'title')),
            'timestamp': traverse_obj(json, ('article', 'aired_at', {parse_iso8601})),
            'thumbnail': traverse_obj(json, ('article', 'thumbnail', {url_or_none})),
        }


class LSMReplayIE(LSMBaseIE):
    _VALID_URL = r'https?://replay\.lsm\.lv/.*/(?:ieraksts|statja)/[^/]+/(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://replay.lsm.lv/lv/ieraksts/ltv/311130/4-studija-zolitudes-tragedija-un-incupes-stacija',
        'md5': '64f72a360ca530d5ed89c77646c9eee5',
        'info_dict': {
            'id': '46k_d23-6000-105',
            'ext': 'mp4',
            'timestamp': 1700586300,
            'description': 'md5:0f1b14798cc39e1ae578bd0eb268f759',
            'duration': 1442,
            'upload_date': '20231121',
            'title': '4. studija. Zolitūdes traģēdija un Inčupes stacija',
            'thumbnail': 'https://ltv.lsm.lv/storage/media/8/7/large/5/1f9604e1.jpg',
        }
    }, {
        'url': 'https://replay.lsm.lv/lv/ieraksts/lr/183522/138-nepilniga-kompensejamo-zalu-sistema-pat-menesiem-dzena-pacientus-pa-aptiekam',
        'md5': '719b33875cd1429846eeeaeec6df2830',
        'info_dict': {
            'id': '183522',
            'ext': 'mp3',
            'duration': 1823,

Review comment (suggestion):
Maybe like this instead?
```suggestion

        return {
            '_type': 'url_transparent',
            'ie_key': 'LSMLTVEmbed',
            'id': video_id,
            **traverse_obj(json, ('article', {
                'url': ('videoMediaItem', 'video', 'embed_id', {lambda x: x and f'https://ltv.lsm.lv/embed?c={x}'}),
                'title': 'title',
                'timestamp': ('aired_at', {parse_iso8601}),
                'thumbnail': ('thumbnail', {url_or_none}),
            })),
```

Code after:
            'ext': 'mp4',
            'timestamp': 1700589151,
            'duration': 1442,
            'upload_date': '20231121',
            'title': 'D23-6000-105_cetstud',
            'thumbnail': 'https://store.cloudycdn.services/tmsp00060/assets/media/660858/placeholder1700589200.jpg',
        }
    }, {
        'url': 'https://ltv.lsm.lv/embed?enablesdkjs=1&c=eyJpdiI6IncwVzZmUFk2MU12enVWK1I3SUcwQ1E9PSIsInZhbHVlIjoid3FhV29vamc3T2sxL1RaRmJ5Rm1GTXozU0o2dVczdUtLK0cwZEZJMDQ2a3ZIRG5DK2pneGlnbktBQy9uazVleHN6VXhxdWIweWNvcHRDSnlISlNYOHlVZ1lpcTUrcWZSTUZPQW14TVdkMW9aOUtRWVNDcFF4eWpHNGcrT0VZbUNFQStKQk91cGpndW9FVjJIa0lpbkh3PT0iLCJtYWMiOiIyZGI1NDJlMWRlM2QyMGNhOGEwYTM2MmNlN2JlOGRhY2QyYjdkMmEzN2RlOTEzYTVkNzI1ODlhZDlhZjU4MjQ2IiwidGFnIjoiIn0=',
        'md5': 'a1711e190fe680fdb68fd8413b378e87',
        'info_dict': {
            'id': 'wUnFArIPDSY',
            'ext': 'mp4',
            'uploader': 'LTV_16plus',
            'release_date': '20220514',
            'channel_url': 'https://www.youtube.com/channel/UCNMrnafwXD2XKeeQOyfkFCw',
            'view_count': int,
            'availability': 'public',
            'thumbnail': 'https://i.ytimg.com/vi/wUnFArIPDSY/maxresdefault.jpg',
            'release_timestamp': 1652544074,
            'title': 'EIROVĪZIJA SALĀTOS',
            'live_status': 'was_live',
            'uploader_id': '@LTV16plus',
            'comment_count': int,
            'channel_id': 'UCNMrnafwXD2XKeeQOyfkFCw',
            'channel_follower_count': int,
            'categories': ['Entertainment'],
            'duration': 5269,
            'upload_date': '20220514',
            'age_limit': 0,
            'channel': 'LTV_16plus',
            'playable_in_embed': True,
            'tags': [],
            'uploader_url': 'https://www.youtube.com/@LTV16plus',
            'like_count': int,
            'description': 'md5:7ff0c42ba971e3c13e4b8a2ff03b70b5',
        }
    }]

    def _real_extract(self, url):
        video_id = urllib.parse.unquote(self._match_id(url))
        webpage = self._download_webpage(url, video_id)
        data = self._search_json(
            r'window\.ltvEmbedPayload\s*=', webpage, 'embed json', video_id)
        embed_type = traverse_obj(data, ('source', 'name', {str}))

        if embed_type == 'telia':
            ie_key = 'CloudyCDN'
            embed_url = traverse_obj(data, ('source', 'embed_url', {url_or_none}))
        elif embed_type == 'youtube':
            ie_key = 'Youtube'