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

Code before:
            'duration': 420.0,
            'uploader': 'Ishu Patel',
            'thumbnail': r're:^https?://.*\.jpg$',
        },
        'params': {'skip_download': 'm3u8'},
    }]

    def _real_extract(self, url):
        site, type_, slug = self._match_valid_url(url).group('site', 'type', 'id')
        # Need to construct the URL since we match /embed/player/ URLs as well
        webpage, urlh = self._download_webpage_handle(f'https://www.{site}.ca/{type_}/{slug}/', slug)
        # type_ can change from film to serie(s) after redirect; new slug may have episode number
        type_, slug = self._match_valid_url(urlh.url).group('type', 'id')

        embed_url = self._html_search_regex(
            r'<script.*<iframe\s+src=[\\"\']+(https?:[^\\"\']+)', webpage, 'embed url')
        video_id = self._match_id(embed_url)  # embed url has unique slug
        player = self._download_webpage(embed_url, video_id, 'Downloading player page')
        if 'MESSAGE_GEOBLOCKED' in player:
            self.raise_geo_restricted(countries=self._GEO_COUNTRIES)

        formats, subtitles = self._extract_m3u8_formats_and_subtitles(
            self._html_search_regex(r'["\']?source["\']?:\s*["\']([^"\']+\.m3u8)', player, 'm3u8 url'),
            video_id, 'mp4', m3u8_id='hls')

        if dv_source := self._html_search_regex(r'dvSource:\s*\'([^\']+)', player, 'dv', default=None):
            fmts, subs = self._extract_m3u8_formats_and_subtitles(
                dv_source, video_id, 'mp4', m3u8_id='dv', preference=-2, fatal=False)
            for fmt in fmts:
                fmt['format_note'] = 'described video'
            formats.extend(fmts)
            self._merge_subtitles(subs, target=subtitles)

        info = {
            'id': video_id,
            'title': self._html_search_regex(
                r'["\']nfb_version_title["\']\s*:\s*["\']([^"\']+)',
                webpage, 'title', default=None),
            'description': self._html_search_regex(
                r'<[^>]+\bid=["\']tabSynopsis["\'][^>]*>\s*<p[^>]*>\s*([^<]+)',
                webpage, 'description', default=None),
            'thumbnail': self._html_search_regex(
                r'poster:\s*\'([^\']+)', player, 'thumbnail', default=None),
            'uploader': self._html_search_regex(
                r'<[^>]+\bitemprop=["\']director["\'][^>]*>([^<]+)', webpage, 'uploader', default=None),
            'release_year': int_or_none(self._html_search_regex(
                r'["\']nfb_version_year["\']\s*:\s*["\']([^"\']+)',
                webpage, 'release_year', default=None)),
        } if type_ == 'film' else self._extract_ep_info(self._extract_ep_data(webpage, video_id, slug), video_id)

        return merge_dicts({

Review comment (suggestion):
```suggestion
        if dv_source := url_or_none(player_data.get('dvSource')):
```

Code after:
            'uploader': 'Ishu Patel',
            'thumbnail': r're:^https?://.*\.jpg$',
        },
        'params': {'skip_download': 'm3u8'},
    }]

    def _real_extract(self, url):
        site, type_, slug = self._match_valid_url(url).group('site', 'type', 'id')
        # Need to construct the URL since we match /embed/player/ URLs as well
        webpage, urlh = self._download_webpage_handle(f'https://www.{site}.ca/{type_}/{slug}/', slug)
        # type_ can change from film to serie(s) after redirect; new slug may have episode number
        type_, slug = self._match_valid_url(urlh.url).group('type', 'id')

        player_data = self._search_json(
            r'window\.PLAYER_OPTIONS\[[^\]]+\]\s*=', webpage, 'player data', slug)
        video_id = self._match_id(player_data['overlay']['url'])  # overlay url always has unique slug

        formats, subtitles = self._extract_m3u8_formats_and_subtitles(
            player_data['source'], video_id, 'mp4', m3u8_id='hls')

        if dv_source := url_or_none(player_data.get('dvSource')):
            fmts, subs = self._extract_m3u8_formats_and_subtitles(
                dv_source, video_id, 'mp4', m3u8_id='dv', preference=-2, fatal=False)
            for fmt in fmts:
                fmt['format_note'] = 'described video'
            formats.extend(fmts)
            self._merge_subtitles(subs, target=subtitles)

        info = {
            'id': video_id,
            'title': self._html_search_regex(
                r'["\']nfb_version_title["\']\s*:\s*["\']([^"\']+)',
                webpage, 'title', default=None),
            'description': self._html_search_regex(
                r'<[^>]+\bid=["\']tabSynopsis["\'][^>]*>\s*<p[^>]*>\s*([^<]+)',
                webpage, 'description', default=None),
            'thumbnail': url_or_none(player_data.get('poster')),
            'uploader': self._html_search_regex(
                r'<[^>]+\bitemprop=["\']director["\'][^>]*>([^<]+)', webpage, 'uploader', default=None),
            'release_year': int_or_none(self._html_search_regex(
                r'["\']nfb_version_year["\']\s*:\s*["\']([^"\']+)',
                webpage, 'release_year', default=None)),
        } if type_ == 'film' else self._extract_ep_info(self._extract_ep_data(webpage, video_id, slug), video_id)

        return merge_dicts({
            'formats': formats,
            'subtitles': subtitles,
        }, info, self._search_json_ld(webpage, video_id, default={}))


class NFBSeriesIE(NFBBaseIE):