Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Backups
youtube-dl
Commits
7b6e7608
Commit
7b6e7608
authored
Mar 06, 2019
by
Remita Amine
Browse files
[toutv] detect invalid login error
parent
829685b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
12 deletions
+20
-12
youtube_dl/extractor/toutv.py
youtube_dl/extractor/toutv.py
+20
-12
No files found.
youtube_dl/extractor/toutv.py
View file @
7b6e7608
...
...
@@ -4,7 +4,9 @@ from __future__ import unicode_literals
import
json
from
.radiocanada
import
RadioCanadaIE
from
..compat
import
compat_HTTPError
from
..utils
import
(
ExtractorError
,
int_or_none
,
merge_dicts
,
)
...
...
@@ -42,18 +44,24 @@ class TouTvIE(RadioCanadaIE):
email
,
password
=
self
.
_get_login_info
()
if
email
is
None
:
return
self
.
_access_token
=
self
.
_download_json
(
'https://services.radio-canada.ca/toutv/profiling/accounts/login'
,
None
,
'Logging in'
,
data
=
json
.
dumps
({
'ClientId'
:
self
.
_CLIENT_KEY
,
'ClientSecret'
:
'34026772-244b-49b6-8b06-317b30ac9a20'
,
'Email'
:
email
,
'Password'
:
password
,
'Scope'
:
'id.write media-validation.read'
,
}).
encode
(),
headers
=
{
'Authorization'
:
'client-key '
+
self
.
_CLIENT_KEY
,
'Content-Type'
:
'application/json;charset=utf-8'
,
})[
'access_token'
]
try
:
self
.
_access_token
=
self
.
_download_json
(
'https://services.radio-canada.ca/toutv/profiling/accounts/login'
,
None
,
'Logging in'
,
data
=
json
.
dumps
({
'ClientId'
:
self
.
_CLIENT_KEY
,
'ClientSecret'
:
'34026772-244b-49b6-8b06-317b30ac9a20'
,
'Email'
:
email
,
'Password'
:
password
,
'Scope'
:
'id.write media-validation.read'
,
}).
encode
(),
headers
=
{
'Authorization'
:
'client-key '
+
self
.
_CLIENT_KEY
,
'Content-Type'
:
'application/json;charset=utf-8'
,
})[
'access_token'
]
except
ExtractorError
as
e
:
if
isinstance
(
e
.
cause
,
compat_HTTPError
)
and
e
.
cause
.
code
==
401
:
error
=
self
.
_parse_json
(
e
.
cause
.
read
().
decode
(),
None
)[
'Message'
]
raise
ExtractorError
(
error
,
expected
=
True
)
raise
self
.
_claims
=
self
.
_call_api
(
'validation/v2/getClaims'
)[
'claims'
]
def
_real_extract
(
self
,
url
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment