From 12ee2d56495cc118ffa59c7da8772bd460d138e5 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: Thu, 11 Apr 2024 12:29:02 +0800 Subject: [PATCH] issues/642 Update vndb.py --- LunaTranslator/LunaTranslator/myutils/vndb.py | 3 ++- .../LunaTranslator/translator/sugoionline.py | 22 +++++++++++++++++++ .../files/defaultconfig/config.json | 6 +++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 LunaTranslator/LunaTranslator/translator/sugoionline.py diff --git a/LunaTranslator/LunaTranslator/myutils/vndb.py b/LunaTranslator/LunaTranslator/myutils/vndb.py index ba75d0f6..54c66165 100644 --- a/LunaTranslator/LunaTranslator/myutils/vndb.py +++ b/LunaTranslator/LunaTranslator/myutils/vndb.py @@ -75,16 +75,17 @@ def vndbdowloadinfo(vid): def safegetvndbjson(url, json, getter): try: + print(url, json) _ = requests.post( url, json=json, proxies=getproxy(), ) + print(_.text) try: return getter(_.json()) except: # print_exc() - print(_.text) return None except: return None diff --git a/LunaTranslator/LunaTranslator/translator/sugoionline.py b/LunaTranslator/LunaTranslator/translator/sugoionline.py new file mode 100644 index 00000000..f44a4bfb --- /dev/null +++ b/LunaTranslator/LunaTranslator/translator/sugoionline.py @@ -0,0 +1,22 @@ +from translator.basetranslator import basetrans + + +class TS(basetrans): + def langmap(self): + return {"en": "English", "ja": "Japanese", "zh": "Chinese", "vi": "Vietnamese"} + + def translate(self, query): + + json_data = { + "content": { + "input_text": query, + "input_language": self.srclang, + "output_language": self.tgtlang, + }, + "message": "translate sentences", + } + + response = self.session.post( + "https://translation-server-proxy-7ja5f.ondigitalocean.app/", json=json_data + ) + return response.json()[0] diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json index fe272ca8..2f2fe8d5 100644 --- a/LunaTranslator/files/defaultconfig/config.json +++ b/LunaTranslator/files/defaultconfig/config.json @@ -948,6 +948,12 @@ "color": "#1839f0", "name": "Sugoi" }, + "sugoionline": { + "use": true, + "color": "#1839f0", + "name": "Sugoi", + "useproxy": true + }, "kingsoft": { "type": "offline", "use": false,