Fix missing videos due to broken token logic

This commit is contained in:
Zed 2019-11-08 22:51:31 +01:00
parent 50ebafdf79
commit 27c8c0a97a
1 changed files with 3 additions and 3 deletions

View File

@ -69,7 +69,7 @@ proc getVideoVar(tweet: Tweet): var Option[Video] =
else: else:
return tweet.video return tweet.video
proc getVideoFetch(tweet: Tweet; agent, token: string): Future[Option[Video]] {.async.} = proc getVideoFetch(tweet: Tweet; agent, token: string; retry=true): Future[Option[Video]] {.async.} =
if tweet.video.isNone(): return if tweet.video.isNone(): return
let let
@ -79,11 +79,11 @@ proc getVideoFetch(tweet: Tweet; agent, token: string): Future[Option[Video]] {.
json = await fetchJson(url, headers) json = await fetchJson(url, headers)
if json == nil: if json == nil:
if not retry: return
if getTime() - tokenUpdated > initDuration(seconds=1): if getTime() - tokenUpdated > initDuration(seconds=1):
tokenUpdated = getTime() tokenUpdated = getTime()
discard await getGuestToken(agent, force=true) discard await getGuestToken(agent, force=true)
result = await getVideoFetch(tweet, agent, guestToken) return await getVideoFetch(tweet, agent, guestToken, retry=false)
return
var video = parseVideo(json, tweet.id) var video = parseVideo(json, tweet.id)
video.title = get(tweet.video).title video.title = get(tweet.video).title