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

Code before:
import base64
import json

from .common import InfoExtractor
from ..utils import (
    mimetype2ext,
    traverse_obj,
    url_or_none,
)


class VidflexIE(InfoExtractor):
    _VALID_URL = r'https?://(?:[^/]+)/[a-z]{2}(?:-[a-z]{2})?/c/[\w-]+\.(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://video.hockeycanada.ca/en/c/nwt-micd-up-with-jamie-lee-rattray.107486',
        'only_matching': True,
    }, {
        # m3u8 + https
        'url': 'https://video.hockeycanada.ca/en-us/c/nwt-micd-up-with-jamie-lee-rattray.107486',
        'info_dict': {
            'id': '107486',
            'title': 'NWT: Mic’d up with Jamie Lee Rattray',
            'ext': 'mp4',
            'duration': 115,
            'timestamp': 1634310409,
            'upload_date': '20211015',
            'tags': ['English', '2021', "National Women's Team"],
            'description': 'md5:efb1cf6165b48cc3f5555c4262dd5b23',
            'thumbnail': 're:^https?://wpmedia01-a.akamaihd.net/en/asset/public/image/.+',
        },
        'params': {'skip_download': True},
    }, {
        'url': 'https://video.hockeycanada.ca/en/c/mwc-remembering-the-wild-ride-in-riga.112307',
        'info_dict': {
            'id': '112307',
            'title': 'MWC: Remembering the wild ride in Riga',
            'ext': 'mp4',
            'duration': 322,

Review comment (security):
We should not match such a generic regex. Since a embed extractor is also not really viable, we need to hardcode the supported domains.
I was thinking something like this (untested)
```py
    _DOMAINS = [
        'video.hockeycanada.ca',
        'www.figureitoutbaseball.com',
        'videos.telusworldofscienceedmonton.ca',
        # TODO: Add more domains
    ]
    _BASE_URL_RE = rf'https?://(?:[^.]+\.vidflex\.tv|{"|".join(map(re.escape, _DOMAINS))})'
    _VALID_URL = rf'{_BASE_URL_RE}/[a-z]{{2}}(?:-[a-z]{{2}})?/c/[\w-]+\.(?P<id>\d+)'
```
Feel free to add any more domains which you can find. I'll also see if I can find some more.

Code after:
import base64
import json

from .common import InfoExtractor
from ..utils import (
    int_or_none,
    join_nonempty,
    mimetype2ext,
    url_or_none,
)
from ..utils.traversal import traverse_obj


class VidflexIE(InfoExtractor):
    _DOMAINS_RE = [
        r'[^.]+\.vidflex\.tv',
        r'(?:www\.)?acactv\.ca',
        r'(?:www\.)?albertalacrossetv\.com',
        r'(?:www\.)?cjfltv\.com',
        r'(?:www\.)?figureitoutbaseball\.com',
        r'(?:www\.)?ocaalive\.com',
        r'(?:www\.)?pegasussports\.tv',
        r'(?:www\.)?praxisseries\.ca',
        r'(?:www\.)?silenticetv\.com',
        r'(?:www\.)?tuffhedemantv\.com',
        r'(?:www\.)?watchfuntv\.com',
        r'live\.ofsaa\.on\.ca',
        r'tv\.procoro\.ca',
        r'tv\.realcastmedia\.net',
        r'tv\.fringetheatre\.ca',
        r'video\.haisla\.ca',
        r'video\.hockeycanada\.ca',
        r'video\.huuayaht\.org',
        r'video\.turningpointensemble\.ca',
        r'videos\.livingworks\.net',
        r'videos\.telusworldofscienceedmonton\.ca',
        r'watch\.binghamtonbulldogs\.com',
        r'watch\.rekindle\.tv',