neeo-sdk
neeo-sdk copied to clipboard
ListView parent or metadata
Let's say I have a list that is dynamically generated from some source (let's say I have a movie player that allows me to create custom collections of movies and I use the collection name as the high level directory listing):
- "Collections" (title bar)
- "Action Movies"
- "RomCom"
- "Other"
Assume there is a collection id associated with each collection title and the collection ID is what we are using for our browserId.
When I click on the "Action Movies" (which we will say is collection id 1), I want the following list shown
- "Action Movies" (title bar)
- "Top Gun"
- "Predator"
The issue I have is the title bar on the sublist. Since my browser id is the collection id - I'd need to retrieve the collections to simply get to the title to create the title bar of the sublist.
What would be great instead is to
- Have a reference to the parent list item when called back (so we'd have parm.offset, parm.lenght, parm.parent) that would allow me to get the title of the parent.
- Or better yet - be able to assign some meta data (generic json object) to each list item and that meta data is reflected back in the parms (parm.meta).
Hi @tmrobert8
Thanks for filing this issue and sorry for the delay. From what I see the sub-list information you get from the API doesn't have any title, correct? Therefore you would need to query the parent again to get the title. If the API had the following structure, this wouldn't be a problem. Do I understand this correctly?
{
"title": "Sublist Title",
"items": [...]
}
Before we dive into "solution space" I'd like to understand the problem fully and get some other opinions and maybe even API examples where that is a problem. @nklerk any thoughts from you?
Say I had a structure like:
Movies
By Genre
Some title
Some other title
By Producer
Some title
Music
But the "By Genre" and "By Producer" are dynamically generated from the source (could be those, could be some other names - all depends on how the source was setup.
What I'd like to do:
On the remote - I press the "Movies" list item. I move to a screen that has a title "Movies" and shows list items "By Genre" and "By Producer". If I press "By Genre", I move to a screen that says "Movies By Genre" and shows list items "Some title" and "Some other title"
Issue The problem is when I get down to the last structure - how do I create a "Movies By Genre" title? Currently, I have to re-retrieve the dynamic source and get the value.
The issue came up while writing the Kaleidescape driver - the movie collections (by genre, by producer, etc) are created on the Kaleidescape device and can be created & named or renamed by their UI (and you can really have an unlimited number of collections created by the user).
Since the API doesn't give me any reference to the parent list item - all I'd have is the value associated with that list item (which in my case is a collection id) and to get the title - I need to reretrieve all collections, filter for that collection id to get the title (then retrieve all the movie titles associated with that collection id).
While technically not an issue - slows down the UI quite a bit since there is an additional call.
One solution
If we could do something like:
.addListItem({ title: "By Genre", meta: { id: 123, title:"By Genre"}, browseIdentifier: 2})
and then in the callback - the parms would be:
{
browseIdentifier: 1,
limit: 0,
offset: 64,
meta: {id: 123, title: "By Genre"}
}
That would allow me to specify whatever I want for the parent item (in my example: the kaleidescape system identifier and the title that was clicked on) - then I have ALL the information I need to create the lower level as needed. I'm also not limited to a single "browseIdentifier" to represent all my state (which is quite limiting).
Tim
I requested special characters in the browser identifier earlier. https://github.com/NEEOInc/neeo-sdk/issues/83
There are multiple reasons to want this. for kodi I wanted it because there are multiple ID types. movies, albums, tracks, tvshows, episodes, etc etc. currently I'm passing multiple values through the browser identifier for different reasons. the workaround I'm using is ugly and I would love an object based solution.
This is what i'm using now:
if (browseIdentifier.match(/^.*;[0-9]*;.*$/)) {
const browseId = browseIdentifier.split(";");
const type = browseId[0];
const id = parseInt(browseId[1], 10);
const title = browseId[2];
I thought about doing that also but rejected it because the user can enter in the full ASCII character set via their keyboard and could potentially conflict with whatever separator I chose (and I didn't want to start layering in a full escaping system to compensate for that)
To be clear I'm not advertising my code as the solution, i'm not a dev as you all know, that my workaround is far from perfect is known to me ;-). Reason I added it is to provide the usecase i'm having and the not ideal solution I had to take for now.