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.
(2020-01-06, 15:23)jurialmunkey Wrote: [ -> ]If you're setting focus to another control first, I honestly don't understand how you have enough time to click twice (let alone three times!). I tried to double click as fast as I possible could and my second click always hits the control I sent focus to onclick rather than my list.

If you click multiple times on any onclick action, the command is going to activate multiple times no matter what it is -- there's not much I can do about that other than say don't do that...
I am not setting the focus in any other control. I am just running the call_auto= method with the add_query= from the <onright /> tag of Kodi's standard cast list container. And yes, there is enough time to press right 2-3 even 4 times since the script delays about 4-5 seconds to start by closing the video info dialog.
Anyway, if it's not something that can be handle/fixed by the script then no problem. Not a biggie. I was just reporting it as a not proper behavior.
 
(2020-01-06, 15:23)jurialmunkey Wrote: [ -> ]Try latest. You should now get some window properties
EDIT: I've now moved these to infolabels attached to the detailed item instead:
xml:

$INFO[ListItem.Property(NumItems.DBID.Movies)]
$INFO[ListItem.Property(NumItems.DBID.TvShows)]
$INFO[ListItem.Property(NumItems.DBID.Episodes)]
$INFO[ListItem.Property(NumItems.DBID.Total)]
$INFO[ListItem.Property(NumItems.TMDB.Cast)]
$INFO[ListItem.Property(NumItems.TMDB.Crew)]
$INFO[ListItem.Property(NumItems.TMDB.Total)]
$INFO[ListItem.Property(NumItems.TMDB.Movies.Cast)]
$INFO[ListItem.Property(NumItems.TMDB.Movies.Crew)]
$INFO[ListItem.Property(NumItems.TMDB.Movies.Total)]
$INFO[ListItem.Property(NumItems.TMDB.TvShows.Cast)]
$INFO[ListItem.Property(NumItems.TMDB.TvShows.Crew)]
$INFO[ListItem.Property(NumItems.TMDB.TvShows.Total)]

DBID properties are the number of items returned by JSON-RPC from kodi library where person name matches either actor, writer or director. "NumItems.DBID" is the combined total. Note that Episodes seem to only be counted if the person is a guest star, not a regular cast member. For instance, when I looked up Alec Baldwin, I got hardly any episodes despite having the entire 30 Rock box set scanned to my library. Whereas I got a lot of episodes for Elizabeth Banks as she was a guest star for a couple of seasons.

The results from TMDb are the Total Number of the Item returned -- so this number will also include items in your library. This is the best I can do without iterating through every item and checking it individually.

I haven't tested this on a lower powered system yet, so please let me know how it fairs performance wise. Seems fine on my laptop but that's relatively powerful compared to most htpc boxes.
Thanks a lot for this. It's working fine. The info is available the same as all the others. No performance issues.

Only one question about this...
Shouldn't the number of $INFO[ListItem.Property(NumItems.TMDB.Movies.Total)] be the same as the total number of the two plugin:// paths from info=stars_in_movies  & info=crew_in_movies?... or it's a different thing?. The same question of course applies for tv shows.


Thanks
Nessus
(2020-01-07, 13:21)nessus Wrote: [ -> ]I am not setting the focus in any other control. I am just running the call_auto= method with the add_query= from the <onright /> tag of Kodi's standard cast list container. And yes, there is enough time to press right 2-3 even 4 times since the script delays about 4-5 seconds to start by closing the video info dialog.
Yeah, it's difficult to manage as there isn't really anyway to talk *between* separate script instances other than setting a window property, which can sometimes lag and so doesn't help for multiple runscripts in quick succession.

With that said, can you test latest version? I've added some additional checks which, from my testing, seems to alleviate the issue -- With the new checks, I actually wasn't able to recreate the issue anymore (but theoretically it is still possible and my laptop might just be beating me for processing speed).
 
(2020-01-07, 13:21)nessus Wrote: [ -> ]Only one question about this...
Shouldn't the number of $INFO[ListItem.Property(NumItems.TMDB.Movies.Total)] be the same as the total number of the two plugin:// paths from info=stars_in_movies  & info=crew_in_movies?... or it's a different thing?. The same question of course applies for tv shows.

