diff --git a/PyFunceble/checker/availability/extras/rules.py b/PyFunceble/checker/availability/extras/rules.py index 46a9dded..2337fc38 100644 --- a/PyFunceble/checker/availability/extras/rules.py +++ b/PyFunceble/checker/availability/extras/rules.py @@ -92,6 +92,7 @@ def __init__(self, status: Optional[AvailabilityCheckerStatus] = None) -> None: r"\.github\.io$": [(self.__switch_to_down_if, 404)], r"\.godaddysites\.com$": [(self.__switch_to_down_if, 404)], r"\.hpg.com.br$": [(self.__switch_to_down_if, 404)], + r"\.imgur\.com$": [self.__handle_imgur_dot_com], r"\.liveadvert\.com$": [(self.__switch_to_down_if, 404)], r"\.skyrock\.com$": [(self.__switch_to_down_if, 404)], r"\.tumblr\.com$": [(self.__switch_to_down_if, 404)], @@ -152,9 +153,7 @@ def __regex_registry_handler(self, regex_registry: dict) -> "ExtraRulesHandler": ) in regex_registry.items(): broken = False for element in data: - if not RegexHelper(regex).match( - self.status.idna_subject, return_match=False - ): + if not RegexHelper(regex).match(self.status.netloc, return_match=False): continue if isinstance(element, tuple): @@ -246,6 +245,40 @@ def __handle_fc2_dot_com(self) -> "ExtraRulesHandler": return self + def __handle_imgur_dot_com(self) -> "ExtraRulesHandler": + """ + Handles the :code:`imgur.com` case. + + .. warning:. + This method assume that we know that we are handling a imgur.com + sub-domain. + """ + + if self.status.idna_subject.startswith( + "http:" + ) or self.status.idna_subject.startswith("https://"): + url = self.status.idna_subject + else: + url = f"https://{self.status.idna_subject}" + + req = PyFunceble.factory.Requester.get(url, allow_redirects=True) + username = self.status.netloc.replace(".imgur.com", "") + + for response in req.history: + if "Location" in req.response: + if req.headers["Location"].endswith(("/removed.png")): + self.switch_to_down() + + if response.status_code in [404] and response.url.endswith( + f"/user/{username}" + ): + self.switch_to_down() + + if req.url.endswith(f"/user/{username}"): + self.switch_to_down() + + return self + def __handle_active2inactive(self) -> "ExtraRulesHandler": """ Handles the status deescalation. diff --git a/docs/components/special-rules.rst b/docs/components/special-rules.rst index dcb876cd..f800a2ff 100644 --- a/docs/components/special-rules.rst +++ b/docs/components/special-rules.rst @@ -319,6 +319,17 @@ supplied as :code:`INACTIVE`. ------ +:code:`*.imgur.com` +""""""""""""""""""" + +Any subjects matching the given pattern and: + + - the :code:`/removed.png` path in the end URL (after redirect). + +are supplied as :code:`INACTIVE`. + +------ + :code:`*.liveadvert.com` """"""""""""""""""""""""