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

Code before:
            'skip_download': True,
            'ignore_no_formats_error': True,
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)

        expires = int_or_none(traverse_obj(parse_qs(url), ('expires', 0)))
        if expires and expires <= time_seconds():
            raise ExtractorError('The link is expired.', video_id=video_id, expected=True)

        webpage = self._download_webpage(url, video_id)

        player_data = self._download_webpage(
            self._search_regex(
                r'<script [^>]*\bsrc="(https://player-api\.p\.uliza\.jp/v1/players/(?:[^"]*))"[^>]*>',
                webpage, 'player data url'),
            video_id, headers={'Referer': 'https://ulizaportal.jp/'},
            note='Fetching player data', errnote='Unable to fetch player data')

        formats = self._extract_m3u8_formats(
            self._search_regex(
                r'https://vms-api\.p\.uliza\.jp/v1/prog-index\.m3u8[^"]+', player_data,
                'm3u8 url', group=(0), default=None),
            video_id, errnote=False)

        m3u8_type = self._search_regex(
            r'https://.+?\.cloudfront\.net/hls/(?P<type>dvr|video)/.+\.m3u8',
            traverse_obj(formats, (0, 'url')), 'm3u8 playlist url', group=('type'), fatal=False, default=None)
        if m3u8_type == 'video':
            live_status = 'is_live'
        elif m3u8_type == 'dvr':
            # short-term archives.
            live_status = 'was_live'
        else:
            # VoD or long-term archives.
            live_status = 'not_live'

        return {
            'id': video_id,
            'title': self._html_extract_title(webpage),
            'formats': formats,
            'live_status': live_status,
        }


Review comment (bug):
- `errnote=False` is not appropriate here IMO, it will make debugging very difficult, since the regex search also has a default
- Why do we want this to be non-fatal, anyways? It doesn't look like we are extracting upcoming livestreams
- Not using a capture group and having `[^"]+` at the end of the pattern could match much more than we are expecting, e.g. if the javascript is using single-quotes instead
```suggestion
        formats = self._extract_m3u8_formats(
            self._search_regex(
                r'["\'](https://vms-api\.p\.uliza\.jp/v1/prog-index\.m3u8[^"\']+)', player_data,
                'm3u8 url', default=None),
            video_id, fatal=False)
```

Code after:
            'skip_download': True,
            'ignore_no_formats_error': True,
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)

        expires = int_or_none(traverse_obj(parse_qs(url), ('expires', 0)))
        if expires and expires <= time_seconds():
            raise ExtractorError('The link is expired.', video_id=video_id, expected=True)

        webpage = self._download_webpage(url, video_id)

        player_data = self._download_webpage(
            self._search_regex(
                r'<script [^>]*\bsrc="(https://player-api\.p\.uliza\.jp/v1/players/[^"]+)"',
                webpage, 'player data url'),
            video_id, headers={'Referer': 'https://ulizaportal.jp/'},
            note='Fetching player data', errnote='Unable to fetch player data')

        formats = self._extract_m3u8_formats(
            self._search_regex(
                r'["\'](https://vms-api\.p\.uliza\.jp/v1/prog-index\.m3u8[^"\']+)', player_data,
                'm3u8 url', default=None),
            video_id, fatal=False)
        m3u8_type = self._search_regex(
            r'/hls/(dvr|video)/', traverse_obj(formats, (0, 'url')), 'm3u8 type', default=None)

        return {
            'id': video_id,
            'title': self._html_extract_title(webpage),
            'formats': formats,
            'live_status': {
                'video': 'is_live',
                'dvr': 'was_live',  # short-term archives
            }.get(m3u8_type, 'not_live'),  # VOD or long-term archives
        }