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

Code before:
        'only_matching': True,
    }, {
        'url': 'https://klasika.lsm.lv/lv/embed/?id=110806&show=0&theme=white&size=16x9',
        'only_matching': True,
    }, {
        'url': 'https://lr4.lsm.lv/lv/embed/?id=184282&show=0&theme=white&size=16x9',
        'only_matching': True,
    }, {
        'url': 'https://pieci.lv/lv/embed/?id=168896&show=0&theme=white&size=16x9',
        'only_matching': True,
    }, {
        'url': 'https://naba.lsm.lv/lv/embed/?id=182901&show=0&theme=white&size=16x9',
        'only_matching': True,
    }, {
        'url': 'https://radioteatris.lsm.lv/lv/embed/?id=176439&show=0&theme=white&size=16x9',
        'only_matching': True,
    }, {
        'url': 'https://lr1.lsm.lv/lv/pleijeris/?embed=0&id=48205&time=00%3A00&idx=0',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        query = parse_qs(url)
        video_id = traverse_obj(query, ('show', 0, {int_or_none}))

        if video_id is None or video_id == 0:
            video_id = traverse_obj(query, ('id', 0, {int_or_none}))

        webpage = self._download_webpage(url, video_id)

        player_data, media_data = self._html_search_regex(
            r'LR\.audio\.Player\s*\([^{]*(?P<player>\{.*?\}),(?P<media>\{.*\})\);',
            webpage, 'player json', group=('player', 'media'))

        player_json = self._parse_json(player_data, video_id, js_to_json)
        media_json = self._parse_json(media_data, video_id, js_to_json)

        entries = []
        for i, audio_json in enumerate(traverse_obj(media_json, ('audio', ...))):
            formats = []
            for source_url in traverse_obj(media_json, (('audio', 'video'), i, 'sources', ..., 'file', {url_or_none})):
                if source_url.endswith('.m3u8'):
                    formats.extend(self._extract_m3u8_formats(source_url, video_id))
                else:
                    formats.append({'url': source_url})

            entries.append({
                'formats': formats,
                'thumbnail': urljoin(url, player_json.get('poster')),
                **traverse_obj(audio_json, {
                    'id': 'id',

Review comment (suggestion):
It will either be an `int` or `None`, so we can use `not` instead:
```suggestion
        if not video_id:
```

Code after:
                'title': 'Krustpunktā Lielā intervija: Valsts prezidents Egils Levits',
                'duration': 3222,
            },
        }, {
            'md5': '5d5e191e718b7644e5118b7b4e093a6d',
            'info_dict': {
                'id': 'v303104',
                'ext': 'mp4',
                'thumbnail': 'https://pic.latvijasradio.lv/public/assets/media/c/5/gallery_a83ad2c2.jpg',
                'title': 'Krustpunktā Lielā intervija: Valsts prezidents Egils Levits - Video Version',
                'duration': 3222,
            },
        }],
    }, {
        'url': 'https://lr1.lsm.lv/lv/embed/?id=183522&show=0&theme=white&size=16x9',
        'only_matching': True,
    }, {
        'url': 'https://lr2.lsm.lv/lv/embed/?id=182126&show=0&theme=white&size=16x9',
        'only_matching': True,
    }, {
        'url': 'https://klasika.lsm.lv/lv/embed/?id=110806&show=0&theme=white&size=16x9',
        'only_matching': True,
    }, {
        'url': 'https://lr4.lsm.lv/lv/embed/?id=184282&show=0&theme=white&size=16x9',
        'only_matching': True,
    }, {
        'url': 'https://pieci.lv/lv/embed/?id=168896&show=0&theme=white&size=16x9',
        'only_matching': True,
    }, {
        'url': 'https://naba.lsm.lv/lv/embed/?id=182901&show=0&theme=white&size=16x9',
        'only_matching': True,
    }, {
        'url': 'https://radioteatris.lsm.lv/lv/embed/?id=176439&show=0&theme=white&size=16x9',
        'only_matching': True,
    }, {
        'url': 'https://lr1.lsm.lv/lv/pleijeris/?embed=0&id=48205&time=00%3A00&idx=0',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        query = parse_qs(url)
        video_id = traverse_obj(query, (
            ('show', 'id'), 0, {int_or_none}, {lambda x: x or None}, {str_or_none}), get_all=False)
        webpage = self._download_webpage(url, video_id)

        player_data, media_data = self._search_regex(
            r'LR\.audio\.Player\s*\([^{]*(?P<player>\{.*?\}),(?P<media>\{.*\})\);',
            webpage, 'player json', group=('player', 'media'))

        player_json = self._parse_json(
            player_data, video_id, transform_source=js_to_json, fatal=False) or {}