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