[atresplayer] fix authentication

This commit is contained in:
Ramón Sola 2021-10-04 09:39:18 +02:00
parent b11c04a8ae
commit 5a16302569

View file

@ -38,7 +38,6 @@ class AtresPlayerIE(InfoExtractor):
'only_matching': True, 'only_matching': True,
}, },
] ]
_API_BASE = 'https://api.atresplayer.com/'
def _real_initialize(self): def _real_initialize(self):
self._login() self._login()
@ -56,23 +55,18 @@ def _login(self):
if username is None: if username is None:
return return
self._request_webpage(
self._API_BASE + 'login', None, 'Downloading login page')
try: try:
target_url = self._download_json( self._download_webpage(
'https://account.atresmedia.com/api/login', None, 'https://account.atresplayer.com/auth/v1/login', None,
'Logging in', headers={ 'Logging in', headers={
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded'
}, data=urlencode_postdata({ }, data=urlencode_postdata({
'username': username, 'username': username,
'password': password, 'password': password,
}))['targetUrl'] }))
except ExtractorError as e: except ExtractorError as e:
self._handle_error(e, 400) self._handle_error(e, 400)
self._request_webpage(target_url, None, 'Following Target URL')
def _real_extract(self, url): def _real_extract(self, url):
display_id, video_id = self._match_valid_url(url).groups() display_id, video_id = self._match_valid_url(url).groups()