Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search fix - using the Users/Items api instead of Search Hints. #1453

Merged
merged 3 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions components/search/SearchRow.brs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function getData()
"PlaylistsFolder": { "label": "Playlist", "count": 0 }
}

for each item in itemData.searchHints
for each item in itemData.Items
if content_types[item.type] <> invalid
content_types[item.type].count += 1
end if
Expand All @@ -86,10 +86,9 @@ sub addRow(data, title, type_filter)
itemData = m.top.itemData
row = data.CreateChild("ContentNode")
row.title = title
for each item in itemData.SearchHints
for each item in itemData.Items
if item.type = type_filter
row.appendChild(item)
end if
end for
end sub

10 changes: 3 additions & 7 deletions source/api/Items.brs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ end function

' Search across all libraries
function searchMedia(query as string)
' This appears to be done differently on the web now
' For each potential type, a separate query is done:
' varying item types, and artists, and people
if query <> ""
resp = APIRequest(Substitute("Search/Hints", m.global.session.user.id), {
data = api.users.GetItemsByQuery(m.global.session.user.id, {
"searchTerm": query,
"IncludePeople": true,
"IncludeMedia": true,
Expand All @@ -56,15 +53,14 @@ function searchMedia(query as string)
"limit": 100
})

data = getJson(resp)
results = []
for each item in data.SearchHints
for each item in data.Items
tmp = CreateObject("roSGNode", "SearchData")
tmp.image = PosterImage(item.id)
tmp.json = item
results.push(tmp)
end for
data.SearchHints = results
data.Items = results
return data
end if
return []
Expand Down