]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/canalalpha.py
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:3de3f151180684621e85be7c10e4e613',
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}
63 def _real_extract(self
, url
):
64 id = self
._match
_id
(url
)
65 webpage
= self
._download
_webpage
(url
, id)
66 data_json
= self
._parse
_json
(self
._search
_regex
(
67 r
'window\.__SERVER_STATE__\s?=\s?({(?:(?!};)[^"]|"([^"]|\\")*")+})\s?;',
68 webpage
, 'data_json'), id)['1']['data']['data']
69 manifests
= try_get(data_json
, lambda x
: x
['video']['manifests'], expected_type
=dict) or {}
74 'width': try_get(video
, lambda x
: x
['res']['width'], expected_type
=int),
75 'height': try_get(video
, lambda x
: x
['res']['height'], expected_type
=int),
76 } for video
in try_get(data_json
, lambda x
: x
['video']['mp4'], expected_type
=list) or [] if video
.get('$url')]
77 if manifests
.get('hls'):
78 m3u8_frmts
, m3u8_subs
= self
._parse
_m
3u8_formats
_and
_subtitles
(manifests
['hls'], video_id
=id)
79 formats
.extend(m3u8_frmts
)
80 subtitles
= self
._merge
_subtitles
(subtitles
, m3u8_subs
)
81 if manifests
.get('dash'):
82 dash_frmts
, dash_subs
= self
._parse
_mpd
_formats
_and
_subtitles
(manifests
['dash'])
83 formats
.extend(dash_frmts
)
84 subtitles
= self
._merge
_subtitles
(subtitles
, dash_subs
)
85 self
._sort
_formats
(formats
)
88 'title': data_json
.get('title').strip(),
89 'description': clean_html(dict_get(data_json
, ('longDesc', 'shortDesc'))),
90 'thumbnail': data_json
.get('poster'),
91 'upload_date': unified_strdate(dict_get(data_json
, ('webPublishAt', 'featuredAt', 'diffusionDate'))),
92 'duration': try_get(data_json
, lambda x
: x
['video']['duration'], expected_type
=int),
94 'subtitles': subtitles
,