From 8a018934067b6ce3993de5351c7a21880bafddee Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Fri, 6 Jan 2023 00:45:34 +0100 Subject: [PATCH] Fix hidden_url --- pynyaata/bridge/yggtorrent.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/pynyaata/bridge/yggtorrent.py b/pynyaata/bridge/yggtorrent.py index 162f5cc..bf5eefd 100644 --- a/pynyaata/bridge/yggtorrent.py +++ b/pynyaata/bridge/yggtorrent.py @@ -21,7 +21,7 @@ class YggTorrent(Bridge): color = Color.SUCCESS title = "YggTorrent" base_url = parse_obj_as(HttpUrl, f"https://{YGG_DOMAIN}") - hidden_url = parse_obj_as(HttpUrl, f"http://{YGG_IP}") + hidden_url = parse_obj_as(HttpUrl, f"http://{YGG_IP}") if YGG_IP else base_url favicon = parse_obj_as(HttpUrl, f"{base_url}/favicon.ico") category = "Animation Série" sub_category = 2179 @@ -38,19 +38,17 @@ class YggTorrent(Bridge): } ) - return parse_obj_as(HttpUrl, f"{self.base_url}?{params}") + return parse_obj_as(HttpUrl, f"{self.base_url}/engine/search?{params}") @log_async @cache_data @filter_data async def search(self, query: str = "", page: int = 1) -> List[RemoteFile]: - if YGG_IP: - params = self.search_url(query, page).split("?") - response = requests.get( - f"{self.hidden_url}?{params[1]}", headers={"Host": YGG_DOMAIN} - ) - else: - response = requests.get(self.search_url(query, page)) + search_url = self.search_url(query, page) + response = requests.get( + f"{self.hidden_url}/{search_url.path}?{search_url.query}", + headers={"Host": YGG_DOMAIN}, + ) if response.status_code != 200: raise requests.HTTPError(response)