Kodi Community Forum

Full Version: plugin.video.themoviedb.helper - Access to TheMovieDb API for Skinners
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
@bsoriano - try this:
Code:
<visible>[Container(90050).IsUpdating | Integer.IsGreater(Container(90050).NumItems,0)] + String.IsEmpty(Window(Home).Property(TMDbHelper.IsUpdating)) + !String.IsEmpty(Window(Home).Property(TMDbHelper.ListItem.Cast.1.Name))</visible>


Why don't you just use the Cast plugin path though?
<content>$VAR[TMDb_Cast]</content>
xml:

<variable name="TMDb_Cast">
<value condition="String.IsEqual(ListItem.DBType,movie) + !String.IsEmpty(ListItem.IMDBNumber) + String.StartsWith(ListItem.IMDBNumber,tt)">plugin://plugin.video.themoviedb.helper?info=cast&amp;type=movie&amp;imdb_id=$INFO[ListItem.IMDBNumber]</value>
<value condition="String.IsEqual(ListItem.DBType,movie)">plugin://plugin.video.themoviedb.helper?info=cast&amp;type=movie&amp;query=$INFO[ListItem.Title]</value>
<value condition="String.IsEqual(ListItem.DBType,season) | String.IsEqual(ListItem.DBType,episode) | String.IsEqual(ListItem.DBType,tvshow)">plugin://plugin.video.themoviedb.helper?info=cast&amp;type=tv&amp;query=$INFO[ListItem.TvShowTitle]</value>
</variable>
(2019-12-29, 23:21)jurialmunkey Wrote: [ -> ]@bsoriano - try this:
Code:
<visible>[Container(90050).IsUpdating | Integer.IsGreater(Container(90050).NumItems,0)] + String.IsEmpty(Window(Home).Property(TMDbHelper.IsUpdating)) + !String.IsEmpty(Window(Home).Property(TMDbHelper.ListItem.Cast.1.Name))</visible>


Why don't you just use the Cast plugin path though?
<content>$VAR[TMDb_Cast]</content>
xml:

<variable name="TMDb_Cast">
<value condition="String.IsEqual(ListItem.DBType,movie) + !String.IsEmpty(ListItem.IMDBNumber) + String.StartsWith(ListItem.IMDBNumber,tt)">plugin://plugin.video.themoviedb.helper?info=cast&amp;type=movie&amp;imdb_id=$INFO[ListItem.IMDBNumber]</value>
<value condition="String.IsEqual(ListItem.DBType,movie)">plugin://plugin.video.themoviedb.helper?info=cast&amp;type=movie&amp;query=$INFO[ListItem.Title]</value>
<value condition="String.IsEqual(ListItem.DBType,season) | String.IsEqual(ListItem.DBType,episode) | String.IsEqual(ListItem.DBType,tvshow)">plugin://plugin.video.themoviedb.helper?info=cast&amp;type=tv&amp;query=$INFO[ListItem.TvShowTitle]</value>
</variable>

@jurialmunkey, thank you! I had not thought of the plugin path for cast. If I do that, then the visibility condition would be just numitems > 0 or isupdating, correct?

Thanks again.

Regards,

Bart

EDIT: @jurialmunkey , using the cast plugin path works well, but it seems the plugin does not fill listitem.label2 for the character/role.  What is the property where the plugin stores the character/role for the cast?
(2019-12-30, 01:07)bsoriano Wrote: [ -> ]@jurialmunkey, thank you! I had not thought of the plugin path for cast. If I do that, then the visibility condition would be just numitems > 0 or isupdating, correct?
Yes, that's correct. Plus the condition that you use to hide this list if local cast is available -- I'm assuming you only show this online cast list if cast isn't available locally in id="50".


(2019-12-30, 01:07)bsoriano Wrote: [ -> ]EDIT: @jurialmunkey , using the cast plugin path works well, but it seems the plugin does not fill listitem.label2 for the character/role.  What is the property where the plugin stores the character/role for the cast?

