From 7ad0956e6e80675b9eea0fc9fd1a345ce69ac510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Sat, 18 May 2024 01:55:02 +0800 Subject: [PATCH] fix --- LunaTranslator/LunaTranslator/cishu/cishubase.py | 5 ++--- LunaTranslator/LunaTranslator/cishu/goo.py | 12 ++++++------ LunaTranslator/LunaTranslator/cishu/weblio.py | 12 ++++++------ LunaTranslator/LunaTranslator/cishu/youdao.py | 14 ++++++++------ 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/LunaTranslator/LunaTranslator/cishu/cishubase.py b/LunaTranslator/LunaTranslator/cishu/cishubase.py index 4793f1a5..e4f8cb6c 100644 --- a/LunaTranslator/LunaTranslator/cishu/cishubase.py +++ b/LunaTranslator/LunaTranslator/cishu/cishubase.py @@ -30,9 +30,8 @@ class cishubase: except: self.needinit = True - if res is None or res == "": - return - self.callback(res) + if res and len(res): + self.callback(res) except: pass diff --git a/LunaTranslator/LunaTranslator/cishu/goo.py b/LunaTranslator/LunaTranslator/cishu/goo.py index 7907a3ad..c6a97ab0 100644 --- a/LunaTranslator/LunaTranslator/cishu/goo.py +++ b/LunaTranslator/LunaTranslator/cishu/goo.py @@ -17,10 +17,10 @@ class goo(cishubase): xx = re.sub("", "", xx) xx = re.sub("", "", xx) - - return ( - '
link
'.format( - url + if len(xx): + return ( + '
link
'.format( + url + ) + + xx ) - + xx - ) diff --git a/LunaTranslator/LunaTranslator/cishu/weblio.py b/LunaTranslator/LunaTranslator/cishu/weblio.py index d49c9a10..d0c070dc 100644 --- a/LunaTranslator/LunaTranslator/cishu/weblio.py +++ b/LunaTranslator/LunaTranslator/cishu/weblio.py @@ -25,10 +25,10 @@ class weblio(cishubase): _all.append(xx) join = "
".join(_all) - - return ( - '
link
'.format( - url + if len(join): + return ( + '
link
'.format( + url + ) + + join ) - + join - ) diff --git a/LunaTranslator/LunaTranslator/cishu/youdao.py b/LunaTranslator/LunaTranslator/cishu/youdao.py index 39300d49..2e7dc06c 100644 --- a/LunaTranslator/LunaTranslator/cishu/youdao.py +++ b/LunaTranslator/LunaTranslator/cishu/youdao.py @@ -25,11 +25,13 @@ class youdao(cishubase): proxies=getproxy(), ).text fnd = re.findall('
([\\s\\S]*?)
', text) - return ( - '
link

'.format( - "https://dict.youdao.com/result?word={}&lang={}".format( - quote(word), self.srclang + + if len(fnd[0][1]): + return ( + '
link

'.format( + "https://dict.youdao.com/result?word={}&lang={}".format( + quote(word), self.srclang + ) ) + + fnd[0][1] ) - + fnd[0][1] - )