mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-12 11:06:30 +00:00
Fix crash on token fetch failure
This commit is contained in:
parent
7acea6b9e0
commit
3dc85639f4
1 changed files with 9 additions and 4 deletions
|
@ -12,12 +12,17 @@ proc fetchToken(): Future[Token] {.async.} =
|
|||
"user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0"
|
||||
})
|
||||
client = newAsyncHttpClient(headers=headers)
|
||||
|
||||
var resp: string
|
||||
|
||||
try:
|
||||
resp = await client.getContent("https://twitter.com")
|
||||
pos = resp.rfind("gt=")
|
||||
|
||||
try: client.close()
|
||||
except: discard
|
||||
client.close()
|
||||
except:
|
||||
echo "fetching token failed"
|
||||
return Token()
|
||||
|
||||
let pos = resp.rfind("gt=")
|
||||
if pos == -1:
|
||||
echo "token parse fail"
|
||||
return Token()
|
||||
|
|
Loading…
Reference in a new issue