[rh:websockets] Support websockets 14.0+ (#11616)
[yt-dlp3.git] / yt_dlp / extractor / ctv.py
bloba41dab11b1b6573f0c493d23d10df4cd0960636c
1 from .common import InfoExtractor
4 class CTVIE(InfoExtractor):
5 _VALID_URL = r'https?://(?:www\.)?ctv\.ca/(?P<id>(?:show|movie)s/[^/]+/[^/?#&]+)'
6 _TESTS = [{
7 'url': 'https://www.ctv.ca/shows/your-morning/wednesday-december-23-2020-s5e88',
8 'info_dict': {
9 'id': '2102249',
10 'ext': 'flv',
11 'title': 'Wednesday, December 23, 2020',
12 'thumbnail': r're:^https?://.*\.jpg$',
13 'description': 'Your Morning delivers original perspectives and unique insights into the headlines of the day.',
14 'timestamp': 1608732000,
15 'upload_date': '20201223',
16 'series': 'Your Morning',
17 'season': '2020-2021',
18 'season_number': 5,
19 'episode_number': 88,
20 'tags': ['Your Morning'],
21 'categories': ['Talk Show'],
22 'duration': 7467.126,
24 }, {
25 'url': 'https://www.ctv.ca/movies/adam-sandlers-eight-crazy-nights/adam-sandlers-eight-crazy-nights',
26 'only_matching': True,
29 def _real_extract(self, url):
30 display_id = self._match_id(url)
31 content = self._download_json(
32 'https://www.ctv.ca/space-graphql/graphql', display_id, query={
33 'query': '''{
34 resolvedPath(path: "/%s") {
35 lastSegment {
36 content {
37 ... on AxisContent {
38 axisId
39 videoPlayerDestCode
44 }''' % display_id, # noqa: UP031
45 })['data']['resolvedPath']['lastSegment']['content']
46 video_id = content['axisId']
47 return self.url_result(
48 '9c9media:{}:{}'.format(content['videoPlayerDestCode'], video_id),
49 'NineCNineMedia', video_id)