Fix hidden_url

This commit is contained in:
Michel Roux 2023-01-06 00:45:34 +01:00
parent e95e3fd631
commit 8a01893406

View File

@ -21,7 +21,7 @@ class YggTorrent(Bridge):
color = Color.SUCCESS color = Color.SUCCESS
title = "YggTorrent" title = "YggTorrent"
base_url = parse_obj_as(HttpUrl, f"https://{YGG_DOMAIN}") 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") favicon = parse_obj_as(HttpUrl, f"{base_url}/favicon.ico")
category = "Animation Série" category = "Animation Série"
sub_category = 2179 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 @log_async
@cache_data @cache_data
@filter_data @filter_data
async def search(self, query: str = "", page: int = 1) -> List[RemoteFile]: async def search(self, query: str = "", page: int = 1) -> List[RemoteFile]:
if YGG_IP: search_url = self.search_url(query, page)
params = self.search_url(query, page).split("?") response = requests.get(
response = requests.get( f"{self.hidden_url}/{search_url.path}?{search_url.query}",
f"{self.hidden_url}?{params[1]}", headers={"Host": YGG_DOMAIN} headers={"Host": YGG_DOMAIN},
) )
else:
response = requests.get(self.search_url(query, page))
if response.status_code != 200: if response.status_code != 200:
raise requests.HTTPError(response) raise requests.HTTPError(response)