Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lilingfengdev committed Jun 15, 2024
1 parent 41e0024 commit 1b9b4c6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
3 changes: 3 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from plugin.engine.tinksp import Tinksp
from concurrent.futures import ThreadPoolExecutor, wait
import random
import colorama

colorama.init(autoreset=True)


def print_result(result):
Expand Down
2 changes: 0 additions & 2 deletions plugin/engine/bing.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ def search(self, keywords, site) -> typing.List[SearchResult]:
except IndexError:
url = h3.get('href')
h3 = h3.xpath('string(.)')
if h3.find("模组") != -1 or h3.find("地图") != -1 or h3.find("插件") == -1:
continue
result.append(SearchResult(url=url, title=h3, summary=p))
except IndexError:
pass
Expand Down
10 changes: 4 additions & 6 deletions plugin/engine/spigotmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ def search(self, keywords) -> typing.List[SearchResult]:
for plug in data:
result.append(
SpigotResult(url=plug["url"], title=plug["name"], summary=plug["tag"], count=plug["download"]["count"]))
result.sort(key=lambda obj: obj.count,reverse=True)
result.sort(key=lambda obj: obj.count, reverse=True)
result = result[:10]
for plug in result:
try:
plug.summary = translate(plug.summary)
plug.title = translate(plug.title)
except:
pass
plug.summary = translate(plug.summary)
plug.title = translate(plug.title)

return result
8 changes: 5 additions & 3 deletions plugin/utils/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

@lru_cache(maxsize=None)
def translate(text, to_lang=ZH_CN) -> str:
translator = Translator()
return translator.process(text, toLang=to_lang)

try:
translator = Translator()
return translator.process(text, toLang=to_lang)
except:
return text

0 comments on commit 1b9b4c6

Please sign in to comment.