[exhentai] remove and update sad panda check
there hasn't been a sad panda in several years
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2014-2022 Mike Fährmann
|
# Copyright 2014-2023 Mike Fährmann
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
@@ -21,8 +21,7 @@ class ExhentaiExtractor(Extractor):
|
|||||||
"""Base class for exhentai extractors"""
|
"""Base class for exhentai extractors"""
|
||||||
category = "exhentai"
|
category = "exhentai"
|
||||||
directory_fmt = ("{category}", "{gid} {title[:247]}")
|
directory_fmt = ("{category}", "{gid} {title[:247]}")
|
||||||
filename_fmt = (
|
filename_fmt = "{gid}_{num:>04}_{image_token}_{filename}.{extension}"
|
||||||
"{gid}_{num:>04}_{image_token}_{filename}.{extension}")
|
|
||||||
archive_fmt = "{gid}_{num}"
|
archive_fmt = "{gid}_{num}"
|
||||||
cookienames = ("ipb_member_id", "ipb_pass_hash")
|
cookienames = ("ipb_member_id", "ipb_pass_hash")
|
||||||
cookiedomain = ".exhentai.org"
|
cookiedomain = ".exhentai.org"
|
||||||
@@ -56,10 +55,10 @@ class ExhentaiExtractor(Extractor):
|
|||||||
if version != "ex":
|
if version != "ex":
|
||||||
self.session.cookies.set("nw", "1", domain=self.cookiedomain)
|
self.session.cookies.set("nw", "1", domain=self.cookiedomain)
|
||||||
|
|
||||||
def request(self, *args, **kwargs):
|
def request(self, url, **kwargs):
|
||||||
response = Extractor.request(self, *args, **kwargs)
|
response = Extractor.request(self, url, **kwargs)
|
||||||
if self._is_sadpanda(response):
|
if response.history and response.headers.get("Content-Length") == "0":
|
||||||
self.log.info("sadpanda.jpg")
|
self.log.info("blank page")
|
||||||
raise exception.AuthorizationError()
|
raise exception.AuthorizationError()
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@@ -100,14 +99,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"""
|
||||||
|
|||||||
Reference in New Issue
Block a user