[exhentai] always use e-hentai.org as domain + set nw cookie
This commit is contained in:
@@ -25,9 +25,9 @@ Desuarchive https://desuarchive.org/ Threads
|
|||||||
DeviantArt https://www.deviantart.com/ |deviantart-C| Optional (OAuth)
|
DeviantArt https://www.deviantart.com/ |deviantart-C| Optional (OAuth)
|
||||||
Doki Reader https://kobato.hologfx.com/reader/ Chapters, Manga
|
Doki Reader https://kobato.hologfx.com/reader/ Chapters, Manga
|
||||||
Dynasty Reader https://dynasty-scans.com/ Chapters, individual Images, Search Results
|
Dynasty Reader https://dynasty-scans.com/ Chapters, individual Images, Search Results
|
||||||
|
E-Hentai https://e-hentai.org/ Favorites, Galleries, Search Results Optional
|
||||||
e621 https://e621.net/ Pools, Popular Images, Posts, Tag-Searches
|
e621 https://e621.net/ Pools, Popular Images, Posts, Tag-Searches
|
||||||
EroLord.com http://erolord.com/ Galleries
|
EroLord.com http://erolord.com/ Galleries
|
||||||
ExHentai https://exhentai.org/ Favorites, Galleries, Search Results Optional
|
|
||||||
Fallen Angels Scans https://www.fascans.com/ Chapters, Manga
|
Fallen Angels Scans https://www.fascans.com/ Chapters, Manga
|
||||||
Fashion Nova https://www.fashionnova.com/ Collections, Products
|
Fashion Nova https://www.fashionnova.com/ Collections, Products
|
||||||
Fireden https://boards.fireden.net/ Threads
|
Fireden https://boards.fireden.net/ Threads
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
"""Extract images from galleries at https://exhentai.org/"""
|
"""Extractors for https://e-hentai.org/"""
|
||||||
|
|
||||||
from .common import Extractor, Message
|
from .common import Extractor, Message
|
||||||
from .. import text, util, exception
|
from .. import text, util, exception
|
||||||
@@ -27,14 +27,11 @@ class ExhentaiExtractor(Extractor):
|
|||||||
filename_fmt = (
|
filename_fmt = (
|
||||||
"{gallery_id}_{num:>04}_{image_token}_{filename}.{extension}")
|
"{gallery_id}_{num:>04}_{image_token}_{filename}.{extension}")
|
||||||
archive_fmt = "{gallery_id}_{num}"
|
archive_fmt = "{gallery_id}_{num}"
|
||||||
cookiedomain = ".exhentai.org"
|
cookiedomain = ".e-hentai.org"
|
||||||
cookienames = ("ipb_member_id", "ipb_pass_hash")
|
cookienames = ("ipb_member_id", "ipb_pass_hash")
|
||||||
root = "https://exhentai.org"
|
root = "https://e-hentai.org"
|
||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
if match.group(1) != "ex":
|
|
||||||
self.root = "https://e-hentai.org"
|
|
||||||
self.cookiedomain = ".e-hentai.org"
|
|
||||||
Extractor.__init__(self, match)
|
Extractor.__init__(self, match)
|
||||||
self.limits = self.config("limits", True)
|
self.limits = self.config("limits", True)
|
||||||
self.original = self.config("original", True)
|
self.original = self.config("original", True)
|
||||||
@@ -45,13 +42,7 @@ class ExhentaiExtractor(Extractor):
|
|||||||
if self.wait_max < self.wait_min:
|
if self.wait_max < self.wait_min:
|
||||||
self.wait_max = self.wait_min
|
self.wait_max = self.wait_min
|
||||||
self.session.headers["Referer"] = self.root + "/"
|
self.session.headers["Referer"] = self.root + "/"
|
||||||
|
self.session.cookies.set("nw", "1", domain=self.cookiedomain)
|
||||||
def request(self, *args, **kwargs):
|
|
||||||
response = Extractor.request(self, *args, **kwargs)
|
|
||||||
if self._is_sadpanda(response):
|
|
||||||
self.log.info("sadpanda.jpg")
|
|
||||||
raise exception.AuthorizationError()
|
|
||||||
return response
|
|
||||||
|
|
||||||
def wait(self, waittime=None):
|
def wait(self, waittime=None):
|
||||||
"""Wait for a randomly chosen amount of seconds"""
|
"""Wait for a randomly chosen amount of seconds"""
|
||||||
@@ -69,11 +60,8 @@ class ExhentaiExtractor(Extractor):
|
|||||||
if username:
|
if username:
|
||||||
self._update_cookies(self._login_impl(username, password))
|
self._update_cookies(self._login_impl(username, password))
|
||||||
else:
|
else:
|
||||||
self.log.info("no username given; using e-hentai.org")
|
|
||||||
self.root = "https://e-hentai.org"
|
|
||||||
self.original = False
|
self.original = False
|
||||||
self.limits = False
|
self.limits = False
|
||||||
self.session.cookies["nw"] = "1"
|
|
||||||
|
|
||||||
@cache(maxage=90*24*3600, keyarg=1)
|
@cache(maxage=90*24*3600, keyarg=1)
|
||||||
def _login_impl(self, username, password):
|
def _login_impl(self, username, password):
|
||||||
@@ -96,14 +84,6 @@ class ExhentaiExtractor(Extractor):
|
|||||||
raise exception.AuthenticationError()
|
raise exception.AuthenticationError()
|
||||||
return {c: response.cookies[c] for c in self.cookienames}
|
return {c: response.cookies[c] for c in self.cookienames}
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _is_sadpanda(response):
|
|
||||||
"""Return True if the response object contains a sad panda"""
|
|
||||||
return (
|
|
||||||
response.headers.get("Content-Length") == "9615" and
|
|
||||||
"sadpanda.jpg" in response.headers.get("Content-Disposition", "")
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ExhentaiGalleryExtractor(ExhentaiExtractor):
|
class ExhentaiGalleryExtractor(ExhentaiExtractor):
|
||||||
"""Extractor for image galleries from exhentai.org"""
|
"""Extractor for image galleries from exhentai.org"""
|
||||||
@@ -372,7 +352,10 @@ class ExhentaiFavoriteExtractor(ExhentaiSearchExtractor):
|
|||||||
subcategory = "favorite"
|
subcategory = "favorite"
|
||||||
pattern = BASE_PATTERN + r"/favorites\.php(?:\?(.*))?"
|
pattern = BASE_PATTERN + r"/favorites\.php(?:\?(.*))?"
|
||||||
test = (
|
test = (
|
||||||
("https://exhentai.org/favorites.php"),
|
("https://exhentai.org/favorites.php", {
|
||||||
|
"count": 1,
|
||||||
|
"pattern": r"https?://e-hentai\.org/g/1200119/d55c44d3d0"
|
||||||
|
}),
|
||||||
("https://exhentai.org/favorites.php?favcat=1&f_search=touhou"
|
("https://exhentai.org/favorites.php?favcat=1&f_search=touhou"
|
||||||
"&f_apply=Search+Favorites"),
|
"&f_apply=Search+Favorites"),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ CATEGORY_MAP = {
|
|||||||
"dynastyscans" : "Dynasty Reader",
|
"dynastyscans" : "Dynasty Reader",
|
||||||
"e621" : "e621",
|
"e621" : "e621",
|
||||||
"erolord" : "EroLord.com",
|
"erolord" : "EroLord.com",
|
||||||
"exhentai" : "ExHentai",
|
"exhentai" : "E-Hentai",
|
||||||
"fallenangels" : "Fallen Angels Scans",
|
"fallenangels" : "Fallen Angels Scans",
|
||||||
"fashionnova" : "Fashion Nova",
|
"fashionnova" : "Fashion Nova",
|
||||||
"hbrowse" : "HBrowse",
|
"hbrowse" : "HBrowse",
|
||||||
|
|||||||
Reference in New Issue
Block a user