ListItem.Property(character) - The name of the character that the cast member plays.
ListItem.Property(job) - The job that the crew member does (e.g. Director, Executive Producer, Screenplay Writer, Sound Editor etc.)
ListItem.Property(department) - The department that the crew member is from (e.g. Directing, Writing, Production, Crew, Art, Sound etc.)

Character is only relevant to cast lists. Job and Department are only relevant to crew lists.

There is also a catch-all property ListItem.Property(role) which will show character for cast members and job for crew members.
(2019-12-30, 01:42)jurialmunkey Wrote: [ -> ]
(2019-12-30, 01:07)bsoriano Wrote: [ -> ]@jurialmunkey, thank you! I had not thought of the plugin path for cast. If I do that, then the visibility condition would be just numitems > 0 or isupdating, correct?
Yes, that's correct. Plus the condition that you use to hide this list if local cast is available -- I'm assuming you only show this online cast list if cast isn't available locally in id="50".
 
(2019-12-30, 01:07)bsoriano Wrote: [ -> ]EDIT: @jurialmunkey , using the cast plugin path works well, but it seems the plugin does not fill listitem.label2 for the character/role.  What is the property where the plugin stores the character/role for the cast?

ListItem.Property(character) - The name of the character that the cast member plays.
ListItem.Property(job) - The job that the crew member does (e.g. Director, Executive Producer, Screenplay Writer, Sound Editor etc.)
ListItem.Property(department) - The department that the crew member is from (e.g. Directing, Writing, Production, Crew, Art, Sound etc.)

Character is only relevant to cast lists. Job and Department are only relevant to crew lists.

There is also a catch-all property ListItem.Property(role) which will show character for cast members and job for crew members. 
@jurialmunkey , thanks once more! I am only showing the online cast when tmdb_id is not empty, and I am showing the local cast when tmdb_id is empty.  I guess this is not ideal, since if the item is cached, container 50 will be filled.  I suppose I should only show the online cast if container 50 has 0 items?

Regards,

Bart
@bsoriano - Yes, you're correct - most efficient/quickest way would be to show online cast only if container 50 has 0 items. If TMDbHelper has previously cached the detailed item then 50 will already be filled.
@jurialmunkey , after using the cast plugin path for a couple of days I have noticed that when there are movies or tv shows with the same name for different years or with similar names to other movies or tv shows, the cast plugin path brings the cast for the first one found (I presume), not from the specific movie or tv show that I am looking at.  Could you add the year in the search for the cast for this plugin path? Thanks.

For example, looking at the tv show "For Life" from 2020, the cast path brings the cast for the show "Grounded For Life" from 2001.  When looking at the movie "Parasite" from 2019, it brings the cast for the movie "Parasite" from 1982.

Regards,

Bart
(2019-12-31, 16:27)bsoriano Wrote: [ -> ]@jurialmunkey , after using the cast plugin path for a couple of days I have noticed that when there are movies or tv shows with the same name for different years or with similar names to other movies or tv shows, the cast plugin path brings the cast for the first one found (I presume), not from the specific movie or tv show that I am looking at.  Could you add the year in the search for the cast for this plugin path? Thanks.

For example, looking at the tv show "For Life" from 2020, the cast path brings the cast for the show "Grounded For Life" from 2001.  When looking at the movie "Parasite" from 2019, it brings the cast for the movie "Parasite" from 1982.

Regards,

Bart

Add &amp;year=$INFO[ListItem.Year] to plugin path or use &amp;imdb_id=$INFO[ListItem.IMDBNumber] instead.
(2019-12-31, 19:25)jurialmunkey Wrote: [ -> ]
(2019-12-31, 16:27)bsoriano Wrote: [ -> ]@jurialmunkey , after using the cast plugin path for a couple of days I have noticed that when there are movies or tv shows with the same name for different years or with similar names to other movies or tv shows, the cast plugin path brings the cast for the first one found (I presume), not from the specific movie or tv show that I am looking at.  Could you add the year in the search for the cast for this plugin path? Thanks.

