From 69b6562121dae2d2e642c39f3420a4a223f48ab7 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Wed, 4 Jan 2023 22:46:13 +0100 Subject: [PATCH] Fix urlencode --- pynyaata/bridge/nyaa.py | 6 +++--- pynyaata/bridge/yggtorrent.py | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/pynyaata/bridge/nyaa.py b/pynyaata/bridge/nyaa.py index caf27cf..7e37a22 100644 --- a/pynyaata/bridge/nyaa.py +++ b/pynyaata/bridge/nyaa.py @@ -1,7 +1,7 @@ from datetime import datetime from os import getenv from typing import List -from urllib.parse import urlencode +from urllib import parse from bs4 import BeautifulSoup from pydantic import HttpUrl, parse_obj_as @@ -24,7 +24,7 @@ class Nyaa(Bridge): def search_url(self, query: str = "", page: int = 1) -> HttpUrl: to_query = "|".join(map(lambda word: f"({query} {word})", VF_WORDS)) - params = urlencode( + params = parse.urlencode( { "f": 0, "c": "1_3", @@ -86,7 +86,7 @@ class EraiRaws(Nyaa): title = "Erai-raws" def search_url(self, query: str = "", page: int = 1) -> HttpUrl: - params = urlencode( + params = parse.urlencode( { "f": 0, "c": "1_2", diff --git a/pynyaata/bridge/yggtorrent.py b/pynyaata/bridge/yggtorrent.py index e250bad..f5e8525 100644 --- a/pynyaata/bridge/yggtorrent.py +++ b/pynyaata/bridge/yggtorrent.py @@ -1,4 +1,5 @@ from typing import List +from urllib import parse from bs4 import BeautifulSoup from humanfriendly import parse_size @@ -21,14 +22,16 @@ class YggTorrent(Bridge): sub_category = 2179 def search_url(self, query: str = "", page: int = 1) -> HttpUrl: - params = { - "name": query, - "category": 2145, - "sub_category": self.sub_category, - "do": "search", - "order": "desc", - "sort": "size" if query else "publish_date", - } + params = parse.urlencode( + { + "name": query, + "category": 2145, + "sub_category": self.sub_category, + "do": "search", + "order": "desc", + "sort": "size" if query else "publish_date", + } + ) return parse_obj_as(HttpUrl, f"{self.base_url}?{params}")