1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 10:42:34 +01:00

[mangoxo] fix login

This commit is contained in:
Mike Fährmann 2020-03-08 23:01:51 +01:00
parent ebc70e87ce
commit a63a376ad2
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
3 changed files with 22 additions and 18 deletions

View File

@ -22,7 +22,7 @@ class HentainexusGalleryExtractor(GalleryExtractor):
test = (
("https://hentainexus.com/view/5688", {
"url": "746d0043e20030f1171aae5ea113176607302517",
"keyword": "c1b7091e2bc2f733f6401711e072ad11cf93dd69",
"keyword": "77702b42f8f76ecfe5d8a14cfbbcbd855eb14d7f",
}),
("https://hentainexus.com/read/5688"),
)

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Mike Fährmann
# Copyright 2019-2020 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@ -12,6 +12,7 @@ from .common import Extractor, Message
from .. import text, exception
from ..cache import cache
import hashlib
import time
class MangoxoExtractor(Extractor):
@ -35,27 +36,33 @@ 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.debug("failed to extract 'loginToken'")
url = self.root + "/login/loginxmm"
url = self.root + "/api/login"
headers = {
"X-Requested-With": "XMLHttpRequest",
"Referer": self.root + "/login",
}
data = {
"name": username,
"password": hashlib.md5(password.encode()).hexdigest(),
"loginToken": token,
}
data = self._sign_by_md5(username, password)
response = self.request(url, method="POST", headers=headers, data=data)
if response.json().get("result") != "1":
raise exception.AuthenticationError()
data = response.json()
if str(data.get("result")) != "1":
raise exception.AuthenticationError(data.get("msg"))
return {"SESSION": self.session.cookies.get("SESSION")}
@staticmethod
def _sign_by_md5(username, password):
# https://dns.mangoxo.com/libs/plugins/phoenix-ui/js/phoenix-ui.js
params = [
("username" , username),
("password" , password),
("timestamp", str(int(time.time()))),
]
query = "&".join("=".join(item) for item in sorted(params))
query += "&secretKey=996293536"
sign = hashlib.md5(query.encode()).hexdigest()
params.append(("sign", sign.upper()))
return params
@staticmethod
def _total_pages(page):
return text.parse_int(text.extract(page, "total :", ",")[0])

View File

@ -28,10 +28,7 @@ TRAVIS_SKIP = {
# temporary issues, etc.
BROKEN = {
"35photo",
"dokireader",
"furaffinity",
"mangapark",
"mangoxo",
"photobucket",
}