Remove workaround for Invidious token expiring due to misconfigured instance (#98)
* Remove workaround for Invidious token expiring * Changelog
This commit is contained in:
1 parent
55fd1ba43c
commit
8bc9cec570
2 files changed
+4
-26
No files matched your search
@@ -147,35 +147,12 @@ class InvidiousService
|
||||
|
||||
function DeleteExpiredToken(response as object)
|
||||
if response.statuscode = 403
|
||||
print(`Server responded with 403: ${response.text}`)
|
||||
if m.IsTokenMaybeExpired() = true
|
||||
print("deleting token...")
|
||||
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
|
||||
end if
|
||||
print(`Invidious instance responded with 403: ${response.text}`)
|
||||
print("Deleting Invidious token...")
|
||||
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
|
||||
end if
|
||||
end function
|
||||
|
||||
' Public Invidious instances fail a lot randomly, even with valid tokens
|
||||
' For that reason, it's better to make sure the token actually expired by date
|
||||
' TODO: this happens because instance owners do not set hmac_key https://github.com/iv-org/invidious/issues/3854
|
||||
' Once hmac_key is enforced, this check can be removed.
|
||||
function IsTokenMaybeExpired() as dynamic
|
||||
authToken = InvidiousSettings.GetAuthToken()
|
||||
if authToken = invalid
|
||||
return invalid
|
||||
end if
|
||||
token = ParseJson(authToken.token)
|
||||
if token = invalid
|
||||
return invalid
|
||||
end if
|
||||
if not token.DoesExist("expire")
|
||||
return invalid
|
||||
end if
|
||||
expire = token["expire"]
|
||||
currentTime = TimeUtils.Now().AsSeconds()
|
||||
return expire < currentTime
|
||||
end function
|
||||
|
||||
function CacheResponse(requestData as object, result as object)
|
||||
cacheKey = FormatJson(requestData)
|
||||
cacheKey = GetMd5(cacheKey)
|
||||
|
||||
Reference in new issue
Block a user