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.
Hi,

Just wondering if it's possible to retrieve all items in a list instead of only 20 if I don't want to use pages?

Thanks.
as far as i understand jurial does this limit on purpose so his api keys dont get hammered

he and i had this conversation concerning trakt a couple months ago
Fair enough.
(2023-06-18, 19:12)Hitcher Wrote: [ -> ]Just wondering if it's possible to retrieve all items in a list instead of only 20 if I don't want to use pages?

It depends on the list but yeah most are limited to 20 by design. Partially to avoid hammering the APIs and partially because the TMDb api forces pagination for many lists.

The stars_in/crews_in lists to get a person's movies/shows support the "&limit=XX" param which will allow you to get more than 20 items. Also there is a user setting in the plugin settings to expand some Trakt sync lists (Collection, Watched History etc.) from 20 items to 84. Other than that, the rest are limited to 20.
(2023-06-17, 23:19)Sea Wolfe Wrote: [ -> ]
(2023-06-15, 01:41)jurialmunkey Wrote: [ -> ]Clearing kodi cache will do nothing - it's not cached to disk. I just meant that kodi caches the last used directory in memory so sometimes going back and then reopening the same folder won't refresh the listing.

I don't cache anything for the list of lists and as you note, newly liked lists are showing immediately which demonstrates that I don't cache it (otherwise it wouldn't update at all)

However Trakt api server does cache things. There is nothing I can do about that. That's just how their server works - it caches some regularly requested user endpoints that aren't critical so it can serve the request faster.

Hey Jurial, thanks for replying and explaining everything. I know this must be the least favorite part of these projects (having to explain things to end users! Smile

It's been about a week, and the changes I made aren't updated.  I wonder how long Trakt caches this stuff to Cloudflare?  Reading the links you gave, it looks like it's by design to reduce the API hits.  
And they (Trakt) don't seem to have the ability to do anything about this cache, if I am understanding the responses on those links, correctly?

You're understanding correctly but that's definitely far too long for it to be cached. It really should only be about a day tops.

Something funky is definitely going on with their API results for liked lists. I tested liking a few on the website and they will show up immediately in the API results, but unliked lists will persist in the results returned.
@jurialmunkey

We have one user MQ9 reporting this issue, is possible to fix it, please?

2023-06-20 23:10:26.336 T:5201 error <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<-- - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS! Error Type: <class 'KeyError'> Error Contents: 'pop from an empty set' Traceback (most recent call last): File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.themoviedb.helper/resources/script.py", line 7, in <module> Script(*sys.argv[1:]).router() File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.themoviedb.helper/resources/tmdbhelper/lib/script/router.py", line 122, in router route_taken = set.intersection(routes_available, params_given).pop() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ KeyError: 'pop from an empty set' -->End of Python script error report<--

here post user with the log

https://forum.kodi.tv/showthread.php?tid...id31565960
(2023-06-20, 15:20)jurialmunkey Wrote: [ -> ]
(2023-06-18, 19:12)Hitcher Wrote: [ -> ]Just wondering if it's possible to retrieve all items in a list instead of only 20 if I don't want to use pages?

It depends on the list but yeah most are limited to 20 by design. Partially to avoid hammering the APIs and partially because the TMDb api forces pagination for many lists.

The stars_in/crews_in lists to get a person's movies/shows support the "&amp;limit=XX" param which will allow you to get more than 20 items. Also there is a user setting in the plugin settings to expand some Trakt sync lists (Collection, Watched History etc.) from 20 items to 84. Other than that, the rest are limited to 20.
Thanks for the clarification.
Update/followup to my previous post:

After a full week (let’s say 8 days to be safe), Liked Lists through TMDBhelper are in sync with Trakt website. So access through the API seems to have about an 8 day cache through Cloudflare (meaning changes won’t update in real time (at least for “Liked Lists” that have been unliked).
(2023-06-20, 16:54)Wanilton Wrote: [ -> ]@jurialmunkey

We have one user MQ9 reporting this issue, is possible to fix it, please?

2023-06-20 23:10:26.336 T:5201 error <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<-- - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS! Error Type: <class 'KeyError'> Error Contents: 'pop from an empty set' Traceback (most recent call last): File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.themoviedb.helper/resources/script.py", line 7, in <module> Script(*sys.argv[1:]).router() File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.themoviedb.helper/resources/tmdbhelper/lib/script/router.py", line 122, in router route_taken = set.intersection(routes_available, params_given).pop() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ KeyError: 'pop from an empty set' -->End of Python script error report<--

here post user with the log

https://forum.kodi.tv/showthread.php?tid...id31565960

That log file is full of banned add-ons...

Anyway, that error means the skin (or user) attempted to do a RunScript(plugin.video.themoviedb.helper) using a command that doesn't exist in TMDbHelper.

From a quick search of the skin code, this is the likely culprit:
RunScript(plugin.video.themoviedb.helper,backend=True)

Don't know what you're trying to do with that command but there's no such script method as "backend=True" in TMDbHelper.
Thanks, I check the line mentioned is only available in the MQ9 mod version by @latts9923.
Reading through this API and cache issues, an idea arises:
would it be possible to have an option per tmdbhelper widget to cache the widget locally and refresh silently each week/specified days in the background.
So everytime you bootup your system, or go back and forth your Kodi (especially on low ram devices like shield tv, that will gladly kill Kodi as soon as you multitask), you get instant loadup of your home screen, without spamming the servers.
There's tons of trakt lists that are not updated too often, no need to query and refresh them every single time.

Is something like this even possible?
(2023-06-22, 12:56)Wanilton Wrote: [ -> ]Thanks, I check the line mentioned is only available in the MQ9 mod version by @latts9923.

It's in the official repo version of the skin in MyVideoNav.xml

xml:

<onload condition="!System.HasAddon(script.tv.show.next.aired) + [Container.Content(tvshows) | Container.Content(seasons) | Container.Content(episodes)]">InstallAddon(plugin.video.themoviedb.helper)</onload>
<onload condition="System.HasAddon(script.tv.show.next.aired) + [Container.Content(tvshows) | Container.Content(seasons) | Container.Content(episodes)]">RunScript(plugin.video.themoviedb.helper,backend=True)</onload>

Looks like you meant to use script.tv.show.next.aired not tmdbhelper
(2023-06-22, 19:18)janweinreich Wrote: [ -> ]Reading through this API and cache issues, an idea arises:
would it be possible to have an option per tmdbhelper widget to cache the widget locally and refresh silently each week/specified days in the background.
So everytime you bootup your system, or go back and forth your Kodi (especially on low ram devices like shield tv, that will gladly kill Kodi as soon as you multitask), you get instant loadup of your home screen, without spamming the servers.
There's tons of trakt lists that are not updated too often, no need to query and refresh them every single time.

Is something like this even possible?

TMDbHelper already has extensive caching of items and lists. Most basic lists are cached for at least 24 hours. Trakt sync lists check Trakt last activities cache before updating. Item details are cached for at least a week.

Startup delays are due to Kodi initialising it's services and the python subinterpreters for plugins. It's impossible for a plugin to beat the startup delay because it has to wait for Kodi to initialise first.
Hi @jurialmunkey
I got here from some advice of @Hitcher.
Quote:You're probably better of using an addon to do this like plugin.video.themoviedb.helper.
https://forum.kodi.tv/showthread.php?tid...pid3154503,  on this link i expose what i do for have some custom videodialoginfo window. Is This way is correct?, i ask for better understanding of how kodi work. And if i use ur addon i can do exactly the same?. Thanks
@jurialmonkey Does ListItem.Property(Known_For) work for you because I never get any results?

Thanks.