mirror of https://gitlab.com/bashrc2/epicyon
Catch exception
parent
35219af5ea
commit
c30b32553d
|
@ -214,6 +214,8 @@ def _libretranslate(url: str, text: str,
|
||||||
else:
|
else:
|
||||||
url += "translate"
|
url += "translate"
|
||||||
|
|
||||||
|
originalText = text
|
||||||
|
|
||||||
# get any links from the text
|
# get any links from the text
|
||||||
links = getLinksFromContent(text)
|
links = getLinksFromContent(text)
|
||||||
|
|
||||||
|
@ -236,7 +238,11 @@ def _libretranslate(url: str, text: str,
|
||||||
urlParams = parse.urlencode(ltParams)
|
urlParams = parse.urlencode(ltParams)
|
||||||
|
|
||||||
req = request.Request(url, data=urlParams.encode())
|
req = request.Request(url, data=urlParams.encode())
|
||||||
response = request.urlopen(req)
|
try:
|
||||||
|
response = request.urlopen(req)
|
||||||
|
except BaseException:
|
||||||
|
print('Unaable to translate: ' + text)
|
||||||
|
return originalText
|
||||||
|
|
||||||
response_str = response.read().decode()
|
response_str = response.read().decode()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue