* Move src under playlet-lib * Update configuration * Update script * Update script * Working version * Vs code config WIP * Package lock sync * Lint fix * Fix images * Reuse config files * Kind of a working setup * Lock node version * Rename scripts to tools * Fix build scripts, lib url system * Lint fix * rale * Fix args and web server * Load fallbacks and build script cleanups * Remove unused method * no message * no message * Remove generic message field * Lint fix * no message * Use loading indicator on main app * Add playlet lib version to settings --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
46 lines
1.1 KiB
Plaintext
46 lines
1.1 KiB
Plaintext
import "pkg:/source/services/Invidious.bs"
|
|
|
|
@asynctask
|
|
function SearchTask(input as object) as object
|
|
q = input.q
|
|
|
|
rootChildren = []
|
|
|
|
response = Invidious.Search(q, { type: "video" })
|
|
|
|
rowContent = GetCategoryContent(`Search - ${q}`, response)
|
|
if rowContent <> invalid
|
|
rootChildren.Push(rowContent)
|
|
end if
|
|
|
|
return {
|
|
q: q,
|
|
rootChildren: rootChildren
|
|
}
|
|
end function
|
|
|
|
function GetCategoryContent(category as string, json as object) as object
|
|
if json <> invalid and json.Count() > 0
|
|
row = {}
|
|
row.title = category
|
|
row.children = []
|
|
for each item in json ' parse items and push them to row
|
|
itemData = GetItemData(item)
|
|
if itemData <> invalid
|
|
row.children.Push(itemData)
|
|
end if
|
|
end for
|
|
return row
|
|
end if
|
|
return invalid
|
|
end function
|
|
|
|
function GetItemData(video as object) as object
|
|
' TODO: handle playlists and channels
|
|
if video.videoId = invalid
|
|
return invalid
|
|
end if
|
|
|
|
return video
|
|
end function
|