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

Code before:
from urllib.parse import unquote
from .common import InfoExtractor
from ..utils import (
    unified_strdate,
    bool_or_none,
    str_or_none,
    traverse_obj,
)


class MediciIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?(?:medici|edu\.medici)\.tv/(?:(?:[a-zA-Z0-9-_\.]+)/)*(?:#!/)?(?P<id>[^?#&]+)'
    _TESTS = [
        {
            'url': 'https://www.medici.tv/en/operas/thomas-ades-the-exterminating-angel-calixto-bieito-opera-bastille-paris',
            'md5': 'd483f74e7a7a9eac0dbe152ab189050d',
            'expected_warnings': [r'preview'],
            'info_dict': {
                'id': '8032',
                'ext': 'mp4',
                'title': 'Thomas Adès\'s The Exterminating Angel',
                'thumbnail': r're:^https?://medicitv-[abc]\.imgix\.net/movie/[^?]+\.jpg(?:\?[^?]+)?',
                'description': 'md5:708ae6350dadc604225b4a6e32482bab',
                'upload_date': '20240304',
            },
        },
        {
            'url': 'https://edu.medici.tv/en/operas/wagner-lohengrin-paris-opera-kirill-serebrennikov-piotr-beczala-kwangchul-youn-johanni-van-oostrum',
            'md5': '4ef3f4079a6e1c617584463a9eb84f99',
            'expected_warnings': [r'preview'],
            'info_dict': {
                'id': '7900',
                'ext': 'mp4',
                'title': 'Wagner\'s Lohengrin',
                'thumbnail': r're:^https?://medicitv-[abc]\.imgix\.net/movie/[^?]+\.jpg(?:\?[^?]+)?',
                'description': 'md5:a384a62937866101f86902f21752cd89',
                'upload_date': '20231017',

Review comment (suggestion):
we don't want to match `www.edu.medici.tv`, right? or do you have a working URL from that hostname?

can we add a test for a `/#!/` URL?

I would write it like this, to be more precise and so that we can match `edu` for later use:
```suggestion
    _VALID_URL = r'https?://(?:(?P<sub>www|edu)\.)?medici\.tv/(?:#!|[a-z]{2}/[\w.-]+)/(?P<id>[^/?#&]+)'
```

Code after:
import urllib.parse

from .common import InfoExtractor
from ..utils import (
    filter_dict,
    parse_iso8601,
    traverse_obj,
    try_call,
    url_or_none,
)


class MediciIE(InfoExtractor):
    _VALID_URL = r'https?://(?:(?P<sub>www|edu)\.)?medici\.tv/[a-z]{2}/[\w.-]+/(?P<id>[^/?#&]+)'
    _TESTS = [{
        'url': 'https://www.medici.tv/en/operas/thomas-ades-the-exterminating-angel-calixto-bieito-opera-bastille-paris',
        'md5': 'd483f74e7a7a9eac0dbe152ab189050d',
        'info_dict': {
            'id': '8032',
            'ext': 'mp4',
            'title': 'Thomas Adès\'s The Exterminating Angel',
            'description': 'md5:708ae6350dadc604225b4a6e32482bab',
            'thumbnail': r're:https://.+/.+\.jpg',
            'upload_date': '20240304',
            'timestamp': 1709561766,
            'display_id': 'thomas-ades-the-exterminating-angel-calixto-bieito-opera-bastille-paris',
        },
        'expected_warnings': [r'preview'],
    }, {
        'url': 'https://edu.medici.tv/en/operas/wagner-lohengrin-paris-opera-kirill-serebrennikov-piotr-beczala-kwangchul-youn-johanni-van-oostrum',
        'md5': '4ef3f4079a6e1c617584463a9eb84f99',
        'info_dict': {
            'id': '7900',
            'ext': 'mp4',
            'title': 'Wagner\'s Lohengrin',
            'description': 'md5:a384a62937866101f86902f21752cd89',
            'thumbnail': r're:https://.+/.+\.jpg',