8 files changed
+141
-28
No files matched your search
@@ -0,0 +1,26 @@
|
||||
TODO:
|
||||
- New template
|
||||
- Use brighterscript
|
||||
- Use classes and tests
|
||||
- Use vs code config
|
||||
- Use unit tests
|
||||
- Use bs promises
|
||||
- Check tools under roku community (linter, etc)
|
||||
- Use RALE app to make UIs
|
||||
- Fix non-Latin characters (Unicode on Roku sucks)
|
||||
|
||||
|
||||
FEATURES:
|
||||
- Sign in with account
|
||||
- Youtube backend abstraction (Invidious vs TubeArchvist)
|
||||
- Settings page
|
||||
- Configure SponsorBlock
|
||||
- Configure Invidious Backend (allow self-hosted)
|
||||
- Closed caption settings?
|
||||
- Search page
|
||||
- Channel page
|
||||
- Comments page? (especially on live videos)
|
||||
- Dislike count?
|
||||
- Closed caption
|
||||
- Launch app to specific video (deep link)
|
||||
- Youtube android app -> share -> custom app -> push to tv
|
||||
@@ -21,6 +21,12 @@ sub GetContent()
|
||||
rootChildren.Push(popular)
|
||||
end if
|
||||
|
||||
feedJson = RokuYoutube.Services.Invidious.GetUserFeed()
|
||||
feed = GetCategoryContent("Subscriptions", feedJson)
|
||||
if feed <> invalid
|
||||
rootChildren.Push(feed)
|
||||
end if
|
||||
|
||||
' set up a root ContentNode to represent rowList on the GridScreen
|
||||
contentNode = CreateObject("roSGNode", "ContentNode")
|
||||
contentNode.Update({
|
||||
|
||||
@@ -1,30 +1,3 @@
|
||||
' TODO:
|
||||
' - New template
|
||||
' - Use brighterscript
|
||||
' - Use classes and tests
|
||||
' - Use vs code config
|
||||
' - Use unit tests
|
||||
' - Use bs promises
|
||||
' - Check tools under roku community (linter, etc)
|
||||
' - Use RALE app to make UIs
|
||||
' - Fix non-Latin characters (Unicode on Roku sucks)
|
||||
|
||||
|
||||
' FEATURES:
|
||||
' - Sign in with account
|
||||
' - Youtube backend abstraction (Invidious vs TubeArchvist)
|
||||
' - Settings page
|
||||
' - Configure SponsorBlock
|
||||
' - Configure Invidious Backend (allow self-hosted)
|
||||
' - Closed caption settings?
|
||||
' - Search page
|
||||
' - Channel page
|
||||
' - Comments page? (especially on live videos)
|
||||
' - Dislike count?
|
||||
' - Closed caption
|
||||
' - Launch app to specific video (deep link)
|
||||
' - Youtube android app -> share -> custom app -> push to tv
|
||||
|
||||
function Main(args as dynamic)
|
||||
initScreen()
|
||||
end function
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
||||
import "pkg:/source/models/SearchSuggestionResult.bs"
|
||||
import "pkg:/source/models/SearchFilter.bs"
|
||||
import "pkg:/source/utils/Registry.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 +13,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 +93,46 @@ namespace RokuYoutube.Services.Invidious
|
||||
return response.json
|
||||
end if
|
||||
end function
|
||||
|
||||
function GetAuthorizeTokenLink()
|
||||
' Make sure the host is not on https, because https cannot redirect to http, which is our local server
|
||||
invidiousHost = strReplace(API_URL, "https://", "http://")
|
||||
scope = ":*"
|
||||
|
||||
localIp = GetLocalIpAddress()
|
||||
webServerPort = 8888
|
||||
expire = Now().AsSeconds() + 60 * 60 * 24 * 30 'A month from now
|
||||
|
||||
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
|
||||
return {
|
||||
"Authorization": `Bearer ${token}`
|
||||
}
|
||||
end function
|
||||
|
||||
function GetUserFeed()
|
||||
headers = GetAuthenticationHeaders()
|
||||
if headers = invalid
|
||||
return invalid
|
||||
end if
|
||||
|
||||
url = `${API_URL}${AUTH_FEED}`
|
||||
|
||||
args = {
|
||||
headers: headers,
|
||||
retryCount: 3 'Sometimes authentication fails randomly with a valid token...
|
||||
}
|
||||
|
||||
response = Requests().get(url, args)
|
||||
if response.statuscode = 200
|
||||
return response.json.videos
|
||||
end if
|
||||
end function
|
||||
end namespace
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace RokuYoutube.Utils.Registry
|
||||
|
||||
function Read(key, section = invalid)
|
||||
if section = invalid section = "Default"
|
||||
sec = CreateObject("roRegistrySection", section)
|
||||
if sec.Exists(key) return sec.Read(key)
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function Write(key, value, section = invalid)
|
||||
if section = invalid section = "Default"
|
||||
sec = CreateObject("roRegistrySection", section)
|
||||
sec.Write(key, value)
|
||||
sec.Flush()
|
||||
end function
|
||||
|
||||
function Delete(key, section = invalid)
|
||||
if section = invalid section = "Default"
|
||||
sec = CreateObject("roRegistrySection", section)
|
||||
sec.Delete(key)
|
||||
sec.Flush()
|
||||
end function
|
||||
|
||||
end namespace
|
||||
@@ -1,3 +1,5 @@
|
||||
import "pkg:/source/utils/Registry.bs"
|
||||
|
||||
namespace RokuYoutube.Http
|
||||
function GetHttpReplyId()
|
||||
m.http_reply_id = validint(m.http_reply_id) + 1
|
||||
@@ -58,6 +60,20 @@ namespace RokuYoutube.Http
|
||||
' work out path of file being requested
|
||||
req = m.request
|
||||
uri = req.uri
|
||||
|
||||
' TODO: move to proper middleware system
|
||||
if uri.StartsWith("/token_callback")
|
||||
components = UrlQueryComponents(uri)
|
||||
if components["token"] <> invalid
|
||||
' Token is encoded twice for some reason
|
||||
token = UrlUnescape(components["token"]).DecodeUriComponent()
|
||||
print(`Got Token: ${token}`)
|
||||
RokuYoutube.Utils.Registry.Write("token", token)
|
||||
end if
|
||||
m.Default(200, "OK")
|
||||
return true
|
||||
end if
|
||||
|
||||
decoded_uri = UrlUnescape(uri)
|
||||
path = CreateObject("roPath", m.settings.WwwRoot + decoded_uri)
|
||||
fs = CreateObject("roFilesystem")
|
||||
|
||||
@@ -37,3 +37,10 @@ Function IsHD()
|
||||
return false
|
||||
End Function
|
||||
|
||||
Function GetLocalIpAddress()
|
||||
di = CreateObject("roDeviceInfo")
|
||||
ips = di.GetIPAddrs()
|
||||
for each ip in ips
|
||||
return ips[ip]
|
||||
end for
|
||||
End Function
|
||||
@@ -139,6 +139,22 @@ function UrlUnescape(url as String) as String
|
||||
return ue.unescape(url)
|
||||
end function
|
||||
|
||||
function UrlQueryComponents(url as String)
|
||||
query = {}
|
||||
index = Instr(0, url, "?")
|
||||
url = Mid(url, index+1)
|
||||
components = url.split("&")
|
||||
for each component in components
|
||||
if Instr(0, component, "=")
|
||||
keyValue = component.split("=")
|
||||
query[keyValue[0]] = keyValue[1]
|
||||
else
|
||||
query[keyValue[0]] = ""
|
||||
end if
|
||||
end for
|
||||
return query
|
||||
end function
|
||||
|
||||
function MimeType(uri="" as String) as String
|
||||
map = m.MimeTypes
|
||||
if map = invalid
|
||||
|
||||
Reference in new issue
Block a user