3 from .radiocanada
import RadioCanadaIE
4 from ..networking
.exceptions
import HTTPError
12 class TouTvIE(RadioCanadaIE
): # XXX: Do not subclass from concrete IE
13 _NETRC_MACHINE
= 'toutv'
15 _VALID_URL
= r
'https?://ici\.tou\.tv/(?P<id>[a-zA-Z0-9_-]+(?:/S[0-9]+[EC][0-9]+)?)'
18 'url': 'http://ici.tou.tv/garfield-tout-court/S2015E17',
22 'title': 'Saison 2015 Épisode 17',
23 'description': 'La photo de famille 2',
24 'upload_date': '20100717',
28 'skip_download': True,
30 'skip': '404 Not Found',
32 'url': 'http://ici.tou.tv/hackers',
33 'only_matching': True,
35 'url': 'https://ici.tou.tv/l-age-adulte/S01C501',
36 'only_matching': True,
38 _CLIENT_KEY
= '90505c8d-9c34-4f34-8da1-3a85bdc6d4f4'
40 def _perform_login(self
, username
, password
):
42 self
._access
_token
= self
._download
_json
(
43 'https://services.radio-canada.ca/toutv/profiling/accounts/login',
44 None, 'Logging in', data
=json
.dumps({
45 'ClientId': self
._CLIENT
_KEY
,
46 'ClientSecret': '34026772-244b-49b6-8b06-317b30ac9a20',
49 'Scope': 'id.write media-validation.read',
50 }).encode(), headers
={
51 'Authorization': 'client-key ' + self
._CLIENT
_KEY
,
52 'Content-Type': 'application/json;charset=utf-8',
54 except ExtractorError
as e
:
55 if isinstance(e
.cause
, HTTPError
) and e
.cause
.status
== 401:
56 error
= self
._parse
_json
(e
.cause
.response
.read().decode(), None)['Message']
57 raise ExtractorError(error
, expected
=True)
59 self
._claims
= self
._call
_api
('validation/v2/getClaims')['claims']
61 def _real_extract(self
, url
):
62 path
= self
._match
_id
(url
)
63 metadata
= self
._download
_json
(
64 'https://services.radio-canada.ca/toutv/presentation/%s' % path
, path
, query
={
65 'client_key': self
._CLIENT
_KEY
,
69 # IsDrm does not necessarily mean the video is DRM protected (see
70 # https://github.com/ytdl-org/youtube-dl/issues/13994).
71 if not self
.get_param('allow_unplayable_formats') and metadata
.get('IsDrm'):
72 self
.report_warning('This video is probably DRM protected.', path
)
73 video_id
= metadata
['IdMedia']
74 details
= metadata
['Details']
78 'title': details
.get('OriginalTitle'),
79 'description': details
.get('Description'),
80 'thumbnail': details
.get('ImageUrl'),
81 'duration': int_or_none(details
.get('LengthInSeconds')),
82 'series': metadata
.get('ProgramTitle'),
83 'season_number': int_or_none(metadata
.get('SeasonNumber')),
84 'season': metadata
.get('SeasonTitle'),
85 'episode_number': int_or_none(metadata
.get('EpisodeNumber')),
86 'episode': metadata
.get('EpisodeTitle'),
87 }, self
._extract
_info
(metadata
.get('AppCode', 'toutv'), video_id
))