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

Add Live TV Channels and People to search results. #2104

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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: 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
3 changes: 3 additions & 0 deletions source/Main.bs
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,9 @@ sub Main (args as dynamic) as void
m.global.queueManager.callFunc("resetShuffle")
m.global.queueManager.callFunc("push", screenContent.albumData.items[node.id])
m.global.queueManager.callFunc("playQueue")
else if node.type = "Playlist"
group = CreatePlaylistView(node.json)
sceneManager.callFunc("pushScene", group)
else
' TODO - switch on more node types
stopLoadingSpinner()
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
Loading