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

Code before:
import re

from .common import InfoExtractor
from ..utils import float_or_none, int_or_none, parse_iso8601, url_or_none
from ..utils.traversal import traverse_obj


class Art19IE(InfoExtractor):
    _UUID_REGEX = r'[\da-f]{8}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{12}'
    _VALID_URL = [
        rf'https?://(?:www\.)?art19\.com/shows/[^/#?]+/episodes/(?P<id>{_UUID_REGEX})',
        rf'https?://rss\.art19\.com/episodes/(?P<id>{_UUID_REGEX})\.mp3',
    ]
    _EMBED_REGEX = [rf'(?x)<iframe[^>]+\bsrc=[\'"](?P<url>{_VALID_URL[0]})']

    _TESTS = [{
        'url': 'https://rss.art19.com/episodes/5ba1413c-48b8-472b-9cc3-cfd952340bdb.mp3',
        'info_dict': {
            'id': '5ba1413c-48b8-472b-9cc3-cfd952340bdb',
            'ext': 'mp3',
            'title': 'Why Did DeSantis Drop Out?',
            'series': 'The Daily Briefing',
            'release_timestamp': 1705941275,
            'description': 'md5:da38961da4a3f7e419471365e3c6b49f',
            'episode': 'Episode 582',
            'thumbnail': r're:^https?://content\.production\.cdn\.art19\.com.*\.jpeg$',
            'series_id': 'ed52a0ab-08b1-4def-8afc-549e4d93296d',
            'upload_date': '20240122',
            'timestamp': 1705940815,
            'episode_number': 582,
            'modified_date': '20240122',
            'episode_id': '5ba1413c-48b8-472b-9cc3-cfd952340bdb',
            'modified_timestamp': 1705941275,
            'release_date': '20240122',

Review comment (refactor):
I think a UUID without dashes is not valid. Unless you have examples of this site using invalid UUIDs, I would simplify the pattern by enforcing dashes
```suggestion
    _UUID_REGEX = r'[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}'
```
&nbsp;
could do this to make it shorter, although arguably harder to read:
```suggestion
    _UUID_REGEX = r'[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}'
```
really this should be a util by now imo

Code after:
import re

from .common import InfoExtractor
from ..utils import float_or_none, int_or_none, parse_iso8601, url_or_none
from ..utils.traversal import traverse_obj


class Art19IE(InfoExtractor):
    _UUID_REGEX = r'[\da-f]{8}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{4}-?[\da-f]{12}'
    _VALID_URL = [
        rf'https?://(?:www\.)?art19\.com/shows/[^/#?]+/episodes/(?P<id>{_UUID_REGEX})',
        rf'https?://rss\.art19\.com/episodes/(?P<id>{_UUID_REGEX})\.mp3',
    ]
    _EMBED_REGEX = [rf'<iframe[^>]+\bsrc=[\'"](?P<url>{_VALID_URL[0]})']

    _TESTS = [{
        'url': 'https://rss.art19.com/episodes/5ba1413c-48b8-472b-9cc3-cfd952340bdb.mp3',
        'info_dict': {
            'id': '5ba1413c-48b8-472b-9cc3-cfd952340bdb',
            'ext': 'mp3',
            'title': 'Why Did DeSantis Drop Out?',
            'series': 'The Daily Briefing',
            'release_timestamp': 1705941275,
            'description': 'md5:da38961da4a3f7e419471365e3c6b49f',
            'episode': 'Episode 582',
            'thumbnail': r're:^https?://content\.production\.cdn\.art19\.com.*\.jpeg$',
            'series_id': 'ed52a0ab-08b1-4def-8afc-549e4d93296d',
            'upload_date': '20240122',
            'timestamp': 1705940815,
            'episode_number': 582,
            'modified_date': '20240122',
            'episode_id': '5ba1413c-48b8-472b-9cc3-cfd952340bdb',
            'modified_timestamp': 1705941275,
            'release_date': '20240122',