So, I've prepared code like this:
async def cv_local(ctx, country=""):
translator = Translator()
try:
country = translator.translate(country, dest='en').text
now = datetime.datetime.now()
# startTime = time.time()
if country == "":
country = "world"
print("At " + str(now.hour) + ":" + str(now.minute) + " user " + str(ctx.message.author.name) + "(Id: " + str(
ctx.message.author.id) + ")" +
" didn't mention any country, sent data for world")
else:
print("At " + str(now.hour) + ":" + str(now.minute) + " user " + str(ctx.message.author.name) + "(Id: " + str(
ctx.message.author.id) + ")" + " searched for: " +
str(Library.exceptionCheck(country)[1]))
if str(country).lower() == "world" or str(country).lower() == "kw" or str(country).lower() == "za":
url = 'https://www.worldometers.info/coronavirus/'
code = Library.HttpsRead(url, "świat", config[str(ctx.message.guild.id)]['lang'])
else:
temp1 = Library.exceptionCheck(country)[0]
url = 'https://www.worldometers.info/coronavirus/country/' + temp1
code = Library.HttpsRead(url, country, config[str(ctx.message.guild.id)]['lang'])
message = await ctx.send(embed=code)
await message.add_reaction("")
# print("execution took %s seconds \n" % (time.time() - startTime))
except UnboundLocalError:
await ctx.send("That's strange... It seems like you wanted data for country that doesn't exist in my database\nImportant message: if you would like to look for countries named with multiple words insert \"-\" instead of "
"spaces or use shortcuts f.e. \"uk\" instead of \"United Kingdom\" or \"south-africa\" instead of \"South Africa\"\n\n If error will be repeating report it to <@!287258679609393152>")
print("Error occurred, user missed name of country")
# print("execution took %s seconds \n" % (time.time() - startTime))
except:
await ctx.send("That's strange... Translator occurred some kind of error\nJust try again and everything should be just fine\n\n If error will be repeating report it to <@!287258679609393152>")
print("Error occurred, informed user")
# print("execution took %s seconds \n" % (time.time() - startTime))
It's discord bot, and everything used to work perfectly, but lately it started to crash more and more frequently, here's an error log:
Traceback (most recent call last):
File "C:\Users\grzes\PycharmProjects\CoronaBot\venv\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:/Users/grzes/PycharmProjects/CoronaBot/bot.py", line 222, in cv_local
country = translator.translate(country, dest='en').text
File "C:\Users\grzes\PycharmProjects\CoronaBot\venv\lib\site-packages\googletrans-2.3.0-py3.8.egg\googletrans\client.py", line 172, in translate
data = self._translate(text, dest, src)
File "C:\Users\grzes\PycharmProjects\CoronaBot\venv\lib\site-packages\googletrans-2.3.0-py3.8.egg\googletrans\client.py", line 75, in _translate
token = self.token_acquirer.do(text)
File "C:\Users\grzes\PycharmProjects\CoronaBot\venv\lib\site-packages\googletrans-2.3.0-py3.8.egg\googletrans\gtoken.py", line 186, in do
self._update()
File "C:\Users\grzes\PycharmProjects\CoronaBot\venv\lib\site-packages\googletrans-2.3.0-py3.8.egg\googletrans\gtoken.py", line 65, in _update
code = unicode(self.RE_TKK.search(r.text).group(1)).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'
I've read a little bit about it and tried few solutions from here, but nothing seems to work for me, maybe it's different problem than this one? I've just got no idea what else to do, can anyone help with this?
EDIT: added os.environ["HTTPX_LOG_LEVEL"] = "DEBUG"
And output is like this:
Traceback (most recent call last):
File "C:\Users\grzes\PycharmProjects\CoronaBot\venv\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:/Users/grzes/PycharmProjects/CoronaBot/bot.py", line 242, in cv_local
code = Library.HttpsRead(url, country, config[str(ctx.message.guild.id)]['lang'])
File "C:\Users\grzes\PycharmProjects\CoronaBot\Library.py", line 221, in HttpsRead
embed = discord.Embed(title=translator.translate("Dane o chorobie", dest=currLang).text, description="[Support bot](https://kickstarter.com), [vote](https://top.gg), [support me](https://patreon.com)", color=0xf00000)
File "C:\Users\grzes\PycharmProjects\CoronaBot\venv\lib\site-packages\googletrans-2.3.0-py3.8.egg\googletrans\client.py", line 172, in translate
data = self._translate(text, dest, src)
File "C:\Users\grzes\PycharmProjects\CoronaBot\venv\lib\site-packages\googletrans-2.3.0-py3.8.egg\googletrans\client.py", line 75, in _translate
token = self.token_acquirer.do(text)
File "C:\Users\grzes\PycharmProjects\CoronaBot\venv\lib\site-packages\googletrans-2.3.0-py3.8.egg\googletrans\gtoken.py", line 186, in do
self._update()
File "C:\Users\grzes\PycharmProjects\CoronaBot\venv\lib\site-packages\googletrans-2.3.0-py3.8.egg\googletrans\gtoken.py", line 65, in _update
code = unicode(self.RE_TKK.search(r.text).group(1)).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'