Mark video watched (#59)
* Mark video watched * Lint fix * return type * fix return type * Changelog --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
1 parent
53f9249b9f
commit
82162d52c1
4 files changed
+40
-2
No files matched your search
@@ -13,11 +13,12 @@ namespace Invidious
|
||||
const STATS_ENDPOINT = "/api/v1/stats"
|
||||
|
||||
const VIDEOS_ENDPOINT = "/api/v1/videos"
|
||||
const HISTORY_ENDPOINT = "/api/v1/auth/history"
|
||||
|
||||
const SEARCH_SUGGEST_ENDPOINT = "/api/v1/search/suggestions"
|
||||
const SEARCH_ENDPOINT = "/api/v1/search"
|
||||
|
||||
const AUTH_SCOPE = "GET:feed,GET:playlists,POST:tokens/unregister"
|
||||
const AUTH_SCOPE = "GET:feed,GET:playlists,POST:tokens/unregister,POST:history*"
|
||||
const AUTH_FEED = "/api/v1/auth/feed"
|
||||
const AUTH_PLAYLISTS = "/api/v1/auth/playlists"
|
||||
const AUTH_TOKENS_UNREGISTER = "/api/v1/auth/tokens/unregister"
|
||||
@@ -66,6 +67,23 @@ namespace Invidious
|
||||
}
|
||||
end function
|
||||
|
||||
function MarkVideoWatched(videoId as string) as boolean
|
||||
authToken = InvidiousSettings.GetAuthToken()
|
||||
if authToken = invalid
|
||||
return false
|
||||
end if
|
||||
|
||||
url = `${authToken.instance}${Invidious.HISTORY_ENDPOINT}/${videoId}`
|
||||
headers = Invidious.GetAuthenticationHeaders(authToken.token)
|
||||
args = {
|
||||
headers: headers,
|
||||
parseJson: false
|
||||
}
|
||||
|
||||
response = Requests().post(url, args)
|
||||
return response.ok
|
||||
end function
|
||||
|
||||
function SearchSuggestions(q as string) as object 'SearchSuggestionResult
|
||||
instance = InvidiousSettings.GetSelectedInstance()
|
||||
url = `${instance}${Invidious.SEARCH_SUGGEST_ENDPOINT}`
|
||||
@@ -127,7 +145,8 @@ namespace Invidious
|
||||
expire = TimeUtils.Now().AsSeconds() + 60 * 60 * 24 * 365 * 2 '2 years from now
|
||||
|
||||
callbackUrl = `http://${localIp}:${webServerPort}${Invidious.TOKEN_CALLBACK}?ref=${instance}`.EncodeUriComponent()
|
||||
return `${invidiousHost}/authorize_token?scopes=${Invidious.AUTH_SCOPE}&callback_url=${callbackUrl}&expire=${expire}`
|
||||
scope = `${Invidious.AUTH_SCOPE}`.EncodeUriComponent()
|
||||
return `${invidiousHost}/authorize_token?scopes=${scope}&callback_url=${callbackUrl}&expire=${expire}`
|
||||
end function
|
||||
|
||||
function GetAuthenticationHeaders(token as string) as object
|
||||
|
||||
Reference in new issue
Block a user