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

Code before:
            'id': '2249992771553',
            'ext': 'mp4',
            'title': 'The National | Women’s soccer pay, Florida seawater, Swift quake',
            'description': 'July 28, 2023 | Canada’s women’s soccer team reaches an interim deal on compensation but says the fight is far from over. The water temperature off the coast of Florida hits hot-tub levels. Plus, Taylor Swift fans cause a small earthquake in Seattle.',
            'timestamp': 1690596000,
            'duration': 2716.333,
            'subtitles': {
                'eng': [
                    {
                        'ext': 'vtt',
                        'protocol': 'm3u8_native',
                    }
                ]
            },
            'thumbnail': 'https://thumbnails.cbc.ca/maven_legacy/thumbnails/481/326/thumbnail.jpeg',
            'uploader': 'CBCC-NEW',
            'chapters': [
                {'end_time': 1196.0, 'start_time': 0.0},
                {'end_time': 1398.0, 'start_time': 1196.0},
                {'end_time': 1753.0, 'start_time': 1398.0},
                {'end_time': 2395.0, 'start_time': 1753.0},
                {'end_time': 2716.333, 'start_time': 2395.0}
            ],
            'upload_date': '20230729',
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        return {
            '_type': 'url_transparent',
            'ie_key': 'ThePlatform',
            'url': smuggle_url(
                'http://link.theplatform.com/s/ExhSPC/media/guid/2655402169/%s?mbr=true&formats=MPEG4,FLV,MP3' % video_id, {
                    'force_smil_url': True
                }),
            'id': video_id,
            # needed because the m3u8 stream bandwidth info is wrong at least sometimes,
            # making the format chooser prefer a supposedly higher quality file when it's just the same mp4 split up and served via hls.
            # Since the bandwidth for downloading the direct mp4 does not seem to be limited, it's better to just download the whole mp4 file at once.
            '_format_sort_fields': ('res', 'proto')
        }


class CBCGemIE(InfoExtractor):
    IE_NAME = 'gem.cbc.ca'
    _VALID_URL = r'https?://gem\.cbc\.ca/(?:media/)?(?P<id>[0-9a-z-]+/s[0-9]+[a-z][0-9]+)'
    _TESTS = [{
        # This is a normal, public, TV show video
        'url': 'https://gem.cbc.ca/media/schitts-creek/s06e01',
        'md5': '93dbb31c74a8e45b378cf13bd3f6f11e',

Review comment (suggestion):
comment could use some more brevity
`md5` for long description
`count` for chapters
```suggestion
    }, {
        # Has subtitles
        # These broadcasts expire after ~1 month, can find new test URL here:
        # https://www.cbc.ca/player/news/TV%20Shows/The%20National/Latest%20Broadcast
        'url': 'http://www.cbc.ca/player/play/2249992771553',
        'md5': '2f2fb675dd4f0f8a5bb7588d1b13bacd',
        'info_dict': {
            'id': '2249992771553',
            'ext': 'mp4',
            'title': 'The National | Women’s soccer pay, Florida seawater, Swift quake',
            'description': 'md5:adba28011a56cfa47a080ff198dad27a',
            'timestamp': 1690596000,
            'duration': 2716.333,
            'subtitles': {'eng': [{'ext': 'vtt', 'protocol': 'm3u8_native'}]},
            'thumbnail': 'https://thumbnails.cbc.ca/maven_legacy/thumbnails/481/326/thumbnail.jpeg',
            'uploader': 'CBCC-NEW',
            'chapters': 'count:5',
            'upload_date': '20230729',
        },
    }]
```

Code after:
            'ext': 'mp4',
            'title': 'The National | Women’s soccer pay, Florida seawater, Swift quake',
            'description': 'md5:adba28011a56cfa47a080ff198dad27a',
            'timestamp': 1690596000,
            'duration': 2716.333,
            'subtitles': {'eng': [{'ext': 'vtt', 'protocol': 'm3u8_native'}]},
            'thumbnail': 'https://thumbnails.cbc.ca/maven_legacy/thumbnails/481/326/thumbnail.jpeg',
            'uploader': 'CBCC-NEW',
            'chapters': 'count:5',
            'upload_date': '20230729',
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        return {
            '_type': 'url_transparent',
            'ie_key': 'ThePlatform',
            'url': smuggle_url(
                'http://link.theplatform.com/s/ExhSPC/media/guid/2655402169/%s?mbr=true&formats=MPEG4,FLV,MP3' % video_id, {
                    'force_smil_url': True
                }),
            'id': video_id,
            '_format_sort_fields': ('res', 'proto')  # Prioritize direct http formats over HLS
        }


class CBCGemIE(InfoExtractor):
    IE_NAME = 'gem.cbc.ca'
    _VALID_URL = r'https?://gem\.cbc\.ca/(?:media/)?(?P<id>[0-9a-z-]+/s[0-9]+[a-z][0-9]+)'
    _TESTS = [{
        # This is a normal, public, TV show video
        'url': 'https://gem.cbc.ca/media/schitts-creek/s06e01',
        'md5': '93dbb31c74a8e45b378cf13bd3f6f11e',
        'info_dict': {
            'id': 'schitts-creek/s06e01',
            'ext': 'mp4',
            'title': 'Smoke Signals',
            'description': 'md5:929868d20021c924020641769eb3e7f1',
            'thumbnail': 'https://images.radio-canada.ca/v1/synps-cbc/episode/perso/cbc_schitts_creek_season_06e01_thumbnail_v01.jpg?im=Resize=(Size)',
            'duration': 1314,
            'categories': ['comedy'],
            'series': 'Schitt\'s Creek',
            'season': 'Season 6',
            'season_number': 6,
            'episode': 'Smoke Signals',
            'episode_number': 1,
            'episode_id': 'schitts-creek/s06e01',
        },
        'params': {'format': 'bv'},
        'skip': 'Geo-restricted to Canada',