0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-30 03:33:02 +00:00

[globo] handle login errors

This commit is contained in:
Remita Amine 2018-05-21 15:07:24 +01:00
parent db2058f63e
commit e518749300

View file

@ -8,7 +8,10 @@
import re import re
from .common import InfoExtractor from .common import InfoExtractor
from ..compat import compat_str from ..compat import (
compat_HTTPError,
compat_str,
)
from ..utils import ( from ..utils import (
ExtractorError, ExtractorError,
float_or_none, float_or_none,
@ -71,6 +74,7 @@ def _real_initialize(self):
if email is None: if email is None:
return return
try:
self._download_json( self._download_json(
'https://login.globo.com/api/authentication', None, data=json.dumps({ 'https://login.globo.com/api/authentication', None, data=json.dumps({
'payload': { 'payload': {
@ -81,6 +85,11 @@ def _real_initialize(self):
}).encode(), headers={ }).encode(), headers={
'Content-Type': 'application/json; charset=utf-8', 'Content-Type': 'application/json; charset=utf-8',
}) })
except ExtractorError as e:
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401:
resp = self._parse_json(e.cause.read(), None)
raise ExtractorError(resp.get('userMessage') or resp['id'], expected=True)
raise
self._LOGGED_IN = True self._LOGGED_IN = True
def _real_extract(self, url): def _real_extract(self, url):