]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/canalplus.py
2 from __future__
import unicode_literals
5 from .common
import InfoExtractor
15 class CanalplusIE(InfoExtractor
):
16 IE_DESC
= 'mycanal.fr and piwiplus.fr'
17 _VALID_URL
= r
'https?://(?:www\.)?(?P<site>mycanal|piwiplus)\.fr/(?:[^/]+/)*(?P<display_id>[^?/]+)(?:\.html\?.*\bvid=|/p/)(?P<id>\d+)'
18 _VIDEO_INFO_TEMPLATE
= 'http://service.canal-plus.com/video/rest/getVideosLiees/%s/%s?format=json'
21 'piwiplus': 'teletoon',
24 # Only works for direct mp4 URLs
25 _GEO_COUNTRIES
= ['FR']
28 'url': 'https://www.mycanal.fr/d17-emissions/lolywood/p/1397061',
31 'display_id': 'lolywood',
33 'title': 'Euro 2016 : Je préfère te prévenir - Lolywood - Episode 34',
34 'description': 'md5:7d97039d455cb29cdba0d652a0efaa5e',
35 'upload_date': '20160602',
38 # geo restricted, bypassed
39 'url': 'http://www.piwiplus.fr/videos-piwi/pid1405-le-labyrinthe-boing-super-ranger.html?vid=1108190',
42 'display_id': 'pid1405-le-labyrinthe-boing-super-ranger',
44 'title': 'BOING SUPER RANGER - Ep : Le labyrinthe',
45 'description': 'md5:4cea7a37153be42c1ba2c1d3064376ff',
46 'upload_date': '20140724',
48 'expected_warnings': ['HTTP Error 403: Forbidden'],
51 def _real_extract(self
, url
):
52 site
, display_id
, video_id
= self
._match
_valid
_url
(url
).groups()
54 site_id
= self
._SITE
_ID
_MAP
[site
]
56 info_url
= self
._VIDEO
_INFO
_TEMPLATE
% (site_id
, video_id
)
57 video_data
= self
._download
_json
(info_url
, video_id
, 'Downloading video JSON')
59 if isinstance(video_data
, list):
60 video_data
= [video
for video
in video_data
if video
.get('ID') == video_id
][0]
61 media
= video_data
['MEDIA']
62 infos
= video_data
['INFOS']
64 preference
= qualities(['MOBILE', 'BAS_DEBIT', 'HAUT_DEBIT', 'HD'])
66 # _, fmt_url = next(iter(media['VIDEOS'].items()))
67 # if '/geo' in fmt_url.lower():
68 # response = self._request_webpage(
69 # HEADRequest(fmt_url), video_id,
70 # 'Checking if the video is georestricted')
71 # if '/blocage' in response.geturl():
72 # raise ExtractorError(
73 # 'The video is not available in your country',
77 for format_id
, format_url
in media
['VIDEOS'].items():
80 if format_id
== 'HLS':
81 formats
.extend(self
._extract
_m
3u8_formats
(
82 format_url
, video_id
, 'mp4', 'm3u8_native', m3u8_id
=format_id
, fatal
=False))
83 elif format_id
== 'HDS':
84 formats
.extend(self
._extract
_f
4m
_formats
(
85 format_url
+ '?hdcore=2.11.3', video_id
, f4m_id
=format_id
, fatal
=False))
88 # the secret extracted from ya function in http://player.canalplus.fr/common/js/canalPlayer.js
89 'url': format_url
+ '?secret=pqzerjlsmdkjfoiuerhsdlfknaes',
90 'format_id': format_id
,
91 'quality': preference(format_id
),
93 self
._sort
_formats
(formats
)
98 } for image_id
, image_url
in media
.get('images', {}).items()]
100 titrage
= infos
['TITRAGE']
104 'display_id': display_id
,
105 'title': '%s - %s' % (titrage
['TITRE'],
106 titrage
['SOUS_TITRE']),
107 'upload_date': unified_strdate(infos
.get('PUBLICATION', {}).get('DATE')),
108 'thumbnails': thumbnails
,
109 'description': infos
.get('DESCRIPTION'),
110 'duration': int_or_none(infos
.get('DURATION')),
111 'view_count': int_or_none(infos
.get('NB_VUES')),
112 'like_count': int_or_none(infos
.get('NB_LIKES')),
113 'comment_count': int_or_none(infos
.get('NB_COMMENTS')),