1 from .common
import InfoExtractor
10 class CanalAlphaIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:www\.)?canalalpha\.ch/play/[^/]+/[^/]+/(?P<id>\d+)/?.*'
14 'url': 'https://www.canalalpha.ch/play/le-journal/episode/24520/jeudi-28-octobre-2021',
18 'title': 'Jeudi 28 octobre 2021',
19 'description': 'md5:d30c6c3e53f8ad40d405379601973b30',
20 'thumbnail': 'https://static.canalalpha.ch/poster/journal/journal_20211028.jpg',
21 'upload_date': '20211028',
24 'params': {'skip_download': True},
26 'url': 'https://www.canalalpha.ch/play/le-journal/topic/24512/la-poste-fait-de-neuchatel-un-pole-cryptographique',
30 'title': 'La Poste fait de Neuchâtel un pôle cryptographique',
31 'description': 'md5:4ba63ae78a0974d1a53d6703b6e1dedf',
32 'thumbnail': 'https://static.canalalpha.ch/poster/news/news_39712.jpg',
33 'upload_date': '20211028',
36 'params': {'skip_download': True},
38 'url': 'https://www.canalalpha.ch/play/eureka/episode/24484/ces-innovations-qui-veulent-rendre-lagriculture-plus-durable',
42 'title': 'Ces innovations qui veulent rendre l’agriculture plus durable',
43 'description': 'md5:85d594a3b5dc6ccfc4a85aba6e73b129',
44 'thumbnail': 'https://static.canalalpha.ch/poster/magazine/magazine_10236.jpg',
45 'upload_date': '20211026',
48 'params': {'skip_download': True},
50 'url': 'https://www.canalalpha.ch/play/avec-le-temps/episode/23516/redonner-de-leclat-grace-au-polissage',
54 'title': 'Redonner de l\'éclat grâce au polissage',
55 'description': 'md5:0d8fbcda1a5a4d6f6daa3165402177e1',
56 'thumbnail': 'https://static.canalalpha.ch/poster/magazine/magazine_9990.png',
57 'upload_date': '20210726',
60 'params': {'skip_download': True},
62 'url': 'https://www.canalalpha.ch/play/le-journal/topic/33500/encore-des-mesures-deconomie-dans-le-jura',
66 'title': 'Encore des mesures d\'économie dans le Jura',
67 'description': 'md5:938b5b556592f2d1b9ab150268082a80',
68 'thumbnail': 'https://static.canalalpha.ch/poster/news/news_46665.jpg',
69 'upload_date': '20240411',
74 def _real_extract(self
, url
):
75 video_id
= self
._match
_id
(url
)
76 webpage
= self
._download
_webpage
(url
, video_id
)
77 data_json
= self
._parse
_json
(self
._search
_regex
(
78 r
'window\.__SERVER_STATE__\s?=\s?({(?:(?!};)[^"]|"([^"]|\\")*")+})\s?;',
79 webpage
, 'data_json'), video_id
)['1']['data']['data']
80 manifests
= try_get(data_json
, lambda x
: x
['video']['manifests'], expected_type
=dict) or {}
85 'width': try_get(video
, lambda x
: x
['res']['width'], expected_type
=int),
86 'height': try_get(video
, lambda x
: x
['res']['height'], expected_type
=int),
87 } for video
in try_get(data_json
, lambda x
: x
['video']['mp4'], expected_type
=list) or [] if video
.get('$url')]
88 if manifests
.get('hls'):
89 fmts
, subs
= self
._extract
_m
3u8_formats
_and
_subtitles
(
90 manifests
['hls'], video_id
, m3u8_id
='hls', fatal
=False)
92 self
._merge
_subtitles
(subs
, target
=subtitles
)
93 if manifests
.get('dash'):
94 fmts
, subs
= self
._extract
_mpd
_formats
_and
_subtitles
(
95 manifests
['dash'], video_id
, mpd_id
='dash', fatal
=False)
97 self
._merge
_subtitles
(subs
, target
=subtitles
)
100 'title': data_json
.get('title').strip(),
101 'description': clean_html(dict_get(data_json
, ('longDesc', 'shortDesc'))),
102 'thumbnail': data_json
.get('poster'),
103 'upload_date': unified_strdate(dict_get(data_json
, ('webPublishAt', 'featuredAt', 'diffusionDate'))),
104 'duration': try_get(data_json
, lambda x
: x
['video']['duration'], expected_type
=int),
106 'subtitles': subtitles
,