Initial auth work

This commit is contained in:
Brahim Hadriche committed 2022-11-04 17:15:23 -04:00
1 parent 99bf585d95
commit 13edce3d7a
6 files changed
+125 -1

No files matched your search

+39 -1
View File
@@ -3,7 +3,7 @@ import "pkg:/source/models/SearchSuggestionResult.bs"
import "pkg:/source/models/SearchFilter.bs"
namespace RokuYoutube.Services.Invidious
const API_URL = "https://invidious.esmailelbob.xyz"
const API_URL = "https://vid.puffyan.us"
const POPULAR_ENDPOINT = "/api/v1/popular"
const TRENDING_ENDPOINT = "/api/v1/trending"
@@ -12,6 +12,8 @@ namespace RokuYoutube.Services.Invidious
const SEARCH_SUGGEST_ENDPOINT = "/api/v1/search/suggestions"
const SEARCH_ENDPOINT = "/api/v1/search"
const AUTH_FEED = "/api/v1/auth/feed"
function GetPopular()
url = `${API_URL}${POPULAR_ENDPOINT}`
response = Requests().get(url)
@@ -90,4 +92,40 @@ namespace RokuYoutube.Services.Invidious
return response.json
end if
end function
function GetAuthorizeTokenLink()
'https://<invidious_host>/authorize_token?scopes=<SCOPE>&callback_url=<LOCAL_ROKU_SERVER>&expire=<EXPIRE>
invidiousHost = strReplace(API_URL, "https://", "http://")
scope = "GET:feed"
localIp = "192.168.1.107"
webServerPort = 8888
expire = 60 * 60 * 24 * 30
callbackUrl = UrlEncode(`http://${localIp}:${webServerPort}/token_callback`)
return `${invidiousHost}/authorize_token?scopes=${scope}&callback_url=${callbackUrl}&expire=${expire}`
end function
function GetAuthenticationHeaders()
token = RokuYoutube.Utils.Registry.Read("token")
if token = invalid
return invalid
end if
end function
function GetUserFeed()
headers = GetAuthenticationHeaders()
if headers = invalid
return invalid
end if
url = `${API_URL}${AUTH_FEED}`
args = { headers: headers }
response = Requests().get(url, args)
if response.statuscode = 200
return response.json.videos
end if
end function
end namespace