From b8a548af7d579eb0d749bb67fc4634ac0c660b44 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: Wed, 4 Sep 2024 10:32:40 +0800 Subject: [PATCH] sakura --- LunaTranslator/LunaTranslator/translator/sakura.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/LunaTranslator/LunaTranslator/translator/sakura.py b/LunaTranslator/LunaTranslator/translator/sakura.py index fcccbce9..3388550d 100644 --- a/LunaTranslator/LunaTranslator/translator/sakura.py +++ b/LunaTranslator/LunaTranslator/translator/sakura.py @@ -192,10 +192,11 @@ class TS(basetrans): if not output.headers["Content-Type"].startswith("text/event-stream"): raise Exception(output.text) for o in output.iter_lines(): - if o == b"data: [DONE]": + o = o.decode("utf-8").strip() + if o == "data: [DONE]": break try: - res = o.decode("utf-8").strip()[6:] # .replace("data: ", "") + res = o[6:] # print(res) if res == "": continue