From 34bd3a0964c13720213db5c96bc3d94609b61d1f Mon Sep 17 00:00:00 2001 From: Jimi Date: Sat, 18 Jan 2025 12:35:56 -0700 Subject: [PATCH] Add Live TV Channels and People to search results. --- components/search/SearchRow.bs | 5 +-- source/api/Items.bs | 56 ++++++++++++++++++++++++++++------ source/api/sdk.bs | 7 +++++ 3 files changed, 57 insertions(+), 11 deletions(-) diff --git a/components/search/SearchRow.bs b/components/search/SearchRow.bs index 8c78a1f83..b8dfac361 100644 --- a/components/search/SearchRow.bs +++ b/components/search/SearchRow.bs @@ -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 }, @@ -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 diff --git a/source/api/Items.bs b/source/api/Items.bs index 2dcf12348..5ebae0136 100644 --- a/source/api/Items.bs +++ b/source/api/Items.bs @@ -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 diff --git a/source/api/sdk.bs b/source/api/sdk.bs index b591b8251..b05bf2922 100644 --- a/source/api/sdk.bs +++ b/source/api/sdk.bs @@ -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)