mirror of
https://github.com/zedeus/nitter.git
synced 2025-12-15 08:42:48 -05:00
Fix crash when profile doesn't exist
This commit is contained in:
@@ -118,6 +118,9 @@ proc getProfileFallback(username: string; headers: HttpHeaders): Future[Profile]
|
||||
url = base / profileIntentUrl ? {"screen_name": username}
|
||||
html = await fetchHtml(url, headers)
|
||||
|
||||
if html.isNil:
|
||||
return Profile()
|
||||
|
||||
result = parseIntentProfile(html)
|
||||
|
||||
proc getProfile*(username: string): Future[Profile] {.async.} =
|
||||
@@ -139,6 +142,9 @@ proc getProfile*(username: string): Future[Profile] {.async.} =
|
||||
url = base / profilePopupUrl ? params
|
||||
html = await fetchHtml(url, headers, jsonKey="html")
|
||||
|
||||
if html.isNil:
|
||||
return Profile()
|
||||
|
||||
if not html.querySelector(".ProfileCard-sensitiveWarningContainer").isNil:
|
||||
return await getProfileFallback(username, headers)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user