Add country code arg for better feed
This commit is contained in:
1 parent
45c618ccda
commit
1c297ff014
3 files changed
+52
-37
No files matched your search
@@ -26,8 +26,9 @@ function GetVideoMetadata()
|
||||
videoMetadata = RokuYoutube.Services.Invidious.GetVideoMetadata(videoId)
|
||||
lastItag = videoMetadata.formatStreams[videoMetadata.formatStreams.Count() - 1].itag
|
||||
|
||||
' GetVideoUrl returns a url with the local=true, leading to less change of rate limit (403) - maybe?
|
||||
' GetVideoUrl returns a url with the local=true, which is proxied through the instance
|
||||
' TODO: is this reliable?
|
||||
' TODO: try direct videos first, before trying proxy, to avoid additional slowdowns
|
||||
videoUrl = RokuYoutube.Services.Invidious.GetVideoUrl(videoId, lastItag)
|
||||
videoMetadata.formatStreams.push({
|
||||
itag: lastItag,
|
||||
|
||||
@@ -15,9 +15,26 @@ namespace RokuYoutube.Services.Invidious
|
||||
|
||||
const AUTH_FEED = "/api/v1/auth/feed"
|
||||
|
||||
function GetCountryCode()
|
||||
if m.countryCode = invalid or m.countryCode = "" then
|
||||
m.countryCode = CreateObject("roDeviceInfo").GetUserCountryCode()
|
||||
end if
|
||||
return m.countryCode
|
||||
end function
|
||||
|
||||
function DefaultArgs()
|
||||
return {
|
||||
params: {
|
||||
region: GetCountryCode()
|
||||
}
|
||||
}
|
||||
end function
|
||||
|
||||
function GetPopular()
|
||||
url = `${API_URL}${POPULAR_ENDPOINT}`
|
||||
response = Requests().get(url)
|
||||
|
||||
args = DefaultArgs()
|
||||
response = Requests().get(url, args)
|
||||
|
||||
if response.statuscode = 200
|
||||
return response.json
|
||||
@@ -27,7 +44,7 @@ namespace RokuYoutube.Services.Invidious
|
||||
function GetTrending(trendingType = invalid as string)
|
||||
url = `${API_URL}${TRENDING_ENDPOINT}`
|
||||
|
||||
args = { params: {} }
|
||||
args = DefaultArgs()
|
||||
if trendingType <> invalid
|
||||
args.params.type = trendingType
|
||||
end if
|
||||
@@ -45,7 +62,9 @@ namespace RokuYoutube.Services.Invidious
|
||||
|
||||
function GetVideoMetadata(videoId as string)
|
||||
url = `${API_URL}${VIDEOS_ENDPOINT}/${videoId}`
|
||||
response = Requests().get(url)
|
||||
|
||||
args = DefaultArgs()
|
||||
response = Requests().get(url, args)
|
||||
|
||||
' TODO: handle 500 {"error":"This video is unavailable"}
|
||||
if response.statuscode = 200
|
||||
@@ -55,11 +74,9 @@ namespace RokuYoutube.Services.Invidious
|
||||
|
||||
function SearchSuggestions(q as string) as SearchSuggestionResult
|
||||
url = `${API_URL}${SEARCH_SUGGEST_ENDPOINT}`
|
||||
args = {
|
||||
params: {
|
||||
q: q
|
||||
}
|
||||
}
|
||||
|
||||
args = DefaultArgs()
|
||||
args.params.q = q
|
||||
response = Requests().get(url, args)
|
||||
|
||||
if response.statuscode = 200
|
||||
@@ -70,33 +87,28 @@ namespace RokuYoutube.Services.Invidious
|
||||
function Search(q as string, page = invalid as integer, sort_by = invalid as RokuYoutube.Models.Invidious.SearchFilter.SortBy, date = invalid as RokuYoutube.Models.Invidious.SearchFilter.Date, duration = invalid as RokuYoutube.Models.Invidious.SearchFilter.Duration, _type = invalid as RokuYoutube.Models.Invidious.SearchFilter.SearchType, features = invalid as RokuYoutube.Models.Invidious.SearchFilter.Features)
|
||||
url = `${API_URL}${SEARCH_ENDPOINT}`
|
||||
|
||||
params = {
|
||||
q: q
|
||||
}
|
||||
args = DefaultArgs()
|
||||
args.params.q = q
|
||||
|
||||
if page <> invalid
|
||||
params.page = Str(page)
|
||||
args.params.page = Str(page)
|
||||
end if
|
||||
if sort_by <> invalid
|
||||
params.sort_by = sort_by
|
||||
args.params.sort_by = sort_by
|
||||
end if
|
||||
if date <> invalid
|
||||
params.date = date
|
||||
args.params.date = date
|
||||
end if
|
||||
if duration <> invalid
|
||||
params.duration = duration
|
||||
args.params.duration = duration
|
||||
end if
|
||||
if _type <> invalid
|
||||
params.type = _type
|
||||
args.params.type = _type
|
||||
end if
|
||||
if features <> invalid
|
||||
params.features = features.join(",")
|
||||
args.params.features = features.join(",")
|
||||
end if
|
||||
|
||||
args = {
|
||||
params: params
|
||||
}
|
||||
|
||||
response = Requests().get(url, args)
|
||||
|
||||
if response.statuscode = 200
|
||||
|
||||
@@ -9,38 +9,40 @@ REM
|
||||
'******************************************************
|
||||
'Get our device version
|
||||
'******************************************************
|
||||
Function GetDeviceVersion()
|
||||
if m.softwareVersion = invalid OR m.softwareVersion = "" then
|
||||
function GetDeviceVersion()
|
||||
if m.softwareVersion = invalid or m.softwareVersion = "" then
|
||||
m.softwareVersion = CreateObject("roDeviceInfo").GetVersion()
|
||||
end if
|
||||
return m.softwareVersion
|
||||
End Function
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
'Get our serial number
|
||||
'******************************************************
|
||||
Function GetDeviceESN()
|
||||
if m.serialNumber = invalid OR m.serialNumber = "" then
|
||||
function GetDeviceESN()
|
||||
if m.serialNumber = invalid or m.serialNumber = "" then
|
||||
m.serialNumber = CreateObject("roDeviceInfo").GetDeviceUniqueId()
|
||||
end if
|
||||
return m.serialNumber
|
||||
End Function
|
||||
end function
|
||||
|
||||
|
||||
'******************************************************
|
||||
'Determine if the UI is displayed in SD or HD mode
|
||||
'******************************************************
|
||||
Function IsHD()
|
||||
function IsHD()
|
||||
di = CreateObject("roDeviceInfo")
|
||||
if di.GetDisplayMode() = "720p" then return true
|
||||
return false
|
||||
End Function
|
||||
end function
|
||||
|
||||
Function GetLocalIpAddress()
|
||||
di = CreateObject("roDeviceInfo")
|
||||
ips = di.GetIPAddrs()
|
||||
for each ip in ips
|
||||
return ips[ip]
|
||||
end for
|
||||
End Function
|
||||
function GetLocalIpAddress()
|
||||
if m.ipAddress = invalid or m.ipAddress = "" then
|
||||
ips = di.GetIPAddrs()
|
||||
for each ip in ips
|
||||
m.ipAddress = ips[ip]
|
||||
return m.ipAddress
|
||||
end for
|
||||
end if
|
||||
end function
|
||||
Reference in new issue
Block a user