Plugin.video.themoviedb.helper: [Request] Random Widgets

Created on 22 Dec 2019  Ā·  45Comments  Ā·  Source: jurialmunkey/plugin.video.themoviedb.helper

Hello! Thank you very much for this awesome addon.

The issue I am having it each page of movies has a count of 10, then with a Next Page button.

When you point it to a widget, say the Trakt list ā€œLatest Releasesā€ for example, the widget will always only display the items from the first page.

I apologize if there is already a way to fix this that I am unaware, I just couldn’t find anything on it.

Most helpful comment

I'm also loving it, but was wondering about the order that the property is set... because it doesn't appear in a widget label until after the widget has loaded. Is it possible to set that property _before_ the widget has fully loaded?

No because Kodi only creates listitems once the Plugin has signalled that the directory is complete and at that stage the plugin no longer has control over the items. The only way to get a property earlier would be to set it to a window property but then you have the issue of giving the window property a unique name so that it doesn't clash with the properties of other widgets (appending the container ID to the property name is the obvious approach but I'm not aware of a way to get the container ID from inside the plugin).

All 45 comments

Are you asking how to show the next page item on a widget?

To show the next page item you need to add &nextpage=True to the plugin path.
https://github.com/jurialmunkey/plugin.video.themoviedb.helper/wiki/Widget-Params

Thank you for your response.

I’m looking for the page to display more than 10 items before coming to the end of page one.

After looking at some other lists from other addons, I know what the problem is now, they have more than 10 items per page. šŸ˜‚ My bad.

Instead, I’d like to throw in a very minor feature request for the ability to change the number of items that show up in a page in the settings.

My reasoning for this is so I can have the addon provide a list with a lot of items on a single page, then have the skin limit the items on the widget, and set the item order to random. That way when the widget updates, it always has different items.

For lists from TMDb, the API determines the number of items per page (which is 20). It is possible to change the limit for Trakt but, regardless, loading 50+ items just so you can randomise them is a terrible idea which would result in an excessive number of API calls.

I limit the number of items in Trakt lists for a reason: with extra art and watched indicators enabled, Trakt lists require three API calls per item (one each to fanarttv, trakt, and tmdb), which means a ten item list already needs 30 API calls. Excessive API calls is a quick way to get my API keys disabled.

Ah, I wasn’t aware of that. Thank you for the information. I apologize for posting an unnecessary request then, but I am glad I learned that information.

Thank you for all your hard work on this amazing addon!

No worries!

What lists were you trying to randomise? Depending on the criteria, I might be able to provide a list that randomises the the items shown whilst still only showing 10 items.

Well I definitely appreciate that! The main two lists I’d like to randomize are the trakt lists Popular and Trending.

This next question likely has nothing to do with this addon and probably more of a skin question, but since you develop AZ2 maybe you would know. Would it be possible to have an addon pull a random page from the widget within a criteria (day only pull a random page from pages 1-5) and use that as the widget on the home screen? Then every time it refreshes, it just pulls a different page (without ever pulling the other pages?). This is a pure curiosity question btw.

Well I definitely appreciate that! The main two lists I’d like to randomize are the trakt lists Popular and Trending.

Okay, I'll have a look at what I can do.

>

This next question likely has nothing to do with this addon and probably more of a skin question, but since you develop AZ2 maybe you would know. Would it be possible to have an addon pull a random page from the widget within a criteria (day only pull a random page from pages 1-5) and use that as the widget on the home screen? Then every time it refreshes, it just pulls a different page (without ever pulling the other pages?). This is a pure curiosity question btw.

I was actually thinking about doing something like this.

Difficult to get random without a script but you could definitely get the cycling between paths by using a skin variable as the widget path. It would require skin modifications though.

Probably much easier to do from the plugin side of things. I'll look into adding a "Random" section to the plugin - I might even be able to add something where you can choose from multiple different paths and have the widget choose them randomly.

I already have two "Random" widgets along these lines - the "Based on Recently Watched" and "Based on Most Watched" paths pick a random Recent/Most watched item and then show recommendations based upon that item - when the widget refreshes, a new item is selected at random.

