Automatically assigning devices to groups

Hi,

Ive finally managed to get my head around the templates / groups / devicebrowser process (thanks for the videos John/Brian). I got to thinking how this could work for the kodi plugin I made, and it works quite nicely.

Ive set up each movie as a device, pulling in title, movie, year, rating and id for click to start and created a template. Given Kodi could have 100s or 1000s of videos and therefore devices (how ive made it) is it possible to run a script or in the plugin to assign devices to groups enmass?

Regards,

JohnKodi_DeviceBrowser2 - Copy.hrp (1.6 MB)

A workaround is using excel to create to tags and manually insert into the groups.xml… would be great to be able to use the app directly though.

I’d recommend taking a completely different approach. I’m not wild about the idea of creating Devices & Groups for your movies. If I were writing this, I’d create a single Kodi device & add a Movies & SelectedMovie attribute to it. Movies can be an array of all of your movies & you could bind that to a GridView. That will be a little cleaner & more dynamic.

Kodi_Array.hrp (7.4 KB)

function onConnect() {
    var movies = [{ Id: "1", Title: "Airplane", Thumbnail: "https://upload.wikimedia.org/wikipedia/en/2/21/Airplane%21_%281980_film%29.jpg" }, { Id: "2", Title: "Batman Begins", Thumbnail:"https://upload.wikimedia.org/wikipedia/en/a/af/Batman_Begins_Poster.jpg" }, { Id: "3", Title: "The Aviator", Thumbnail:"https://upload.wikimedia.org/wikipedia/en/f/fa/The_Aviator_%282004%29.png" }];
    var kodiDevice = plugin.Devices[DEVICE_ID];
    if (kodiDevice != null) {
        kodiDevice.Movies = movies;
    }
}

Take advantage of the new ItemsSource, TextMemberPath, SelectedValuePath, & IconMemberPath properties on the GridView.

NOTE: The current version does of IconMemberPath only supports display of images from the Images folder in the project. The next version I will try to add support for URL images from your Kodi server or from the web. This simulator screenshot showing the images was taken from my development build, not the current release build 3.0.21.

Thanks Bill, I will take a look at your example, ive not used the gridview function before or TextMemberPath, SelectedValuePath, & IconMemberPath so your example will help me understand it.

Ive just spent a couple of days doing my way but as I said before its good learning to understand the js scripting. The new way reduces the code from my original way by about 60% but im sure your way is better again.

Thanks for your advice.

John

Hi Bill,

I was able to create some basic gridviews using the data from my server and also a simple command to update the items based on the genre. Probably took me 10x the JS in my original plugin to do this.

I assume the grid view cannot have multiple entries per item for the additional items such as year and rating etc (textmemberpath).

It would be great to have the web thumbnails of course, its lacking the polish this way without the thumbs.

John

Correct. That is 1 of the limitations. You can only have 1 text field.

I agree. I just finished adding the thumbnail feature a little bit ago. It’ll be in this week’s release. The GridView will be able to load HTTP & HTTPS URLS just like that example I shared.

Great thanks Bill, the software is getting better and better. I wonder how many of the old irule guys finally came over - this is a much better solution of course but with a steep learning curve for us mere mortals. Ive enjoyed learning some basic JS.

John

1 Like

Assuming this is not yet implemented as I cannot get my images from URLs to display?

This has been implemented. The example I posted should run on any device.

Pretty much identical to what I have. I am basing my plugin off of the Kodi one. I will PM you my array data.

I know what it is, I have basic auth on.