No, because with the plugin:// paths numitems.tmdb = container.numitems - numitems.dbid
It's done this way since you can already get the total for a plugin:// path by using $INFO[Container(ID).NumItems]

I don't use this method for detailed item because it requires individually checking if each item is in the library (which adds overhead). For plugin paths, I'm already checking DBID anyway, so no additional overhead there.
Aha... you nailed!!. Even with 4-5 clicks the actor info closes fine and only once.

I think i am done with this. Everything work flawlessly and i am very happy with the result.
Great work man. Thank you very much for all your work with this great addon and for your patience so far.

Cheers
Nessus
(2020-01-08, 01:28)nessus Wrote: [ -> ]Aha... you nailed!!. Even with 4-5 clicks the actor info closes fine and only once.

Excellent! The additional check seems to have worked far better than I expected -- particularly as I initially thought it wouldn't help at all!

(2020-01-08, 01:28)nessus Wrote: [ -> ]I think i am done with this. Everything work flawlessly and i am very happy with the result.
Great work man. Thank you very much for all your work with this great addon and for your patience so far.

No worries at all! Glad to have helped and a lot of great improvements came out of the process too. Thanks for taking the time to test things out.

I should have these latest changes up on the official repo sometime in the coming week.
@jurialmunkey , I am in the process of changing my code to use the call_auto and close_dialog calls.  In my video info dialog, I use a custom Play button.  If I press I on a movie, and just want to play it (I have not clicked on any widget lists or anything yet), do I need to use the close_dialog call before sending a click to button 8? Or should it be after, or not at all? I am finding that the dialog is closed, but the movie does not start playing full screen, but in the background.  Please confirm what the sequence of events should be, or if I need to ensure that tmdbhelper.path.current is not empty before doing any close_dialog call.  Thanks.

Also, for a few of the detail fields in video info (Director, Writer, Genre, Country, Studio, etc.) I use script.embuary.helper to show the user a select dialog and allow them to choose to search online in tmdb (via a tmdb helper call) or locally in the db, and sometimes a second select dialog to separate multiple items in the field so the user can select one to do the search with.  First, calling embuary helper should not interfere with your plugin's new window management, correct? And second, in all of the actions that I have for these select dialogs where I close the video info dialog, do I need to replace them with a tmdb helper close_dialog call? Are there any conditions I would need to check before doing that?

Thanks again for all of your help.

Regards,

Bart
(2020-01-08, 02:05)bsoriano Wrote: [ -> ]@jurialmunkey , I am in the process of changing my code to use the call_auto and close_dialog calls.  In my video info dialog, I use a custom Play button.  If I press I on a movie, and just want to play it (I have not clicked on any widget lists or anything yet), do I need to use the close_dialog call before sending a click to button 8? Or should it be after, or not at all? I am finding that the dialog is closed, but the movie does not start playing full screen, but in the background.  Please confirm what the sequence of events should be, or if I need to ensure that tmdbhelper.path.current is not empty before doing any close_dialog call.  Thanks.
Generally, you should run close_dialog anywhere that you would normally use Dialog.Close() to close dialogvideoinfo. It should be placed before any other onclick actions. However, for SendClick(8) (and probably trailer button too) we will need a special action as the script closing the dialog at the same time interferes with the toggle fullscreen action.

On the latest, I've added an additional "sendclick=" param for the close_dialog method which will let the script handle when to call SendClick(ID) (make sure you remove <onclick>SendClick(8)</onclick> because otherwise it will get called twice!)
Code:
<onclick>RunScript(plugin.video.themoviedb.helper,close_dialog=1190,sendclick=8)</onclick>

This works for me. Please test and confirm.

(2020-01-08, 02:05)bsoriano Wrote: [ -> ]Also, for a few of the detail fields in video info (Director, Writer, Genre, Country, Studio, etc.) I use script.embuary.helper to show the user a select dialog and allow them to choose to search online in tmdb (via a tmdb helper call) or locally in the db, and sometimes a second select dialog to separate multiple items in the field so the user can select one to do the search with.  First, calling embuary helper should not interfere with your plugin's new window management, correct? And second, in all of the actions that I have for these select dialogs where I close the video info dialog, do I need to replace them with a tmdb helper close_dialog call? Are there any conditions I would need to check before doing that?

