]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/canalalpha.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
13 class CanalAlphaIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?canalalpha\.ch/play/[^/]+/[^/]+/(?P<id>\d+)/?.*'
17 'url': 'https://www.canalalpha.ch/play/le-journal/episode/24520/jeudi-28-octobre-2021',
21 'title': 'Jeudi 28 octobre 2021',
22 'description': 'md5:d30c6c3e53f8ad40d405379601973b30',
23 'thumbnail': 'https://static.canalalpha.ch/poster/journal/journal_20211028.jpg',
24 'upload_date': '20211028',
27 'params': {'skip_download': True}
29 'url': 'https://www.canalalpha.ch/play/le-journal/topic/24512/la-poste-fait-de-neuchatel-un-pole-cryptographique',
33 'title': 'La Poste fait de Neuchâtel un pôle cryptographique',
34 'description': 'md5:4ba63ae78a0974d1a53d6703b6e1dedf',
35 'thumbnail': 'https://static.canalalpha.ch/poster/news/news_39712.jpg',
36 'upload_date': '20211028',
39 'params': {'skip_download': True}
41 'url': 'https://www.canalalpha.ch/play/eureka/episode/24484/ces-innovations-qui-veulent-rendre-lagriculture-plus-durable',
45 'title': 'Ces innovations qui veulent rendre l’agriculture plus durable',
46 'description': 'md5:3de3f151180684621e85be7c10e4e613',
47 'thumbnail': 'https://static.canalalpha.ch/poster/magazine/magazine_10236.jpg',
48 'upload_date': '20211026',
51 'params': {'skip_download': True}
53 'url': 'https://www.canalalpha.ch/play/avec-le-temps/episode/23516/redonner-de-leclat-grace-au-polissage',
57 'title': 'Redonner de l\'éclat grâce au polissage',
58 'description': 'md5:0d8fbcda1a5a4d6f6daa3165402177e1',
59 'thumbnail': 'https://static.canalalpha.ch/poster/magazine/magazine_9990.png',
60 'upload_date': '20210726',
63 'params': {'skip_download': True}
66 def _real_extract(self
, url
):
67 id = self
._match
_id
(url
)
68 webpage
= self
._download
_webpage
(url
, id)
69 data_json
= self
._parse
_json
(self
._search
_regex
(
70 r
'window\.__SERVER_STATE__\s?=\s?({(?:(?!};)[^"]|"([^"]|\\")*")+})\s?;',
71 webpage
, 'data_json'), id)['1']['data']['data']
72 manifests
= try_get(data_json
, lambda x
: x
['video']['manifests'], expected_type
=dict) or {}
77 'width': try_get(video
, lambda x
: x
['res']['width'], expected_type
=int),
78 'height': try_get(video
, lambda x
: x
['res']['height'], expected_type
=int),
79 } for video
in try_get(data_json
, lambda x
: x
['video']['mp4'], expected_type
=list) or [] if video
.get('$url')]
80 if manifests
.get('hls'):
81 m3u8_frmts
, m3u8_subs
= self
._parse
_m
3u8_formats
_and
_subtitles
(manifests
['hls'], id)
82 formats
.extend(m3u8_frmts
)
83 subtitles
= self
._merge
_subtitles
(subtitles
, m3u8_subs
)
84 if manifests
.get('dash'):
85 dash_frmts
, dash_subs
= self
._parse
_mpd
_formats
_and
_subtitles
(manifests
['dash'], id)
86 formats
.extend(dash_frmts
)
87 subtitles
= self
._merge
_subtitles
(subtitles
, dash_subs
)
88 self
._sort
_formats
(formats
)
91 'title': data_json
.get('title').strip(),
92 'description': clean_html(dict_get(data_json
, ('longDesc', 'shortDesc'))),
93 'thumbnail': data_json
.get('poster'),
94 'upload_date': unified_strdate(dict_get(data_json
, ('webPublishAt', 'featuredAt', 'diffusionDate'))),
95 'duration': try_get(data_json
, lambda x
: x
['video']['duration'], expected_type
=int),
97 'subtitles': subtitles
,