I was thinking something similar for genres might be interesting (i.e. widget that picks a random genre each time) and maybe something for trakt lists (e.g. pick a random trending list etc.).

I've been attempting to write an add-on to do these types of "cycling" or "random" widgets, but was attempting to use Skin Shortcuts to set the properties, and ran into this: https://github.com/mikesilvo164/script.skinshortcuts/issues/10

Tackling it on the skin side may be a more fluid experience, but obviously isn't as "universal".

@jurialmunkey That would be an amazing feature to be able to choose multiple widget paths and have it randomly choose the path. That would effectively remedy this issue by allowing me to theoretically use it in any list (depending on implementation of course). Also, I was completely unaware of the Based on... paths, that feature’s presence makes me one step closer to using AZ2 over AuraMod lmao.

The genre idea is fantastic and I would use it.

@drinfernoo i read through that whole thread and I really hope you come to a solution for it as I am very excited for that addon you are developing!

I've been attempting to write an add-on to do these types of "cycling" or "random" widgets, but was attempting to use Skin Shortcuts to set the properties, and ran into this: mikesilvo164/script.skinshortcuts#10

Tackling it on the skin side may be a more fluid experience, but obviously isn't as "universal".

Definitely not looking to do anything that advanced. Waiting with anticipation for your random widget plugin! 😁

I was simply thinking of having a widgets section in my addon where users can pick some categories from the plugin to use as a random widget. I wouldn't need something like skinshortcuts to walk through node paths - I would just be showing a pop-up list of compatible categories from the plugin.

Okay, I've added a "Randomised" category.

So far I have Genres | Based on | Trending List | Popular List | Liked List | Your List

All of these will pick a random list of that type. The name of the list will by placed in $INFO[Container.PluginCategory]

I'll have some randomised page and additional options coming soon (the current ones were just the easiest to implement, whereas the others are a little more complex).

And this is why you are one of my favorite developers, the speed on which you got this done was ridiculous.

I will definitely be testing this when I get home. Thanks again šŸ‘

I've already pushed them to the repo as well with 2.0.16!

@jurialmunkey, if you're open to it, I'd love to pick your brain on Skin Shortcuts... I may be going about it all wrong by trying to call a "Just Select" method from Python, but have considered doing this as a custom window of my own.

Do you have any way to chat outside of GitHub or Kodi forum?

@Demonseeed - Okay, I've now added 4 lists that show randomised items from Trakt:
Trending | Popular | Most Played | Anticipated

These lists display 10 random items from a list of 50. For example, Random Popular Movies will get the 50 most popular movies on Trakt and then randomly select 10 to display in the list.

I tried out the random page idea but it honestly felt a bit odd and confusing, so I scrapped it. Randomising the items displayed is far superior to randomising the page.

Sounds good, I will check it out! Hate to bother you again about this, but could you possibly add the Based On.. lists? Now that I know about those, I will 100% use those.

As for the random pages - makes sense. I could definitely see some convoluted setting caused by it.

@drinfernoo - I'm pretty bad with any messenger apps, particularly with being an Aussie and the time difference with the rest of the world. If you want to start an Issue thread on the github repo page, I'll try and respond there.

Sounds good, I will check it out! Hate to bother you again about this, but could you possibly add the Based On.. lists? Now that I know about those, I will 100% use those.

What do you mean? They were already added in the last update.. The options that select a random list are still there (e.g. random genre or random trending list etc.) - I'm just not adding an option to show a random page number from a specific list (e.g. randomly show page 4 of popular movies).

Ah, gotcha! Sorry I misread your previous post. Still haven’t been home to check it out. Thanks again jurialmonkey!

Alright, I got home and tested out the Random Genres and Because You Watched random lists. These are perfect, thank you for your hard work.

One last question, I promise.
Is there a method for the widget label to include what it is pulling (maybe a $VAR?). That was bad explanation, so here’s an example of what I mean:

Random Movie Lost | Horror | {selected movie title} - where horror changes based off the genre it randomly selects.

