Search screen (#10)

* Search screen with keyboard and suggestions

* Clear search on visibility change

* Search page works

* Local search history

* Use built-in delete function

* Changelog

* Animation

* Adjust suggestions

* Web play video always goes to home
This commit is contained in:
Brahim Hadriche authored and GitHub committed 2022-11-23 09:02:05 -05:00
1 parent 22dfe785f1
commit 740440c3a7
15 files changed
+395 -22

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
import "pkg:/source/services/Invidious.bs"
function Init()
m.top.functionName = "TaskMain"
end function
function TaskMain()
input = m.top.getField("input")
q = input.q
rootChildren = []
response = Invidious.Search(q, { type: "video" })
rowContent = GetCategoryContent(`Search - ${q}`, response)
if rowContent <> invalid
rootChildren.Push(rowContent)
end if
m.top.setField("output", {
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