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.
(2019-12-18, 13:17)nessus Wrote: [ -> ]1. There is no ListItem.Trailer info label in the themoviedb.helper info properties. Is this not available in the API.
The API does return a list of YouTube IDs for related videos like trailers etc. - I haven't got around to adding it yet as I'm not certain on what the proper way to add a YouTube ID as trailer path is. I'll look into it and get back to you.

(2019-12-18, 13:17)nessus Wrote: [ -> ]2. I cant fallback the main "Play" action for the item. In movies videos section i use PlayMedia($INFO[ListItem.FilenameAndPath]). In widgets using eg... plugin://plugin.video.themoviedb.helper?info=now_playing&type=movie this is not working since the ListItem.FilenameAndPath is empty for all items even for those are available in local library. I try to you use themoviedb.helper play fuction... plugin://plugin.video.themoviedb.helper?info=play&tmdb_id=$INFO[ListItem.Property(tmdb_id)]&type=movie but that it's not working too. I am sure i am doing something wrong here but i cant figure what?.
I don't lookup any local db information except for DBID - that's why filenameandpath is empty.

You need to use RunPlugin() because the player function is essentially a script and doesn't directly return playable file path.
RunPlugin(plugin://plugin.video.themoviedb.helper?info=play&tmdb_id=$INFO[ListItem.Property(tmdb_id)]&type=movie)

The player function then executes one of three commands depending on certain conditions: PlayMedia(filename_path) for local db items, RunPlugin(player_url) for user selected play_movie/episode players, and ActivateWindow(videos, player_url, return) for user selected search_movie/episode players.
(2019-12-16, 20:57)dm21912 Wrote: [ -> ]
(2019-12-16, 09:27)jurialmunkey Wrote: [ -> ]and I tested on both Windows and LibreELEC

yeh, this is android (firestick 4k). Was speaking to someone else on android in discord got same problem. 

weird.

its not that much of a hassle just to press info>run though

@dm21912 - Can you test latest git version? I'm hoping most recent update will fix this issue.
(2019-12-18, 23:39)jurialmunkey Wrote: [ -> ]You need to use RunPlugin() because the player function is essentially a script and doesn't directly return playable file path.
RunPlugin(plugin://plugin.video.themoviedb.helper?info=play&tmdb_id=$INFO[ListItem.Property(tmdb_id)]&type=movie)

The player function then executes one of three commands depending on certain conditions: PlayMedia(filename_path) for local db items, RunPlugin(player_url) for user selected play_movie/episode players, and ActivateWindow(videos, player_url, return) for user selected search_movie/episode players. 
Ok... this works fine for widgets items provided by themoviedb.helper plugin:// path lists, but when used in movies section or for widgets with local path (playlist or library node) it throws a script error.... https://paste.kodi.tv/saqehupufu.kodi

Can the script do this automatically?. I mean play items that are provided by script's plugin:// paths and they are in local library and open kodi's video info dialog for all the others ?. I think this will save as of lot of hassle.

By the way the lists provided from the themoviedb.helper they all have the "Next Page" as the last item. I didn't test what happens if the content limit is set in less than 20 but i have all my widgets without limit an i would like to keep it that way.

EDIT: Also i notice that some of the items are missing the IMDB number which is available from the API. Example... "The Lord of the Rings: The Return of the King" in Top Rated Movies... https://api.themoviedb.org/3/movie/122?a...uage=en-US

EDIT2: TMDB "Trending Movies" & "Trending TV Shows" are missing from provided lists... https://github.com/jurialmunkey/plugin.v...s-Trending.


Thanks
Nessus
(2019-12-20, 00:15)jurialmunkey Wrote: [ -> ]
(2019-12-16, 20:57)dm21912 Wrote: [ -> ]
(2019-12-16, 09:27)jurialmunkey Wrote: [ -> ]and I tested on both Windows and LibreELEC

yeh, this is android (firestick 4k). Was speaking to someone else on android in discord got same problem. 

weird.

its not that much of a hassle just to press info>run though 

@dm21912 - Can you test latest git version? I'm hoping most recent update will fix this issue. 

yup. working.
(2019-12-20, 01:30)nessus Wrote: [ -> ]Ok... this works fine for widgets items provided by themoviedb.helper plugin:// path lists, but when used in movies section or for widgets with local path (playlist or library node) it throws a script error.... https://paste.kodi.tv/saqehupufu.kodi
Can the script do this automatically?. I mean play items that are provided by script's plugin:// paths and they are in local library and open kodi's video info dialog for all the others ?. I think this will save as of lot of hassle.

That's because ListItem.Property(tmdb_id) is empty, so you're not looking anything up. You need to use a condition in the skin to check that it's not empty before calling the player function i.e.
Code:
<onclick condition="!String.IsEmpty(ListItem.Property(tmdb_id))">RunPlugin(plugin://plugin.video.themoviedb.helper?info=play&amp;tmdb_id=$INFO[ListItem.Property(tmdb_id)]&amp;type=movie)</onclick>
Up to you what you want to do if it is empty. You can send &amp;query= when it is empty:
Code:
<onclick condition="String.IsEmpty(ListItem.Property(tmdb_id))">RunPlugin(plugin://plugin.video.themoviedb.helper?info=play&amp;query=$INFO[ListItem.Title]&amp;type=movie)</onclick>
Or you can do some other action (like call info dialog). I'd like to minimise forcing actions from the script side of things as much as possible and leave it up to skinners to decide.

(2019-12-20, 01:30)nessus Wrote: [ -> ]By the way the lists provided from the themoviedb.helper they all have the "Next Page" as the last item. I didn't test what happens if the content limit is set in less than 20 but i have all my widgets without limit an i would like to keep it that way.
I'll add an optional param to disable/enable next page item in next update.
EDIT: Added. By default next page item will only show in the browser. If you want to show it in a widget/videoinfo then add &amp;nextpage=True

(2019-12-20, 01:30)nessus Wrote: [ -> ]Also i notice that some of the items are missing the IMDB number which is available from the API. Example... "The Lord of the Rings: The Return of the King" in Top Rated Movies... https://api.themoviedb.org/3/movie/122?a...uage=en-US
Top Rated Movies api call doesn't return external IDs:
https://developers.themoviedb.org/3/movi...ted-movies
https://api.themoviedb.org/3/movie/top_r...-US&page=1

Only API calls that support append_to_response will return external IDs. However, if you've previously viewed the detailed item, the external IDs (and other details) will be cached and returned. Looking up the details for every item in the list causes a significant performance hit because each details call has to be done individually.
(2019-12-20, 02:46)dm21912 Wrote: [ -> ]
(2019-12-20, 00:15)jurialmunkey Wrote: [ -> ]
(2019-12-16, 20:57)dm21912 Wrote: [ -> ]yeh, this is android (firestick 4k). Was speaking to someone else on android in discord got same problem. 

weird.

its not that much of a hassle just to press info>run though 

@dm21912 - Can you test latest git version? I'm hoping most recent update will fix this issue. 

yup. working.

Excellent! Thanks for testing and confirming Big Grin
(2019-12-20, 02:59)jurialmunkey Wrote: [ -> ]That's because ListItem.Property(tmdb_id) is empty, so you're not looking anything up. You need to use a condition in the skin to check that it's not empty before calling the player function i.e.
Code:
<onclick condition="!String.IsEmpty(ListItem.Property(tmdb_id))">RunPlugin(plugin://plugin.video.themoviedb.helper?info=play&amp;tmdb_id=$INFO[ListItem.Property(tmdb_id)]&amp;type=movie)</onclick>
Up to you what you want to do if it is empty. You can send &amp;query= when it is empty:
Code:
<onclick condition="String.IsEmpty(ListItem.Property(tmdb_id))">RunPlugin(plugin://plugin.video.themoviedb.helper?info=play&amp;query=$INFO[ListItem.Title]&amp;type=movie)</onclick>
Or you can do some other action (like call info dialog). I'd like to minimise forcing actions from the script side of things as much as possible and leave it up to skinners to decide. 
I disagree with that. IMHO scripts should make skinners life simpler. If it's possible with the help of a script to avoid any part/size of code then that's the way to go. Furthermore in this case the click--> play and click--> show info are the only options. Choosing click--> play as default action it makes perfectly sense. If user wants to open the video info dialog he can press "I" to show it. Or you can honor Kodi's setting "Default select action". The same logic like in video section.

Anyway, that's my opinion. It's your script and you can do whatever you want with it. If its necessary i will add the extra conditions for the play action.
 
(2019-12-20, 02:59)jurialmunkey Wrote: [ -> ]I'll add an optional param to disable/enable next page item in next update.
Why another param ?. it's a dead item anyway.
 
(2019-12-20, 02:59)jurialmunkey Wrote: [ -> ]Only API calls that support append_to_response will return external IDs. However, if you've previously viewed the detailed item, the external IDs (and other details) will be cached and returned. Looking up the details for every item in the list causes a significant performance hit because each details call has to be done individually.
I don't really understand since the IMDB number it's available in some items in the same list and in some it's not. Anyway, that's not important. I just noticed and thought i should mention.
 
(2019-12-20, 01:30)nessus Wrote: [ -> ]EDIT2: TMDB "Trending Movies" & "Trending TV Shows" are missing from provided lists... https://github.com/jurialmunkey/plugin.v...s-Trending.
What about this?


Now, i am little confused about how the themoviedb.helper handles the video info dialog when it's opened from widgets. I did a comparison of the "Popular Movies" list with extendedinfo.script and yours for an item that it's in local db and some stuff are missing or disabled.

 VideoInfo Dialog                                                    Extendedinfo            TheMoviedbHelper
========================================================================
Refresh button (id=6) ----------------------------------> DISABLED -----------> DISABLED
My rating button (id=7) -------------------------------> DISABLED -----------> ENABLED
Trailer button (condition ListItem.Trailer) ------> ENABLED ------------> DISABLED
Cast list (id=50 condition ListItem.Plot)----------> Showing -------------> Not Showing

Any idea why?

EDIT: Also all media flags are missing (eg ListItem.VideoCodec) while in Extendedinfo are showing fine. Overall with Extendedinfo list all the info in the dialog are exactly the same like in videos/movies section.


Thanks
Nessus
(2019-12-20, 12:02)nessus Wrote: [ -> ]I disagree with that. IMHO scripts should make skinners life simpler. If it's possible with the help of a script to avoid any part/size of code then that's the way to go. Furthermore in this case the click--> play and click--> show info are the only options. Choosing click--> play as default action it makes perfectly sense. If user wants to open the video info dialog he can press "I" to show it. Or you can honor Kodi's setting "Default select action". The same logic like in video section.

Sorry I misunderstood what you were suggesting. You can already change the default action to play with the &amp;widget=True param.
This param makes Movies|Episode = Play and TvShows = Browse Seasons.

I originally thought you were asking for the script to force "Action(Info)" if the tmdb_id param was empty when passed to info=play - which would cause all sorts of problems.
 
(2019-12-20, 12:02)nessus Wrote: [ -> ]Why another param ?. it's a dead item anyway.
It's not a dead item. It opens the next page of results. Anyway, you only add nextpage=True if you want to display the next page item.

The default is always False for all boolean params (i.e. for widget, fanarttv, nextpage). The plugin only ever checks if these are set to True - if the param is omitted or set to any other value, then it will be treated as False.
 
(2019-12-20, 12:02)nessus Wrote: [ -> ]I don't really understand since the IMDB number it's available in some items in the same list and in some it's not. Anyway, that's not important. I just noticed and thought i should mention.
The plugin caches the detailed item if it is accessed and uses that info if available. So if the service monitor has pulled info for that item previously, then you will get cached details in the list.
 
(2019-12-20, 01:30)nessus Wrote: [ -> ]"Trending Movies" & "Trending TV Shows" are missing from provided lists... https://github.com/jurialmunkey/plugin.v...s-Trending.
Added in latest.


(2019-12-20, 12:02)nessus Wrote: [ -> ]Now, i am little confused about how the themoviedb.helper handles the video info dialog when it's opened from widgets. I did a comparison of the "Popular Movies" list with extendedinfo.script and yours for an item that it's in local db and some stuff are missing or disabled.

Extended info merges local db info with online info. TMDbHelper is only online info, which is intentional for performance reasons and also to make it clear where the info comes from.

Cast list will be available if the detailed item is previously cached.

My Rating displays fine for me for items with dbid. If there is a mismatch between title/year on TMDb and in your local db, then a dbid won't be found. Extendedinfo has a fuzzier search because it ignores year whereas mine is a much stricter match (I avoid false positives at the cost of sometimes missing legitimate matches due to local differences in release year).
(2019-12-20, 22:52)jurialmunkey Wrote: [ -> ]Sorry I misunderstood what you were suggesting. You can already change the default action to play with the &amp;widget=True param.
This param makes Movies|Episode = Play and TvShows = Browse Seasons.
Sorry, i missed that param. Works fine... thanks. Even better if this can be extended to open the video info dialog for any non-local item.
 
(2019-12-20, 22:52)jurialmunkey Wrote: [ -> ]Extended info merges local db info with online info. TMDbHelper is only online info, which is intentional for performance reasons and also to make it clear where the info comes from.
I totally understand. You know better then me what is the best approach from python side. I just mention the extended info results just to point out what info were missing.
 
(2019-12-20, 22:52)jurialmunkey Wrote: [ -> ]The default is always False for all boolean params (i.e. for widget, fanarttv, nextpage). The plugin only ever checks if these are set to True - if the param is omitted or set to any other value, then it will be treated as False.
(2019-12-20, 22:52)jurialmunkey Wrote: [ -> ]Added in latest.
All working fine... thanks.
 
(2019-12-20, 22:52)jurialmunkey Wrote: [ -> ]Cast list will be available if the detailed item is previously cached.
I am getting the cast list through Kodi's standard cast list container (id=50). Not from themoviedb.helper plugin:// path. So cashed detailed items it's not helping. Any other way?. Also the trailer option (ListItem.Trailer) it's disabled but i remember you said you will have a look at that. Refresh & My rating buttons are not so important. I will hide them anyway when the videoinfo dialog it's not opening in videos sections.


Thanks
Nessus
(2019-12-21, 02:27)nessus Wrote: [ -> ]Sorry, i missed that param. Works fine... thanks. Even better if this can be extended to open the video info dialog for any non-local item.
Could be problematic for widgets inside info dialog because Action(Info) closes the info dialog if it is already open.
 
(2019-12-21, 02:27)nessus Wrote: [ -> ]I am getting the cast list through Kodi's standard cast list container (id=50). Not from themoviedb.helper plugin:// path. So cashed detailed items it's not helping. Any other way?
Ah, you're right - the cast list isn't populating from cache. Mistake on my end - should be fixed now.

(2019-12-21, 02:27)nessus Wrote: [ -> ]Also the trailer option (ListItem.Trailer) it's disabled but i remember you said you will have a look at that. Refresh & My rating buttons are not so important. I will hide them anyway when the videoinfo dialog it's not opening in videos sections.

Added. Should now show trailers for detailed item or in lists if detailed item is cached. Can also get with service monitor Window(Home).Property(TMDbHelper.ListItem.Trailer)

If the item was already cached, you'll need to refresh the cache for that item.
You can refresh the cache of an item by locating it in the TMDbHelper add-on browser and entering the details page. Refresh is at the bottom of the list.

You can manually refresh the cache of an item with:
Code:
RunPlugin(plugin://plugin.video.themoviedb.helper/?info=details&amp;refresh=True&amp;tmdb_id=$INFO[ListItem.Property(tmdb_id)]&amp;type=movie)

The nuclear option is to delete simplecache.db from userdata/addon_data/simplecache but I don't recommend that.

Once I've got all the new features to a stable state and ready for an official repo update, I'll set the plugin to refresh all cached entries to ensure that everyone gets the new features.
Yep... after an item it's cached the info are available... thanks Big Grin
The only info that are missing now are the media flags, eg ListItem.VideoResolution for the local items.

Curiosity questions:
1. After an item is cached, the Window(Home).Property(TMDbHelper.ListItem.Trailer) it's still empty while the ListItem.Trailer it's filled for both local or non-local items. Is this normal?
2. After an item is cached, how come Kodi's cast list container (id=50) it's filled for non-local items?. I thought this list container id was only for local items.
3. How come only ListItem.Plot it's immediately available for all items locals or non-locals, cached or not?

All these are questions about items in widgets lists.

Thanks
Nessus
(2019-12-21, 13:27)nessus Wrote: [ -> ]1. After an item is cached, the Window(Home).Property(TMDbHelper.ListItem.Trailer) it's still empty while the ListItem.Trailer it's filled for both local or non-local items. Is this normal?
2. After an item is cached, how come Kodi's cast list container (id=50) it's filled for non-local items?. I thought this list container id was only for local items.
3. How come only ListItem.Plot it's immediately available for all items locals or non-locals, cached or not?
1. My mistake. Should be fixed now.
2. Plugins can set cast list for video items using the setCast method of the ListItem class: https://codedocs.xyz/AlwinEsch/kodi/grou...fb7ccd3619
3. Plot overview is returned by most of the TMDb API calls, so it is usually available. You can get a good idea of the default non-detailed item fields returned by looking at the schema for the Top Rated Movies call - https://developers.themoviedb.org/3/movi...ted-movies

Basically, these fields are usually available in every list: poster, tmdb id, plot, premiered, year, genres, title, fanart, rating, votes.
@jurialmunkey , I am testing the latest version from GitHub running in the latest Matrix nightly.  I am getting the following error whenbrowsing the plugin and trying to get details for a cast member:

xml:

2019-12-21 10:38:14.107 T:8684   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <class 'TypeError'>
                                            Error Contents: '<' not supported between instances of 'NoneType' and 'NoneType'
                                            Traceback (most recent call last):
                                              File "C:\Users\bsori\AppData\Roaming\Kodi\addons\plugin.video.themoviedb.helper\plugin.py", line 11, in <module>
                                                Container().router()
                                              File "C:\Users\bsori\AppData\Roaming\Kodi\addons\plugin.video.themoviedb.helper\resources\lib\container.py", line 522, in router
                                                self.list_details()
                                              File "C:\Users\bsori\AppData\Roaming\Kodi\addons\plugin.video.themoviedb.helper\resources\lib\container.py", line 411, in list_details
                                                details = self.tmdb.get_detailed_item(*d_args)
                                              File "C:\Users\bsori\AppData\Roaming\Kodi\addons\plugin.video.themoviedb.helper\resources\lib\tmdb.py", line 316, in get_detailed_item
                                                itemdict = self.set_cache(self.get_niceitem(request), cache_name, self.cache_long) if request else {}
                                              File "C:\Users\bsori\AppData\Roaming\Kodi\addons\plugin.video.themoviedb.helper\resources\lib\tmdb.py", line 252, in get_niceitem
                                                cast = self.get_cast(item)
                                              File "C:\Users\bsori\AppData\Roaming\Kodi\addons\plugin.video.themoviedb.helper\resources\lib\tmdb.py", line 197, in get_cast
                                                for i in sorted(cast_list, key=lambda k: k.get('order')):
                                            TypeError: '<' not supported between instances of 'NoneType' and 'NoneType'
                                            -->End of Python script error report<--

Any ideas? Thanks for your help.

Regards,

Bart
(2019-12-21, 14:34)jurialmunkey Wrote: [ -> ]1. My mistake. Should be fixed now.
2. Plugins can set cast list for video items using the setCast method of the ListItem class: https://codedocs.xyz/AlwinEsch/kodi/grou...fb7ccd3619
3. Plot overview is returned by most of the TMDb API calls, so it is usually available. You can get a good idea of the default non-detailed item fields returned by looking at the schema for the Top Rated Movies call - https://developers.themoviedb.org/3/movi...ted-movies

Basically, these fields are usually available in every list: poster, tmdb id, plot, premiered, year, genres, title, fanart, rating, votes.
Great... thanks for the info.
 
(2019-12-21, 13:27)nessus Wrote: [ -> ]The only info that are missing now are the media flags, eg ListItem.VideoResolution for the local items.
What about this one?
(2019-12-21, 06:32)jurialmunkey Wrote: [ -> ]
(2019-12-21, 02:27)nessus Wrote: [ -> ]Sorry, i missed that param. Works fine... thanks. Even better if this can be extended to open the video info dialog for any non-local item.
Could be problematic for widgets inside info dialog because Action(Info) closes the info dialog if it is already open.
That's fine. I am already closing the info dialog when an item is playable. IMHO this is proper behavior and makes it clear to the user that it opens the info dialog for a different item. If you don't want to add this then we will need a click action to run the script and show the video info for that clicked item.