1 from .common
import InfoExtractor
11 class CanalplusIE(InfoExtractor
):
12 IE_DESC
= 'mycanal.fr and piwiplus.fr'
13 _VALID_URL
= r
'https?://(?:www\.)?(?P<site>mycanal|piwiplus)\.fr/(?:[^/]+/)*(?P<display_id>[^?/]+)(?:\.html\?.*\bvid=|/p/)(?P<id>\d+)'
14 _VIDEO_INFO_TEMPLATE
= 'http://service.canal-plus.com/video/rest/getVideosLiees/%s/%s?format=json'
17 'piwiplus': 'teletoon',
20 # Only works for direct mp4 URLs
21 _GEO_COUNTRIES
= ['FR']
24 'url': 'https://www.mycanal.fr/d17-emissions/lolywood/p/1397061',
27 'display_id': 'lolywood',
29 'title': 'Euro 2016 : Je préfère te prévenir - Lolywood - Episode 34',
30 'description': 'md5:7d97039d455cb29cdba0d652a0efaa5e',
31 'upload_date': '20160602',
34 # geo restricted, bypassed
35 'url': 'http://www.piwiplus.fr/videos-piwi/pid1405-le-labyrinthe-boing-super-ranger.html?vid=1108190',
38 'display_id': 'pid1405-le-labyrinthe-boing-super-ranger',
40 'title': 'BOING SUPER RANGER - Ep : Le labyrinthe',
41 'description': 'md5:4cea7a37153be42c1ba2c1d3064376ff',
42 'upload_date': '20140724',
44 'expected_warnings': ['HTTP Error 403: Forbidden'],
47 def _real_extract(self
, url
):
48 site
, display_id
, video_id
= self
._match
_valid
_url
(url
).groups()
50 site_id
= self
._SITE
_ID
_MAP
[site
]
52 info_url
= self
._VIDEO
_INFO
_TEMPLATE
% (site_id
, video_id
)
53 video_data
= self
._download
_json
(info_url
, video_id
, 'Downloading video JSON')
55 if isinstance(video_data
, list):
56 video_data
= next(video
for video
in video_data
if video
.get('ID') == video_id
)
57 media
= video_data
['MEDIA']
58 infos
= video_data
['INFOS']
60 preference
= qualities(['MOBILE', 'BAS_DEBIT', 'HAUT_DEBIT', 'HD'])
62 # _, fmt_url = next(iter(media['VIDEOS'].items()))
63 # if '/geo' in fmt_url.lower():
64 # response = self._request_webpage(
65 # HEADRequest(fmt_url), video_id,
66 # 'Checking if the video is georestricted')
67 # if '/blocage' in response.url:
68 # raise ExtractorError(
69 # 'The video is not available in your country',
73 for format_id
, format_url
in media
['VIDEOS'].items():
76 if format_id
== 'HLS':
77 formats
.extend(self
._extract
_m
3u8_formats
(
78 format_url
, video_id
, 'mp4', 'm3u8_native', m3u8_id
=format_id
, fatal
=False))
79 elif format_id
== 'HDS':
80 formats
.extend(self
._extract
_f
4m
_formats
(
81 format_url
+ '?hdcore=2.11.3', video_id
, f4m_id
=format_id
, fatal
=False))
84 # the secret extracted from ya function in http://player.canalplus.fr/common/js/canalPlayer.js
85 'url': format_url
+ '?secret=pqzerjlsmdkjfoiuerhsdlfknaes',
86 'format_id': format_id
,
87 'quality': preference(format_id
),
93 } for image_id
, image_url
in media
.get('images', {}).items()]
95 titrage
= infos
['TITRAGE']
99 'display_id': display_id
,
100 'title': '{} - {}'.format(titrage
['TITRE'], titrage
['SOUS_TITRE']),
101 'upload_date': unified_strdate(infos
.get('PUBLICATION', {}).get('DATE')),
102 'thumbnails': thumbnails
,
103 'description': infos
.get('DESCRIPTION'),
104 'duration': int_or_none(infos
.get('DURATION')),
105 'view_count': int_or_none(infos
.get('NB_VUES')),
106 'like_count': int_or_none(infos
.get('NB_LIKES')),
107 'comment_count': int_or_none(infos
.get('NB_COMMENTS')),