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

Code before:
        media_id = player_info.get('mediaId')
        if not media_id:
            clip_id = player_info['clipId']
            feed = self._download_json(
                f'http://tpfeed.cbc.ca/f/ExhSPC/vms_5akSXx4Ng_Zn?byCustomValue={{:mpsReleases}}{{{clip_id}}}',
                clip_id, fatal=False)
            if feed:
                media_id = try_get(feed, lambda x: x['entries'][0]['guid'], str)
            if not media_id:
                media_id = self._download_json(
                    'http://feed.theplatform.com/f/h9dtGB/punlNGjMlc1F?fields=id&byContent=byReleases%3DbyId%253D' + clip_id,
                    clip_id)['entries'][0]['id'].split('/')[-1]
        return self.url_result(f'cbcplayer:{media_id}', 'CBCPlayer', media_id)

    def _real_extract(self, url):
        display_id = self._match_id(url)
        webpage = self._download_webpage(url, display_id)
        title = (self._og_search_title(webpage, default=None)
                 or self._html_search_meta('twitter:title', webpage, 'title', default=None)
                 or self._html_extract_title(webpage))
        title = self._search_regex(
            r'^(?P<title>.+?)(?:\s*[|–-]\s*CBC.*)?$',
            title, 'cleaned title', group='title', default=title)
        data = self._search_json(
            r'window\.__INITIAL_STATE__\s*=', webpage,
            'initial state', display_id, fatal=False, default={}, transform_source=js_to_json)

        entries = [
            self._extract_player_init(player_init, display_id)
            for player_init in re.findall(r'CBC\.APP\.Caffeine\.initInstance\(({.+?})\);', webpage)]
        media_ids = []
        for media_id_re in (
                r'<iframe[^>]+src="[^"]+?mediaId=(\d+)"',
                r'<div[^>]+\bid=["\']player-(\d+)',
                r'guid["\']\s*:\s*["\'](\d+)'):
            media_ids.extend(re.findall(media_id_re, webpage))
        media_ids.extend(traverse_obj(data, (
            'detail', 'content', 'body', ..., 'content',
            lambda _, v: v['type'] == 'polopoly_media', 'content', 'sourceId', {str})))
        if content_id := traverse_obj(data, ('app', 'contentId', {str})):
            media_ids.append(content_id)
        entries.extend([
            self.url_result(f'cbcplayer:{media_id}', 'CBCPlayer', media_id)
            for media_id in orderedSet(media_ids)])
        return self.playlist_result(
            entries, display_id, strip_or_none(title),
            self._og_search_description(webpage))


class CBCPlayerIE(InfoExtractor):
    IE_NAME = 'cbc.ca:player'

Review comment (suggestion):
passing a `default` implies `fatal=False`
```suggestion
            'initial state', display_id, default={}, transform_source=js_to_json)
```

Code after:
        media_id = player_info.get('mediaId')
        if not media_id:
            clip_id = player_info['clipId']
            feed = self._download_json(
                f'http://tpfeed.cbc.ca/f/ExhSPC/vms_5akSXx4Ng_Zn?byCustomValue={{:mpsReleases}}{{{clip_id}}}',
                clip_id, fatal=False)
            if feed:
                media_id = try_get(feed, lambda x: x['entries'][0]['guid'], str)
            if not media_id:
                media_id = self._download_json(
                    'http://feed.theplatform.com/f/h9dtGB/punlNGjMlc1F?fields=id&byContent=byReleases%3DbyId%253D' + clip_id,
                    clip_id)['entries'][0]['id'].split('/')[-1]
        return self.url_result(f'cbcplayer:{media_id}', 'CBCPlayer', media_id)

    def _real_extract(self, url):
        display_id = self._match_id(url)
        webpage = self._download_webpage(url, display_id)
        title = (self._og_search_title(webpage, default=None)
                 or self._html_search_meta('twitter:title', webpage, 'title', default=None)
                 or self._html_extract_title(webpage))
        title = self._search_regex(
            r'^(?P<title>.+?)(?:\s*[|–-]\s*CBC.*)?$',
            title, 'cleaned title', group='title', default=title)
        data = self._search_json(
            r'window\.__INITIAL_STATE__\s*=', webpage,
            'initial state', display_id, default={}, transform_source=js_to_json)

        entries = [
            self._extract_player_init(player_init, display_id)
            for player_init in re.findall(r'CBC\.APP\.Caffeine\.initInstance\(({.+?})\);', webpage)]
        media_ids = []
        for media_id_re in (
                r'<iframe[^>]+src="[^"]+?mediaId=(\d+)"',
                r'<div[^>]+\bid=["\']player-(\d+)',
                r'guid["\']\s*:\s*["\'](\d+)'):
            media_ids.extend(re.findall(media_id_re, webpage))
        media_ids.extend(traverse_obj(data, (
            'detail', 'content', 'body', ..., 'content',
            lambda _, v: v['type'] == 'polopoly_media', 'content', 'sourceId', {str})))
        if content_id := traverse_obj(data, ('app', 'contentId', {str})):
            media_ids.append(content_id)
        entries.extend([
            self.url_result(f'cbcplayer:{media_id}', 'CBCPlayer', media_id)
            for media_id in orderedSet(media_ids)])
        return self.playlist_result(
            entries, display_id, strip_or_none(title),
            self._og_search_description(webpage))


class CBCPlayerIE(InfoExtractor):
    IE_NAME = 'cbc.ca:player'