For example, looking at the tv show "For Life" from 2020, the cast path brings the cast for the show "Grounded For Life" from 2001.  When looking at the movie "Parasite" from 2019, it brings the cast for the movie "Parasite" from 1982.

Regards,

Bart

Add &amp;year=$INFO[ListItem.Year] to plugin path or use &amp;imdb_id=$INFO[ListItem.IMDBNumber] instead.

@jurialmunkey, will do, thanks!

Regards,

Bart
@jurialmunkey i am working on your way to integrate the video info and actor info. Oh man... this is a hell of hack. Is the kind of hack that i dislike in skinning. Is there not any other way to do this?... besides sualfred's script.

In any case there is one glitch in this way. If you accidentally click twice on RunScript(plugin.video.themoviedb.helper,add_path or del_path then the custom info window it's reloading twice or triple if you click three times. Is there a way to avoid this?

Also, in person's info, is there way to have an infolabel with the number of items (movies & tv shows) that are in the local library?.


Thanks
Nessus
(2019-12-31, 20:27)nessus Wrote: [ -> ]@jurialmunkey i am working on your way to integrate the video info and actor info. Oh man... this is a hell of hack. Is the kind of hack that i dislike in skinning. Is there not any other way to do this?... besides sualfred's script.
Yeah, it's really hacky - I've been looking for a way to make it a bit more stable but unfortunately I haven't found another way other than resorting to an extendedinfo type script such as Sualfred's.

There is a way in python to call the info dialog directly for a listitem, which looked promising - but unfortunately it puts the info dialog lists from plugins into an IsUpdating loop where they never resolve. That method treats the info dialog like a confirmation dialog that needs to be closed before the rest of the script can complete. So far I haven't found a way around it, which is frustrating because otherwise it was working really well.

(2019-12-31, 20:27)nessus Wrote: [ -> ]In any case there is one glitch in this way. If you accidentally click twice on RunScript(plugin.video.themoviedb.helper,add_path or del_path then the custom info window it's reloading twice or triple if you click three times. Is there a way to avoid this?
I send focus back to my default control (grouplist of dialog buttons). Has the added advantage of resetting the info dialog back to its default position.

(2019-12-31, 20:27)nessus Wrote: [ -> ]Also, in person's info, is there way to have an infolabel with the number of items (movies & tv shows) that are in the local library?.
For individual lists, yes. In latest update $INFO[Container(ID).ListItem.Property(numitems.dbid)] and $INFO[Container(ID).ListItem.Property(numitems.tmdb)] will give you the number of local and online items respectively. These are also set to Container.Property(numitems.dbid/tmdb) but for some reason it isn't possible to access container properties by ID, so I've had to set them to the listitems.
(2020-01-01, 09:28)jurialmunkey Wrote: [ -> ]There is a way in python to call the info dialog directly for a listitem, which looked promising - but unfortunately it puts the info dialog lists from plugins into an IsUpdating loop where they never resolve. That method treats the info dialog like a confirmation dialog that needs to be closed before the rest of the script can complete. So far I haven't found a way around it, which is frustrating because otherwise it was working really well.
I understand. No problem. I will go with this atm. Keep me posted if you find a better way.
 
(2020-01-01, 09:28)jurialmunkey Wrote: [ -> ]I send focus back to my default control (grouplist of dialog buttons). Has the added advantage of resetting the info dialog back to its default position.
Can you please be more specific on this?. I mean like in arctic zephyr code example.
 
(2020-01-01, 09:28)jurialmunkey Wrote: [ -> ]For individual lists, yes. In latest update $INFO[Container(ID).ListItem.Property(numitems.dbid)] and $INFO[Container(ID).ListItem.Property(numitems.tmdb)] will give you the number of local and online items respectively. These are also set to Container.Property(numitems.dbid/tmdb) but for some reason it isn't possible to access container properties by ID, so I've had to set them to the listitems.
I cant get these info. Which Container(ID) do you mean? I've set it to the hidden list container in custom tmdb info window but is not working while the others are working fine... eg $INFO[Container(999).ListItemAbsolute(0).Property(Born)]

EDIT: I just saw that if i set the id of the list container of eg info=stars_in_movies then the property is filled after the container is updated. Until then the property is empty. IMHO that's not proper behavior because you may want to see only the infos and not any of the lists.
Also is it possible to have total numitems.tmdb/numitems.dbid for movies or tv shows from both info=stars_in_movies and info=crew_in_movies ?

 
Two more questions about this...
1. Why in arctic zephyr example don't you use the actual plugin path in the <content/> tags instead of these Info_Cast_Listxx variables?. Is there a downside if i use the actual plugin path?... plugin://plugin.video.themoviedb.helper?info=stars_in_movies&amp;type=person&amp;tmdb_id=$INFO[Container(999).ListItemAbsolute(0).Property(tmdb_id)]&amp;extended=True

2. When i am in the custom tmdb info window and clicking on an item (movie or tv show), the video info dialog opens properly but if i go back to custom tmdb info window, but, to go out also from there i need to click/back twice to close the window. The weird thing is that if i click on item (movie or tv show) and click again on an item (movie or tv show) in the opened video info dialog, then when i go back all the way to close all the windows it works fine and it needs only one click/back. Any idea?


Thanks
Nessus
(2020-01-01, 14:33)nessus Wrote: [ -> ]> I send focus back to my default control (grouplist of dialog buttons). Has the added advantage of resetting the info dialog back to its default position.
Can you please be more specific on this?. I mean like in arctic zephyr code example.
Here's my onclick action for my info dialog lists: https://github.com/jurialmunkey/skin.arc...l#L96-L106

AZ2 info dialog has a fullscreen group that has poster, info and buttons (e.g. play, refresh etc.).
Pressing down scrolls to a separate fullscreen grouplist filled with widget lists.

Simplified, AZ2 info dialog looks like:
xml:

<control type="grouplist">
<include>FullScreenDimensions</include>

<!-- Main Page -->
<control type="group">
<include>FullScreenDimensions</include>
<!-- Info and Poster Here -->
<control type="grouplist" id="300">
<!-- Play Refresh etc. Buttons -->
</control>
</control>

<!-- Widgets Grouplist -->
<control type="grouplist">
<include>FullScreenDimensions</include>
<control type="list" id="5000">
</control>
<control type="list" id="5001">
</control>
<!-- More Lists Here -->
</control>
</control>

Simplified, my onclick actions are:
Code:

<onclick>SetFocus(5000)</onclick>
<onclick>SetFocus(300)</onclick>
<onclick>RunScript(...)</onclick>

So basically, I set focus to the first list in my grouplist of lists (id="5000"), then I set focus to my grouplist of control buttons (id="300"), then I run the script.

That way everything gets set back to initial positions before the next info dialog opens.


(2020-01-01, 14:33)nessus Wrote: [ -> ]I cant get these info. Which Container(ID) do you mean? I've set it to the hidden list container in custom tmdb info window but is not working while the others are working fine... eg $INFO[Container(999).ListItemAbsolute(0).Property(Born)]

EDIT: I just saw that if i set the id of the list container of eg info=stars_in_movies then the property is filled after the container is updated. Until then the property is empty. IMHO that's not proper behavior because you may want to see only the infos and not any of the lists.
Also is it possible to have total numitems.tmdb/numitems.dbid for movies or tv shows from both info=stars_in_movies and info=crew_in_movies ?
Only possible for individual lists.

Each plugin container is its own independent instance, which means it can only access its own info. Attempting cross talk between instances will create a race condition. Plus, even if I knew which container IDs the user wants to count, it isn't possible because Kodi creates the listitems *after* the plugin code is completed - so the code is finished before the info it needs is available.

This is where a scripted window like extended info has an advantage because it can pull in all the info that it needs at once and perform any needed data manipulation before creating any gui objects.

 
(2020-01-01, 14:33)nessus Wrote: [ -> ]Two more questions about this...
1. Why in arctic zephyr example don't you use the actual plugin path in the <content/> tags instead of these Info_Cast_Listxx variables?. Is there a downside if i use the actual plugin path?... plugin://plugin.video.themoviedb.helper?info=stars_in_movies&amp;type=person&amp;tmdb_id=$INFO[Container(999).ListItemAbsolute(0).Property(tmdb_id)]&amp;extended=True
No downside. If anything, your method is probably better.

My approach is a legacy from when I was using the window to show info for all types rather than just person (i.e. before I started calling the actual info dialog instead for movie/tv). Since either way works, I never bothered to change it.

(2020-01-01, 14:33)nessus Wrote: [ -> ]2. When i am in the custom tmdb info window and clicking on an item (movie or tv show), the video info dialog opens properly but if i go back to custom tmdb info window, but, to go out also from there i need to click/back twice to close the window. The weird thing is that if i click on item (movie or tv show) and click again on an item (movie or tv show) in the opened video info dialog, then when i go back all the way to close all the windows it works fine and it needs only one click/back. Any idea?

Do you have this condition in the hidden list?
<onfocus condition="String.IsEmpty(Window(Home).Property(TMDbHelper.Path.Current))">Action(Back)</onfocus>

Also, because the person info isn't a dialog, you need an onback condition in your controls to replicate the del_path onunload condition:
<onback condition="!String.IsEmpty(Window(Home).Property(TMDbHelper.Path.Current))">RunScript(plugin.video.themoviedb.helper,del_path,call_id=1137)</onback>
(2020-01-02, 00:07)jurialmunkey Wrote: [ -> ]So basically, I set focus to the first list in my grouplist of lists (id="5000"), then I set focus to my grouplist of control buttons (id="300"), then I run the script.

That way everything gets set back to initial positions before the next info dialog opens.
Yes, i have seen that code, but it does not fix the issue. I've reproduce it also in AZ2. It has the same issue if you click twice or three times to a cast item or try to go back from the custom tmdb info window.
 
(2020-01-02, 00:07)jurialmunkey Wrote: [ -> ]Only possible for individual lists.
Each plugin container is its own independent instance, which means it can only access its own info. Attempting cross talk between instances will create a race condition. Plus, even if I knew which container IDs the user wants to count, it isn't possible because Kodi creates the listitems *after* the plugin code is completed - so the code is finished before the info it needs is available.
That's a bummer!. I thought that these numbers were available by the API. So this means that i cant have a single number for both info=stars_in_movies and info=crew_in_movies numbers of items?
 
(2020-01-02, 00:07)jurialmunkey Wrote: [ -> ]Do you have this condition in the hidden list?
<onfocus condition="String.IsEmpty(Window(Home).Property(TMDbHelper.Path.Current))">Action(Back)</onfocus>

Also, because the person info isn't a dialog, you need an onback condition in your controls to replicate the del_path onunload condition:
<onback condition="!String.IsEmpty(Window(Home).Property(TMDbHelper.Path.Current))">RunScript(plugin.video.themoviedb.helper,del_path,call_id=1137)</onback>
Yes i do... in both. The weird thing is that if you go to a second or third level of clicking an item then going back works fine until the custom person info window closes.


EDIT: Also gender info is missing.
@nessus - Okay, I've managed to come up with what seems to be a far better way of handling the windows that simplifies the whole process quite a bit. Basically, when you run the script it will start a service monitor that manages the windows until you've finished browsing.

Custom Window
This window will form the base. It should be empty other than for a hidden list, a background, and a busy indicator. It can be any custom window ID. I've used 1190 here. The control list id must be 9999
xml:

<?xml version="1.0" encoding="UTF-8"?>
<window type="window" id="1190">
<defaultcontrol always="true">9999</defaultcontrol>
<controls>
<include>Global_Background</include>
<include>Topbar</include>
<control type="list" id="9999">
<top>-1000</top>
<left>-1000</left>
<width>1</width>
<height>1</height>
<itemlayout />
<focusedlayout />
<content target="videos">$INFO[Window(Home).Property(TMDbHelper.Path.Current)]</content>
</control>
<control type="group">
<visible>Container(9999).IsUpdating</visible>
<visible>!Window.IsVisible(DialogVideoInfo.xml)</visible>
<include>Dialog_Busy</include>
</control>
</controls>
</window>

DialogVideoInfo - List Onclick
Add the below onclick action to your info dialog widget lists. Do NOT close the dialog onclick. The script will handle closing the windows (you can set focus to another control, however). Make sure you remove any of the old onunload actions etc. -- This command will be the only one that you need!
xml:
<onclick>RunScript(plugin.video.themoviedb.helper,add_path=$INFO[ListItem.FolderPath],call_auto=1190)</onclick>

Using this call_auto method, the script will handle everything else.


Person Information
With the call_auto method, person information is shown directly in DialogVideoInfo.xml
Use the condition String.Contains(ListItem.FolderPath,type=person) to determine if the dialog is for a person. You can either modify specific pieces of information to suit, or include an entirely different layout - It's up to you.


There are still a couple of bugs here and there but overall it seems to be working. Occasionally there is a service instance left behind which results in odd behaviour (e.g. dialog will open and close twice) - I'm working on a way to clean-up these left overs once I figure out what the exact scenario is that causes it to occur.
(2020-01-03, 02:10)jurialmunkey Wrote: [ -> ]@nessus - Okay, I've managed to come up with what seems to be a far better way of handling the windows that simplifies the whole process quite a bit. Basically, when you run the script it will start a service monitor that manages the windows until you've finished browsing.

Custom Window
This window will form the base. It should be empty other than for a hidden list, a background, and a busy indicator. It can be any custom window ID. I've used 1190 here. The control list id must be 9999
xml:

<?xml version="1.0" encoding="UTF-8"?>
<window type="window" id="1190">
<defaultcontrol always="true">9999</defaultcontrol>
<controls>
<include>Global_Background</include>
<include>Topbar</include>
<control type="list" id="9999">
<top>-1000</top>
<left>-1000</left>
<width>1</width>
<height>1</height>
<itemlayout />
<focusedlayout />
<content target="videos">$INFO[Window(Home).Property(TMDbHelper.Path.Current)]</content>
</control>
<control type="group">
<visible>Container(9999).IsUpdating</visible>
<visible>!Window.IsVisible(DialogVideoInfo.xml)</visible>
<include>Dialog_Busy</include>
</control>
</controls>
</window>

DialogVideoInfo - List Onclick
Add the below onclick action to your info dialog widget lists. Do NOT close the dialog onclick. The script will handle closing the windows (you can set focus to another control, however). Make sure you remove any of the old onunload actions etc. -- This command will be the only one that you need!
xml:
<onclick>RunScript(plugin.video.themoviedb.helper,add_path=$INFO[ListItem.FolderPath],call_auto=1190)</onclick>

Using this call_auto method, the script will handle everything else.


Person Information
With the call_auto method, person information is shown directly in DialogVideoInfo.xml
Use the condition String.Contains(ListItem.FolderPath,type=person) to determine if the dialog is for a person. You can either modify specific pieces of information to suit, or include an entirely different layout - It's up to you.


There are still a couple of bugs here and there but overall it seems to be working. Occasionally there is a service instance left behind which results in odd behaviour (e.g. dialog will open and close twice) - I'm working on a way to clean-up these left overs once I figure out what the exact scenario is that causes it to occur.

@jurialmunkey, this is great, thanks! So if I understand correctly, now there is no need for the intermediate window that calls the window that used to have the person info, correct?

Now it is just the custom window and dialog video info.

Also, no need for the previous on back actions in the video info widget lists, correct?

Finally, I do not need to do any del_path or reset_path actions anywhere, correct?

When you have a chance, please confirm so I know how to modify my existing code. Thanks.

Regards,

Bart