Because You Watched Deadpool | {selected movie title} - where Deadpool changes based off the movie it selected.

If that’s not possible, then that’s okay. It’s not a major issue.

Ah I thought you would be able to get Container.PluginCategory for the label but it doesn't seem to work.

I've added a widget property to the listitems which you can reference if you know the container ID of the widget: $INFO[Container(ID).ListItem.Property(widget)]

In AZ2 you can find the container ID for the widget by looking in 1080i/script-skinshortcuts-includes.xml and finding the includes that start with: skinshortcuts-template-vertical-

Alternatively you can turn skin debugging overlay on with a shortcut that runs Skin.ToggleSetting(debuginfo)
That overlay shows the ID of the currently highlighted control in the top right. Highlight the widget and it will show what the ID is.

Awesome, I’ll have to check that out in a bit. Thanks so much!

Edit: worked like a charm!

Excellent!

I really dig this, but am a bit confused on how to get the proper label for the widget? For example, If I use "Random Movie Genre", can I use a variable in the widget label to denote which genre I'm seeing?

@drinfernoo Yes, you can. Use the variable that jurialmonkey posted above in the label, along with the ID provided.

For example, my random genre widget’s label is:
Random $INFO[Container(33106).ListItem.Property(widget)] Movies

Which in turn shows up as Random Horror Movies, with Horror being whatever genre it picked up.

So I’ve been testing it for a few days, and I love this. It’s fantastic.

However, I did notice when setting multiple of the same widget (for example more than one Random Movie Genre widgets) occasionally they will grab the same genre or watched item, or whatever it is.

Is it possible to have it recognize a genre has been chosen and prevent other widgets from choosing the same one?

Unfortunately not - each widget loads the plugin in a separate instance and so there isn't anyway to access the details of the other widgets other than by window properties. The big problem with using window properties is that widget containers typically refresh simultaneously - so even if I stored a whitelist/blacklist in a property, all the widgets would be attempting to retrieve it (and potentially write back to it) at the same time.

I'm also loving it, but was wondering about the order that the property is set... because it doesn't appear in a widget label until after the widget has loaded. Is it possible to set that property before the widget has fully loaded?

I'm also loving it, but was wondering about the order that the property is set... because it doesn't appear in a widget label until after the widget has loaded. Is it possible to set that property _before_ the widget has fully loaded?

No because Kodi only creates listitems once the Plugin has signalled that the directory is complete and at that stage the plugin no longer has control over the items. The only way to get a property earlier would be to set it to a window property but then you have the issue of giving the window property a unique name so that it doesn't clash with the properties of other widgets (appending the container ID to the property name is the obvious approach but I'm not aware of a way to get the container ID from inside the plugin).

Ah well, can’t be helped I guess. Thank you!

@jurialmunkey, would you possibly have an idea of how that widget property could be used in the instance that the container ID isn't static? I'm working on that shortcuts add-on, and an "intended" side effect is that widgets could have random content... meaning there would be no way to no which container had that particular widget.

@jurialmunkey, would you possibly have an idea of how that widget property could be used in the instance that the container ID isn't static? I'm working on that shortcuts add-on, and an "intended" side effect is that widgets could have random content... meaning there would be no way to no which container had that particular widget.

The container ID will always be static because it is defined from the skin side. Plugins can't modify the container ID.

I assume your plugin will work like so:

  1. User enters your plugin settings and sets up a "random" widget through an interface similar to skinshortcuts where they can select multiple plugin paths.
  2. The user then opens skin shortcuts and selects the "random" widget from your plugin.
  3. When your plugin loads, it selects one of the paths at random and updates the container path with the new "random" path.

If that is the basic flow, then the container ID will remain static.

The only way you could change the container ID from the plugin side of things is if you were using some sort of skin include code template building - and there are much simpler approaches than that.

While we are back on this request, I do have an unrelated but related question.

I have been looking at adding these as default widgets to your AZ2 skin, and then appending $INFO[Container(ID).ListItem.Property(widget)] to the label with the Container ID already there so nobody will have to reference this request and then figure out the container ID to get Horror in the label.

