Skip to content

Commit

Permalink
fix: bing网络相关错误
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhldr committed Dec 10, 2024
1 parent 0e7d305 commit 63a1fb2
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lfy/api/server/tra/bing.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def g_url(host, hs):
return f'https://{host}/ttranslatev3?isVertical=1&&IG={hs["IG"]}&IID={hs["my_iid"]}'


def _get_data(st: ServerTra, text, lang_to, n=0):
def _translate(st: ServerTra, text, lang_to, n=0):

if st.session is None:
st.session = _init_session()

if n > 5:
return False, _("something error, try other translate engine?")
Expand All @@ -89,15 +92,6 @@ def _get_data(st: ServerTra, text, lang_to, n=0):
data = {'': '', 'text': text, "fromLang": "auto-detect",
'to': lang_to, 'token': hs['token'], 'key': hs['key'],
'tryFetchingGenderDebiasedTranslations': True}
return host, data, hs


def _translate(st: ServerTra, text, lang_to, n=0):

if st.session is None:
st.session = _init_session()

host, data, hs = _get_data(st, text, lang_to, n)

try:
url = g_url(host, hs)
Expand Down

0 comments on commit 63a1fb2

Please sign in to comment.