mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 22:59:31 +00:00
Use random user agents
This commit is contained in:
parent
d0ee8e8403
commit
6b6e5b3a40
4 changed files with 143 additions and 53 deletions
|
|
@ -12,18 +12,18 @@ var profileCacheTime = initDuration(minutes=10)
|
|||
proc outdated(profile: Profile): bool =
|
||||
getTime() - profile.updated > profileCacheTime
|
||||
|
||||
proc getCachedProfile*(username: string; force=false): Future[Profile] {.async.} =
|
||||
proc getCachedProfile*(username, agent: string; force=false): Future[Profile] {.async.} =
|
||||
withDb:
|
||||
try:
|
||||
result.getOne("username = ?", username)
|
||||
doAssert not result.outdated()
|
||||
except AssertionError:
|
||||
var profile = await getProfile(username)
|
||||
var profile = await getProfile(username, agent)
|
||||
profile.id = result.id
|
||||
result = profile
|
||||
result.update()
|
||||
except KeyError:
|
||||
result = await getProfile(username)
|
||||
result = await getProfile(username, agent)
|
||||
if result.username.len > 0:
|
||||
result.insert()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue