1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 18:53:21 +01:00

[mangoxo] fix login

This commit is contained in:
Mike Fährmann 2019-04-30 15:14:54 +02:00
parent 8acbe863cb
commit 1c665fd4bd
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -34,6 +34,11 @@ class MangoxoExtractor(Extractor):
def _login_impl(self, username, password):
self.log.info("Logging in as %s", username)
page = self.request(self.root + "/login/").text
token = text.extract(page, 'id="loginToken" value="', '"')[0]
if not token:
self.log.warning("failed to extract 'loginToken'")
url = self.root + "/login/loginxmm"
headers = {
"X-Requested-With": "XMLHttpRequest",
@ -42,12 +47,13 @@ class MangoxoExtractor(Extractor):
data = {
"name": username,
"password": password,
"loginToken": token,
}
response = self.request(url, method="POST", headers=headers, data=data)
session = response.cookies.get("SESSION")
if not session:
if response.json().get("result") != "1":
raise exception.AuthenticationError()
return {"SESSION": session}
return {"SESSION": self.session.cookies.get("SESSION")}
@staticmethod
def _total_pages(page):