Yep, just replace Dialog.Close with the close_dialog call. It should work fine -- just make sure you are only calling close_dialog when you are going to the search window and NOT themoviedb info window (i.e. don't do close_dialog when doing add_path/call_auto).

Close_dialog is basically just a way to nuke the tmdbhelper process and reset all its Path properties.

In order, close_dialog does the following:
1. Clears all the TMDbHelper.Path properties.
2. Closes dialogvideoinfo
3. Closes the Window ID as specified in close_dialog=
4. SendClick(ID) as specified in sendclick=
(2020-01-08, 05:27)jurialmunkey Wrote: [ -> ]<onclick>RunScript(plugin.video.themoviedb.helper,close_dialog=1190,sendclick=8)</onclick>

@jurialmunkey , this is not working for me.  Latest version of the plugin from Git, Kodi 18.5 under Windows 10.  

This is what I have for the custom "Play/Browse/Close" button right now (I commented out every action that is not for a local movie):

xml:

<control type="button" id="8000" description="Play/browse">
                <height>90</height>
                <width min="210">auto</width>
                <align>center</align>
                <font>Details</font>
                <label>$VAR[VideoInfoButton8]</label>
<!--                <onclick condition="String.IsEmpty(ListItem.DBID) + !String.IsEmpty(ListItem.Property(tmdb_id))">RunScript(plugin.video.themoviedb.helper,close_dialog=1134)</onclick>
                <onclick condition="String.IsEmpty(ListItem.DBID) + String.IsEmpty(ListItem.Property(tmdb_id))">RunScript(plugin.video.themoviedb.helper,close_dialog=1134)</onclick>
                <onclick condition="!String.IsEmpty(ListItem.DBID) + !String.IsEmpty(ListItem.Property(tmdb_id))">RunScript(plugin.video.themoviedb.helper,close_dialog=1134)</onclick> -->
                <onclick condition="String.IsEqual(ListItem.DBType,movie) + !String.IsEmpty(ListItem.DBID)">RunScript(plugin.video.themoviedb.helper,close_dialog=1134,sendclick=8)</onclick>
<!--                <onclick condition="String.IsEqual(ListItem.DBType,movie) + !String.IsEmpty(ListItem.DBID)">SendClick(8)</onclick> -->
<!--                <onclick condition="String.IsEqual(ListItem.DBType,episode) + !String.IsEmpty(ListItem.DBID)">RunScript(plugin.video.themoviedb.helper,close_dialog=1134,sendclick=8)</onclick> -->
<!--                <onclick condition="String.IsEqual(ListItem.DBType,episode) + !String.IsEmpty(ListItem.DBID)">SendClick(8)</onclick> -->
<!--                <onclick condition="String.IsEqual(ListItem.DBType,tvshow) + !String.IsEmpty(ListItem.DBID)">RunScript(script.embuary.helper,action=goto,path='"videodb://tvshows/titles/$INFO[ListItem.DBID]/"',target=videos)</onclick> -->
            </control>

And this is the content of Window 1134:

xml:

<?xml version="1.0" encoding="UTF-8"?>
<window type="window" id="1134">
    <defaultcontrol always="true">9999</defaultcontrol>
    <controls>
        <control type="image">
            <width>1920</width>
            <height>1080</height>
            <texture>img/BlackDot.png</texture>
            <aspectratio>scale</aspectratio>
        </control>
        <control type="image">
            <width>1920</width>
            <height>1080</height>
            <texture background="true">special://skin/backgrounds/default.jpg</texture>
            <aspectratio>scale</aspectratio>
        </control>
        <include content="BackgroundOverlay">
            <param name="parentid" value="9999"/>
        </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 + !Window.IsVisible(DialogVideoInfo.xml)</visible>
            <include>InfoLoading</include>
        </control>
    </controls>
</window>

The info dialog closes, but the movie does not play.

What am I doing incorrectly? Thanks for your help.

Regards,

Bart
@bsoriano - Hmm, yes you're right, sometimes it doesn't work - I've got an alternate approach that seems to work though.

On latest version I've added a playmedia param for close_dialog:
Code:
RunScript(plugin.video.themoviedb.helper,close_dialog=1134,playmedia=$INFO[ListItem.FileNameAndFolder])

Can you test and confirm?
(2020-01-09, 00:10)jurialmunkey Wrote: [ -> ]@bsoriano - Hmm, yes you're right, sometimes it doesn't work - I've got an alternate approach that seems to work though.

On latest version I've added a playmedia param for close_dialog:
Code:
RunScript(plugin.video.themoviedb.helper,close_dialog=1134,playmedia=$INFO[ListItem.FileNameAndFolder])

Can you test and confirm?
@jurialmunkey , thanks! This works for the custom Play/Browse/Close button (with ListItem.FileNameAndPath). 

I will test with all of the other instances where I am closing the dialog to see how it goes.

Regards,

Bart
@bsoriano - No worries! Glad it works.

If you hit any other roadblocks, let me know and I'll see if I can find a solution.
@bsoriano 
The following code it works fine for me for a custom Play button in all cases....

"Play" button in video info dialog...
xml:
<control type="button" id="88">
    <description>Play/Browse/Close</description>
    <label>$VAR[PlayBrowseButtonLabel]</label>
    <onclick>Dialog.Close(MovieInformation)</onclick>
    <onclick>$VAR[CustomClickForMoreLists]</onclick>
    <include>TopMenuButton</include>
</control>

... and the variables....
xml:
<variable name="CustomClickForMoreLists">
    <value condition="String.IsEqual(ListItem.DBType,movie) + !String.IsEmpty(ListItem.FilenameAndPath) + !String.StartsWith(ListItem.FilenameAndPath,plugin://)">AlarmClock(PlayMovie,PlayMedia($INFO[ListItem.FilenameAndPath]),00:01,silent)</value>
    <value condition="String.IsEqual(ListItem.DBType,movie) + !String.IsEmpty(ListItem.DBID)">RunPlugin(plugin://plugin.video.themoviedb.helper/?info=play&amp;tmdb_id=$INFO[ListItem.Property(tmdb_id)]&amp;type=movie)</value>
    <value condition="String.IsEqual(ListItem.DBType,episode) + !String.IsEmpty(ListItem.DBID)">RunPlugin(plugin://plugin.video.themoviedb.helper/?info=play&amp;tmdb_id=$INFO[ListItem.Property(tmdb_id)]&amp;season=1&amp;episode=1&amp;type=episode)</value>
    <value condition="[String.IsEqual(ListItem.DBType,tvshow) | String.IsEqual(ListItem.DBType,season)] + !String.IsEmpty(ListItem.DBID)">ActivateWindow(videos,videodb://tvshows/titles/$INFO[ListItem.DBID]/,return)</value>
</variable>
xml:
<variable name="PlayBrowseButtonLabel">
    <value condition="[String.IsEqual(ListItem.DBType,tvshow) | String.IsEqual(ListItem.DBType,season)] + !String.StartsWith(ListItem.FilenameAndPath,plugin://)">$LOCALIZE[1024]</value>
    <value condition="!String.StartsWith(ListItem.FilenameAndPath,plugin://)">$LOCALIZE[208]</value>
    <value>$LOCALIZE[15067]</value>
</variable>

The <variable name="CustomClickForMoreLists"> works fine too for the widgets lists inside the video info dialog.

Cheers
Nessus
(2020-01-09, 12:45)nessus Wrote: [ -> ]@bsoriano 
The following code it works fine for me for a custom Play button in all cases....

"Play" button in video info dialog...
xml:
<control type="button" id="88">
    <description>Play/Browse/Close</description>
    <label>$VAR[PlayBrowseButtonLabel]</label>
    <onclick>Dialog.Close(MovieInformation)</onclick>
    <onclick>$VAR[CustomClickForMoreLists]</onclick>
    <include>TopMenuButton</include>
</control>

... and the variables....
xml:
<variable name="CustomClickForMoreLists">
    <value condition="String.IsEqual(ListItem.DBType,movie) + !String.IsEmpty(ListItem.FilenameAndPath) + !String.StartsWith(ListItem.FilenameAndPath,plugin://)">AlarmClock(PlayMovie,PlayMedia($INFO[ListItem.FilenameAndPath]),00:01,silent)</value>
    <value condition="String.IsEqual(ListItem.DBType,movie) + !String.IsEmpty(ListItem.DBID)">RunPlugin(plugin://plugin.video.themoviedb.helper/?info=play&amp;tmdb_id=$INFO[ListItem.Property(tmdb_id)]&amp;type=movie)</value>
    <value condition="String.IsEqual(ListItem.DBType,episode) + !String.IsEmpty(ListItem.DBID)">RunPlugin(plugin://plugin.video.themoviedb.helper/?info=play&amp;tmdb_id=$INFO[ListItem.Property(tmdb_id)]&amp;season=1&amp;episode=1&amp;type=episode)</value>
    <value condition="[String.IsEqual(ListItem.DBType,tvshow) | String.IsEqual(ListItem.DBType,season)] + !String.IsEmpty(ListItem.DBID)">ActivateWindow(videos,videodb://tvshows/titles/$INFO[ListItem.DBID]/,return)</value>
</variable>
xml:
<variable name="PlayBrowseButtonLabel">
    <value condition="[String.IsEqual(ListItem.DBType,tvshow) | String.IsEqual(ListItem.DBType,season)] + !String.StartsWith(ListItem.FilenameAndPath,plugin://)">$LOCALIZE[1024]</value>
    <value condition="!String.StartsWith(ListItem.FilenameAndPath,plugin://)">$LOCALIZE[208]</value>
    <value>$LOCALIZE[15067]</value>
</variable>

The <variable name="CustomClickForMoreLists"> works fine too for the widgets lists inside the video info dialog.

Cheers
Nessus

@nessus, thank you! Smile

Regards,

Bart
@jurialmunkey 
I am using the bellow plugin path as widget from skin shortcuts.... plugin://plugin.video.themoviedb.helper?info=popular&amp;type=person&amp;widget=True and i would like <oninfo/> to show the info for each person. I've try the call_auto method with add_path= param (since this is a TMDB Helper list) but the Window(Home).Property(TMDbHelper.Path.Current)  its empty. Also tried the add_query= param but also not working.

Is there a way to show the actor info dialog from outside the video info dialog?. This would be useful so it can be called also from actors section in videos windows.

Thanks
Nessus
(2020-01-11, 12:16)nessus Wrote: [ -> ]@jurialmunkey 
I am using the bellow plugin path as widget from skin shortcuts.... plugin://plugin.video.themoviedb.helper?info=popular&amp;type=person&amp;widget=True and i would like <oninfo/> to show the info for each person. I've try the call_auto method with add_path= param (since this is a TMDB Helper list) but the Window(Home).Property(TMDbHelper.Path.Current)  its empty. Also tried the add_query= param but also not working.

Is there a way to show the actor info dialog from outside the video info dialog?. This would be useful so it can be called also from actors section in videos windows.

Thanks
Nessus

Kodi doesn't allow you to override <oninfo> for containers filled with dynamic content paths. It's not just my script -- you won't be able to do any <oninfo> command from a widget (e.g. try <oninfo>ActivateWindow(settings)</oninfo> and it won't work).

You can only control the <onclick> action for widgets. Both add_query= and add_path= work for me as onclick
Code:
<onclick>RunScript(plugin.video.themoviedb.helper,add_query=$INFO[ListItem.Label],type=person,call_auto=1190)</onclick>
Code:
<onclick>RunScript(plugin.video.themoviedb.helper,add_path=$INFO[ListItem.FolderPath],call_auto=1190)</onclick>
@nessus - You should still be able to open the info dialog for the person, you just won't have detailed info. HOWEVER, note that the service monitor also works for people, so you can get the info using window properties such as Window(Home).Property(TMDBHelper.ListItem.Biography). Use a variable to check if the listitem infolabel is empty and fallback to the service monitor info (EDIT: I just realised there is a bug in service monitor where it is checking person info anymore... fixing now EDIT2: Okay should be fixed now).