From fd5fda980eb6c0310ef904bc6a78cf158f3bea36 Mon Sep 17 00:00:00 2001 From: jue0115 <46835138+jue0115@users.noreply.github.com> Date: Sat, 7 Oct 2023 18:38:33 +0800 Subject: [PATCH 1/5] fix http(s) fix http https --- backend/src/module/network/request_url.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/backend/src/module/network/request_url.py b/backend/src/module/network/request_url.py index d4e17395..c6148074 100644 --- a/backend/src/module/network/request_url.py +++ b/backend/src/module/network/request_url.py @@ -87,11 +87,20 @@ class RequestURL: self.session = requests.Session() if settings.proxy.enable: if "http" in settings.proxy.type: - url = f"{settings.proxy.type}://{settings.proxy.host}:{settings.proxy.port}" - self.session.proxies = { - "https": url, - "http": url, - } + if settings.proxy.username: + username=settings.proxy.username + password=settings.proxy.password + url = f"http://{username}:{password}@{settings.proxy.host}:{settings.proxy.port}" + self.session.proxies = { + "http": url, + "https": url, + } + else: + url = f"http://{settings.proxy.host}:{settings.proxy.port}" + self.session.proxies = { + "http": url, + "https": url, + } elif settings.proxy.type == "socks5": self._socks5_proxy = True socks.set_default_proxy( From 5f89ed9913da170500a441d72270a8f402f9c7d4 Mon Sep 17 00:00:00 2001 From: jue0115 <46835138+jue0115@users.noreply.github.com> Date: Sun, 8 Oct 2023 12:08:06 +0800 Subject: [PATCH 2/5] fix socks5 search --- backend/src/module/searcher/searcher.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/module/searcher/searcher.py b/backend/src/module/searcher/searcher.py index 1b44f4e6..1cddb23a 100644 --- a/backend/src/module/searcher/searcher.py +++ b/backend/src/module/searcher/searcher.py @@ -21,8 +21,11 @@ BangumiJSON: TypeAlias = str class SearchTorrent(RequestContent, RSSAnalyser): def search_torrents(self, rss_item: RSSItem) -> list[Torrent]: - torrents = self.get_torrents(rss_item.url) + with RequestContent() as req: + torrents = self.get_torrents(rss_item.url) return torrents + # torrents = self.get_torrents(rss_item.url) + # return torrents def analyse_keyword( self, keywords: list[str], site: str = "mikan", limit: int = 5 From 6523b01042219273492cdc725bc778b11804279c Mon Sep 17 00:00:00 2001 From: jue0115 <46835138+jue0115@users.noreply.github.com> Date: Sun, 8 Oct 2023 18:30:21 +0800 Subject: [PATCH 3/5] fix nyaa search error --- backend/src/module/network/site/mikan.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/backend/src/module/network/site/mikan.py b/backend/src/module/network/site/mikan.py index 00181a87..72b7be9c 100644 --- a/backend/src/module/network/site/mikan.py +++ b/backend/src/module/network/site/mikan.py @@ -2,10 +2,16 @@ def rss_parser(soup): torrent_titles = [] torrent_urls = [] torrent_homepage = [] - for item in soup.findall("./channel/item"): - torrent_titles.append(item.find("title").text) - torrent_urls.append(item.find("enclosure").attrib["url"]) - torrent_homepage.append(item.find("link").text) + if not len(soup.findall("./channel/item/enclosure")): + for item in soup.findall("./channel/item"): + torrent_titles.append(item.find("title").text) + torrent_urls.append(item.find("link").text) + torrent_homepage.append(item.find("guid").text) + else: + for item in soup.findall("./channel/item"): + torrent_titles.append(item.find("title").text) + torrent_urls.append(item.find("enclosure").attrib["url"]) + torrent_homepage.append(item.find("link").text) return torrent_titles, torrent_urls, torrent_homepage From fc3875772322ddcb94e2cfadc60afa54e32dcbea Mon Sep 17 00:00:00 2001 From: Estrella Pan <33726646+EstrellaXD@users.noreply.github.com> Date: Sun, 8 Oct 2023 19:55:17 +0800 Subject: [PATCH 4/5] Update mikan.py --- backend/src/module/network/site/mikan.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/backend/src/module/network/site/mikan.py b/backend/src/module/network/site/mikan.py index 72b7be9c..f581fdd2 100644 --- a/backend/src/module/network/site/mikan.py +++ b/backend/src/module/network/site/mikan.py @@ -2,16 +2,15 @@ def rss_parser(soup): torrent_titles = [] torrent_urls = [] torrent_homepage = [] - if not len(soup.findall("./channel/item/enclosure")): - for item in soup.findall("./channel/item"): - torrent_titles.append(item.find("title").text) - torrent_urls.append(item.find("link").text) - torrent_homepage.append(item.find("guid").text) - else: - for item in soup.findall("./channel/item"): - torrent_titles.append(item.find("title").text) - torrent_urls.append(item.find("enclosure").attrib["url"]) + for item in soup.findall("./channel/item"): + torrent_titles.append(item.find("title").text) + enclosure = item.find("enclosure") + if enclosure is not None: torrent_homepage.append(item.find("link").text) + torrent_urls.append(enclosure.attrib.get("url")) + else: + torrent_urls.append(item.find("link").text) + torrent_homepage.append("") return torrent_titles, torrent_urls, torrent_homepage From 9637dc53d9aa2efe36ad619b26468ac155086800 Mon Sep 17 00:00:00 2001 From: Estrella Pan <33726646+EstrellaXD@users.noreply.github.com> Date: Sun, 8 Oct 2023 19:55:53 +0800 Subject: [PATCH 5/5] Update searcher.py --- backend/src/module/searcher/searcher.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/src/module/searcher/searcher.py b/backend/src/module/searcher/searcher.py index 1cddb23a..71de3a9a 100644 --- a/backend/src/module/searcher/searcher.py +++ b/backend/src/module/searcher/searcher.py @@ -21,9 +21,7 @@ BangumiJSON: TypeAlias = str class SearchTorrent(RequestContent, RSSAnalyser): def search_torrents(self, rss_item: RSSItem) -> list[Torrent]: - with RequestContent() as req: - torrents = self.get_torrents(rss_item.url) - return torrents + return self.get_torrents(rss_item.url) # torrents = self.get_torrents(rss_item.url) # return torrents