[mangoxo] add login support (#184)

A very recent change: It is now only possible to see more
than the first 5 images of an album if you are logged in.
pull/230/head
Mike Fährmann 6 years ago
parent 49a6522c38
commit d9b94a585d
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -61,7 +61,7 @@ MangaDex https://mangadex.org/ Chapters, Manga
Mangapanda https://www.mangapanda.com/ Chapters, Manga
MangaPark https://mangapark.me/ Chapters, Manga
Mangareader https://www.mangareader.net/ Chapters, Manga
Mangoxo https://www.mangoxo.com/ Albums, Channels
Mangoxo https://www.mangoxo.com/ Albums, Channels Optional
Newgrounds https://www.newgrounds.com/ Images from Users, individual Images, Videos
Ngomik http://ngomik.in/ Chapters
nhentai https://nhentai.net/ Galleries, Search Results

@ -9,13 +9,45 @@
"""Extractors for https://www.mangoxo.com/"""
from .common import Extractor, Message
from .. import text
from .. import text, exception
from ..cache import cache
class MangoxoBase():
"""Base class for mangoxo extractors"""
category = "mangoxo"
root = "https://www.mangoxo.com"
cookiedomain = "www.mangoxo.com"
cookienames = ("SESSION",)
_warning = True
def login(self):
username, password = self._get_auth_info()
if username:
self._update_cookies(self._login_impl(username, password))
elif MangoxoBase._warning:
MangoxoBase._warning = False
self.log.warning("Unauthenticated users cannot see "
"more than 5 images per album")
@cache(maxage=3*3600, keyarg=1)
def _login_impl(self, username, password):
self.log.info("Logging in as %s", username)
url = self.root + "/login/loginxmm"
headers = {
"X-Requested-With": "XMLHttpRequest",
"Referer": self.root + "/login",
}
data = {
"name": username,
"password": password,
}
response = self.request(url, method="POST", headers=headers, data=data)
session = response.cookies.get("SESSION")
if not session:
raise exception.AuthenticationError()
return {"SESSION": session}
@staticmethod
def _total_pages(page):
@ -53,6 +85,7 @@ class MangoxoAlbumExtractor(MangoxoBase, Extractor):
self.album_id = match.group(1)
def items(self):
self.login()
url = "{}/album/{}/".format(self.root, self.album_id)
page = self.request(url).text
data = self.metadata(page)
@ -117,6 +150,7 @@ class MangoxoChannelExtractor(MangoxoBase, Extractor):
self.channel_id = match.group(1)
def items(self):
self.login()
yield Message.Version, 1
url = "{}/channel/{}/".format(self.root, self.channel_id)
num = total = 1

@ -102,6 +102,7 @@ AUTH_MAP = {
"flickr" : "Optional (OAuth)",
"idolcomplex": "Optional",
"luscious" : "Optional",
"mangoxo" : "Optional",
"nijie" : "Required",
"pixiv" : "Required",
"reddit" : "Optional (OAuth)",

@ -228,6 +228,7 @@ def setup_test_config():
config.set(("extractor", "seiga", "username"), email)
config.set(("extractor", "danbooru", "username"), None)
config.set(("extractor", "twitter" , "username"), None)
config.set(("extractor", "mangoxo" , "password"), "VZ8DL3983u")
config.set(("extractor", "deviantart", "client-id"), "7777")
config.set(("extractor", "deviantart", "client-secret"),

Loading…
Cancel
Save