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

Code before:
import re
import urllib.parse

from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    int_or_none,
    js_to_json,
    parse_iso8601,
    parse_qs,
    url_or_none,
    urljoin,
)
from ..utils.traversal import traverse_obj


class LSMLREmbedIE(InfoExtractor):
    _VALID_URL = r'https?://(?:(?:latvijasradio|lr1|lr2|klasika|lr4|naba|radioteatris)\.lsm|pieci)\.lv/[^/]+/(?:pleijeris|embed)'
    _TESTS = [{
        'url': 'https://latvijasradio.lsm.lv/lv/embed/?theme=black&size=16x9&showCaptions=0&id=183522',
        'md5': '719b33875cd1429846eeeaeec6df2830',
        'info_dict': {
            'id': 'a342781',
            'ext': 'mp3',
            'duration': 1823,
            'title': '#138 Nepilnīgā kompensējamo zāļu sistēma pat mēnešiem dzenā pacientus pa aptiekām',
            'thumbnail': 'https://pic.latvijasradio.lv/public/assets/media/9/d/gallery_fd4675ac.jpg',
        }
    }, {
        'url': 'https://radioteatris.lsm.lv/lv/embed/?id=&show=1270&theme=white&size=16x9',
        'info_dict': {
            'id': 1270,
        },
        'playlist_count': 3,
        'playlist': [{
            'md5': '2e61b6eceff00d14d57fdbbe6ab24cac',
            'info_dict': {
                'id': 'a297397',
                'ext': 'mp3',
                'title': 'Eriks Emanuels Šmits "Pilāta evaņģēlijs". 1. daļa',
                'thumbnail': 'https://radioteatris.lsm.lv/public/assets/shows/62f131ae81e3c.jpg',
                'duration': 3300,
            },

Review comment (suggestion):
if the URL doesn't have a `show` or `id` query param then it wouldn't be pointing at anything useful?
```suggestion
    _VALID_URL = r'''(?x)
        https?://(?:
            (?:latvijasradio|lr1|lr2|klasika|lr4|naba|radioteatris)\.lsm|
            pieci
        )\.lv/[^/?#]+/(?:
            pleijeris|embed
        )/?\?(?:[^#]+&)?(?:show|id)=(?P<id>\d+)'''
```

Code after:
import re
import urllib.parse

from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    determine_ext,
    int_or_none,
    js_to_json,
    parse_iso8601,
    parse_qs,
    str_or_none,
    url_or_none,
    urljoin,
)
from ..utils.traversal import traverse_obj


class LSMLREmbedIE(InfoExtractor):
    _VALID_URL = r'''(?x)
        https?://(?:
            (?:latvijasradio|lr1|lr2|klasika|lr4|naba|radioteatris)\.lsm|
            pieci
        )\.lv/[^/?#]+/(?:
            pleijeris|embed
        )/?\?(?:[^#]+&)?(?:show|id)=(?P<id>\d+)'''
    _TESTS = [{
        'url': 'https://latvijasradio.lsm.lv/lv/embed/?theme=black&size=16x9&showCaptions=0&id=183522',
        'md5': '719b33875cd1429846eeeaeec6df2830',
        'info_dict': {
            'id': 'a342781',
            'ext': 'mp3',
            'duration': 1823,
            'title': '#138 Nepilnīgā kompensējamo zāļu sistēma pat mēnešiem dzenā pacientus pa aptiekām',
            'thumbnail': 'https://pic.latvijasradio.lv/public/assets/media/9/d/gallery_fd4675ac.jpg',
        }
    }, {
        'url': 'https://radioteatris.lsm.lv/lv/embed/?id=&show=1270&theme=white&size=16x9',
        'info_dict': {
            'id': '1270',
        },
        'playlist_count': 3,
        'playlist': [{