Is that whole finding the container ID automatically part actually possible?

So the "steps" you outlined are pretty much exactly what I'm doing. I'm launching the Skin Shortcuts management dialog, in order to manage a "submenu" group, using code like:

RunScript(script.skinshortcuts,type=manage&group=autowidget-$INFO[Window.Property(dialog.group)])

Where dialog.group is a property I'm setting. In this dialog, a label and widget path are set. I'm interested in letting the user set widget aspect and such here as well, but I'm not sure that's feasible with my current approach.

After that, the user points a widget (in the skin's dialog) at a path in my add-on, which "injects" a skin string (set with my values) into the .xml file that Skin Shortcuts creates. That initial modification means that an additional skin reload is needed, but after that, the widget refreshes "seamlessly" whenever I change the skin string to a new path. I simply use the labels that were set previously, and "inject" them into another skin string.

The issue I see is that if I have five paths to choose from, for example, and set two widgets to choose from those paths, then I won't know if, or more importantly, which widget has that content ahead of time, in order to set the container ID in the label.

Is that whole finding the container ID automatically part actually possible?

Not that I can think of...

FWIW, you can check out the latest build at: https://github.com/drinfernoo/plugin.program.autowidget/blob/devrepo/zips/plugin.program.autowidget/plugin.program.autowidget-0.0.57.zip

I've just made the repo public, but be aware this is super alpha, and isn't working perfectly yet. I would certainly appreciate any feedback you've got, though!

@drinfernoo - Ah, I understand what you are saying about container ID now. Hmm, I'll have to have a think about how it might be possible. I'll give your plugin a proper spin when I'm slightly less hungover...

Absolutely! Happy New Year!

@drinfernoo do you mind if I check it out too? I probably can’t be much help other than bug reporting but I’d love to nonetheless.

Happy New Year both of you!

@Demonseeed Absolutely! Hopefully over the next few days/weeks I'll get an actual announcement and release out, along with a repo to serve updates šŸ‘

@jurialmunkey I haven't really been worried too much about it, and rolling back through this thread, have come to an idea how I can do it in my personal setup... but have you by any chance put any thought into making the process of figuring the container ID and/or content being passed in any more streamlined?

@jurialmunkey I haven't really been worried too much about it, and rolling back through this thread, have come to an idea how I can do it in my personal setup... but have you by any chance put any thought into making the process of figuring the container ID and/or content being passed in any more streamlined?

Yeah I haven't been able to come up with anything from the plugin side of things. I think I've found a solution on the skin side of things using some skinshortcut tricks - but really a plugin side solution would be better.

@jurialmunkey Where are you setting this in the code? I'd like to use a similar method in AutoWidget šŸ‘

Where are you setting this in the code?

Sorry, I'm not quite following? Setting what exactly?

The ListItem.Property(widget) is being set to plugincategory here:
https://github.com/jurialmunkey/plugin.video.themoviedb.helper/blob/master/resources/lib/container.py#L283

Not sure if that's what you mean though.

Ah, so that property is set on each item in the list? I'm just trying to figure out, in this case, what ends up getting done with i.infoproperties?

Yep, set for every item. It's just a duplicate of the container property so that you can get it in a widget since you can't get container properties on widgets (only get them in media windows).

infoproperties is just a dictionary passed to the xbmcgui.ListItem() class' setProperties method:
https://codedocs.xyz/AlwinEsch/kodi/group__python__xbmcgui__listitem.html#ga7dc4c3a74ae823f4a349b35a9220ecae

This part of the code is where the actual listitem is generated and added to the directory:
https://github.com/jurialmunkey/plugin.video.themoviedb.helper/blob/master/resources/lib/listitem.py#L245-L272

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dairefagan picture dairefagan  Ā·  5Comments

alKODIque picture alKODIque  Ā·  5Comments

Blurayx picture Blurayx  Ā·  7Comments

Blurayx picture Blurayx  Ā·  3Comments

prateek33 picture prateek33  Ā·  5Comments