Skip to content

Commit

Permalink
Add Live TV Channels and People to search results.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimdogx committed Jan 18, 2025
1 parent 0fd3721 commit 34bd3a0
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 11 deletions.
5 changes: 3 additions & 2 deletions components/search/SearchRow.bs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function getData()
' todo - Or get the old data? I can't remember...
data = CreateObject("roSGNode", "ContentNode")
' Do this to keep the ordering, AssociateArrays have no order
type_array = ["Movie", "Series", "TvChannel", "Episode", "MusicArtist", "MusicAlbum", "Audio", "Person", "PlaylistsFolder"]
type_array = ["Movie", "Series", "TvChannel", "Episode", "MusicArtist", "MusicAlbum", "Audio", "Person", "Playlist", "Program"]
content_types = {
"TvChannel": { "label": "Channels", "count": 0 },
"Movie": { "label": "Movies", "count": 0 },
Expand All @@ -62,7 +62,8 @@ function getData()
"MusicAlbum": { "label": "Albums", "count": 0 },
"Audio": { "label": "Songs", "count": 0 },
"Person": { "label": "People", "count": 0 },
"PlaylistsFolder": { "label": "Playlist", "count": 0 }
"Playlist": { "label": "Playlist", "count": 0 },
"Program": { "label": "Programs", "count": 0 }
}

for each item in itemData.Items
Expand Down
56 changes: 47 additions & 9 deletions source/api/Items.bs
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,60 @@ end function
' Search across all libraries
function searchMedia(query as string)
if query <> ""
data = api.users.GetItemsByQuery(m.global.session.user.id, {
' Everything except Live TV shows (but including TV Channels)
data = api.items.Get({
"userid": m.global.session.user.id,
"searchTerm": query,
"IncludePeople": true,
"IncludeMedia": true,
"IncludeShows": true,
"IncludeGenres": true,
"IncludeStudios": true,
"IncludeArtists": true,
"IncludeItemTypes": "LiveTvChannel,Movie,BoxSet,Series,Episode,Video,Person,Audio,MusicAlbum,MusicArtist,Playlist",
"fields": "ChildCount, ItemCounts, Genres, RecursiveItemCount",
"IncludeItemTypes": "LiveTvChannel,Movie,BoxSet,Series,Episode,Video,Audio,MusicAlbum,MusicArtist,Playlist",
"EnableTotalRecordCount": false,
"ImageTypeLimit": 1,
"Recursive": true,
"limit": 100
})

if data = invalid then return []
people = api.persons.Get({
"userid": m.global.session.user.id,
"searchTerm": query,
"EnableTotalRecordCount": false,
"ImageTypeLimit": 1,
"limit": 100
})

if isValid(data) and isValid(people)
' we've got both regular stuff and people
data.Items.Append(people.Items)
else if isValid(people)
' we only have people
data = people
end if

' Separate query so that we can get all programs just like the Web Client
liveTv = api.items.Get({
"userid": m.global.session.user.id,
"searchTerm": query,
"IncludeItemTypes": "LiveTvProgram",
"EnableTotalRecordCount": false,
"ImageTypeLimit": 1,
"Recursive": true,
"limit": 100,
"IsMovie": false,
"IsSeries": false,
"IsSports": false,
"IsNews": false,
"IsKids": false
})

if isValid(data) and isValid(liveTv)
' we've got both regular stuff and live tv
data.Items.Append(liveTv.Items)
else if isValid(liveTv)
' we only have live tv
data = liveTv
else if not isValid(data)
' we have neither
return []
end if

results = []
for each item in data.Items
Expand Down
7 changes: 7 additions & 0 deletions source/api/sdk.bs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,13 @@ namespace api
end namespace

namespace items
' Gets items based on a query.
' requires userid passed in params
function Get(params = {} as object)
req = APIRequest("/items/", params)
return getJson(req)
end function

' Gets legacy query filters.
function GetFilters(params = {} as object)
req = APIRequest("/items/filters", params)
Expand Down

0 comments on commit 34bd3a0

Please sign in to comment.