From b706e9af10d5f01ed52c3d3314307c553e528f4b Mon Sep 17 00:00:00 2001 From: lilingfengdev Date: Mon, 10 Jun 2024 16:51:24 +0800 Subject: [PATCH] fix --- plugin/engine/base.py | 6 ++++++ plugin/engine/bing.py | 5 ++++- plugin/engine/spigotmc.py | 0 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 plugin/engine/spigotmc.py diff --git a/plugin/engine/base.py b/plugin/engine/base.py index f27e02e..74c0bbf 100644 --- a/plugin/engine/base.py +++ b/plugin/engine/base.py @@ -9,6 +9,12 @@ def __init__(self, url, title, summary): self.title = title self.summary = summary + def __eq__(self, other): + return self.url == other.url + + def __hash__(self): + return hash(self.url) + class SearchEngine(ABC): diff --git a/plugin/engine/bing.py b/plugin/engine/bing.py index 1ac727d..69cda56 100644 --- a/plugin/engine/bing.py +++ b/plugin/engine/bing.py @@ -16,7 +16,10 @@ def get_bing_url(self, keywords): return bing_url def search(self, keywords) -> typing.List[SearchResult]: - keywords = f"我的世界 {translate(keywords)} 插件" + return list(set(self._search(f"我的世界 {translate(keywords)} 插件")) | set( + self._search(f"minecraft {translate(keywords, to_lang=EN)} plugin"))) + + def _search(self, keywords) -> typing.List[SearchResult]: bing_url = self.get_bing_url(keywords) result: typing.List[SearchResult] = [] headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0', diff --git a/plugin/engine/spigotmc.py b/plugin/engine/spigotmc.py new file mode 100644 index 0000000..e69de29