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
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Video duration formatting in cast dialog
|
- Video duration formatting in cast dialog
|
||||||
|
- (Removed) Workaround for Invidious token expiring due to misconfigured instance
|
||||||
|
|
||||||
## [0.10.1] - 2023-06-28
|
## [0.10.1] - 2023-06-28
|
||||||
|
|
||||||
|
|||||||
@@ -147,35 +147,12 @@ class InvidiousService
|
|||||||
|
|
||||||
function DeleteExpiredToken(response as object)
|
function DeleteExpiredToken(response as object)
|
||||||
if response.statuscode = 403
|
if response.statuscode = 403
|
||||||
print(`Server responded with 403: ${response.text}`)
|
print(`Invidious instance responded with 403: ${response.text}`)
|
||||||
if m.IsTokenMaybeExpired() = true
|
print("Deleting Invidious token...")
|
||||||
print("deleting token...")
|
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
|
||||||
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_TOKEN)
|
|
||||||
end if
|
|
||||||
end if
|
end if
|
||||||
end function
|
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)
|
function CacheResponse(requestData as object, result as object)
|
||||||
cacheKey = FormatJson(requestData)
|
cacheKey = FormatJson(requestData)
|
||||||
cacheKey = GetMd5(cacheKey)
|
cacheKey = GetMd5(cacheKey)
|
||||||
|
|||||||
Reference in new issue
Block a user