Add search functions
This commit is contained in:
1 parent
ef371da10c
commit
f98b9d47bc
4 files changed
+65
-3
No files matched your search
Vendored
-2
@@ -9,7 +9,6 @@
|
|||||||
"build"
|
"build"
|
||||||
],
|
],
|
||||||
"files.exclude": {
|
"files.exclude": {
|
||||||
"build": true,
|
|
||||||
".history": true,
|
".history": true,
|
||||||
"node_modules": true,
|
"node_modules": true,
|
||||||
"out": true,
|
"out": true,
|
||||||
@@ -19,7 +18,6 @@
|
|||||||
"**/.factorypath": true,
|
"**/.factorypath": true,
|
||||||
"/tmp/**": true,
|
"/tmp/**": true,
|
||||||
"**/dist": true,
|
"**/dist": true,
|
||||||
"**/build": true,
|
|
||||||
"**/out": true
|
"**/out": true
|
||||||
},
|
},
|
||||||
"search.exclude": {
|
"search.exclude": {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace RokuYoutube.Models.Invidious
|
||||||
|
|
||||||
|
class SearchSuggestionResult
|
||||||
|
|
||||||
|
public query as string
|
||||||
|
public suggestions as Array
|
||||||
|
|
||||||
|
end class
|
||||||
|
|
||||||
|
end namespace
|
||||||
@@ -1,11 +1,16 @@
|
|||||||
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
||||||
|
import "pkg:/source/models/SearchSuggestionResult.bs"
|
||||||
|
|
||||||
namespace RokuYoutube.Services.Invidious
|
namespace RokuYoutube.Services.Invidious
|
||||||
const API_URL = "https://invidious.esmailelbob.xyz"
|
const API_URL = "https://invidious.esmailelbob.xyz"
|
||||||
const POPULAR_ENDPOINT = "/api/v1/popular"
|
const POPULAR_ENDPOINT = "/api/v1/popular"
|
||||||
const TRENDING_ENDPOINT = "/api/v1/trending"
|
const TRENDING_ENDPOINT = "/api/v1/trending"
|
||||||
|
|
||||||
const VIDEOS_ENDPOINT = "/api/v1/videos"
|
const VIDEOS_ENDPOINT = "/api/v1/videos"
|
||||||
|
|
||||||
|
const SEARCH_SUGGEST_ENDPOINT = "/api/v1/search/suggestions"
|
||||||
|
const SEARCH_ENDPOINT = "/api/v1/search"
|
||||||
|
|
||||||
function GetPopular()
|
function GetPopular()
|
||||||
url = `${API_URL}${POPULAR_ENDPOINT}`
|
url = `${API_URL}${POPULAR_ENDPOINT}`
|
||||||
response = Requests().get(url)
|
response = Requests().get(url)
|
||||||
@@ -34,4 +39,54 @@ namespace RokuYoutube.Services.Invidious
|
|||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function SearchSuggestions(q as string) as SearchSuggestionResult
|
||||||
|
url = `${API_URL}${SEARCH_SUGGEST_ENDPOINT}`
|
||||||
|
args = {
|
||||||
|
params: {
|
||||||
|
q: q
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response = Requests().get(url, args)
|
||||||
|
|
||||||
|
if response.statuscode = 200
|
||||||
|
return response.json
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function Search(q as string, page = invalid, sort_by = invalid, date = invalid, duration = invalid, _type = invalid, features = invalid)
|
||||||
|
url = `${API_URL}${SEARCH_ENDPOINT}`
|
||||||
|
|
||||||
|
params = {
|
||||||
|
q: q
|
||||||
|
}
|
||||||
|
|
||||||
|
if page <> invalid
|
||||||
|
params.page = page
|
||||||
|
end if
|
||||||
|
if sort_by <> invalid
|
||||||
|
params.sort_by = sort_by
|
||||||
|
end if
|
||||||
|
if date <> invalid
|
||||||
|
params.date = date
|
||||||
|
end if
|
||||||
|
if duration <> invalid
|
||||||
|
params.duration = duration
|
||||||
|
end if
|
||||||
|
if _type <> invalid
|
||||||
|
params.type = _type
|
||||||
|
end if
|
||||||
|
if features <> invalid
|
||||||
|
params.features = features.join(",")
|
||||||
|
end if
|
||||||
|
|
||||||
|
args = {
|
||||||
|
params: params
|
||||||
|
}
|
||||||
|
|
||||||
|
response = Requests().get(url, args)
|
||||||
|
|
||||||
|
if response.statuscode = 200
|
||||||
|
return response.json
|
||||||
|
end if
|
||||||
|
end function
|
||||||
end namespace
|
end namespace
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
' TODO: remove Requests.brs and import it from installed package
|
|
||||||
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
||||||
|
|
||||||
namespace RokuYoutube.Services.SponsorBlock
|
namespace RokuYoutube.Services.SponsorBlock
|
||||||
|
|||||||
Reference in new issue
Block a user