Solved 'Real' runtime of episode
#1
My addon uses JSON-RPC "VideoLibrary.GetEpisodes" method to get episodes for a TV show and then creates a playlist within the given maximum playing time limit. To track the playing time I use the "runtime" field returned by "VideoLibrary.GetEpisodes".

Recently I found that the 'runtime' field has the same value for all the TV show's seasons. OK, it works the same as thetvdb.com does. But the point is that some TV shows have 'Special' episodes, and its lenght is not the same as the standard episode lenght.

So the question is how can I retrieve the 'real' runtime of the episode in my addon?
Reply
#2
I think that there is no other way than to read duration from videofiles. It can be done with ffmpeg but, if I'm not mistaken, Kodi's buit-in ffmpeg is not accessible from Python. Fortunately, there is Hachoir library which is pure-Python (means platform-independent) that can work with a number of binary file formats, including some media formats. It works with great majority of avi/mp4/mkv files and does not work with ts/m2ts. You can see an example of its usage in my YATP plugin.

The only problem I see that scanning many files, especially with Python, will take quite a while. I'd recommend to use some form of caching for known files, for example with a pickled dictionary or a Python shelve that stores "path: duration" pairs.
Reply
#3
Thank you for the answer, I will try it))
Reply
#4
if i remember correctly, the 'runtime' field contains the scraped (from thetvdb.com etc..) length of a video.

you can also query the 'streamdetails' field, which will return (amongst others) the 'duration' value,
which is the actually length of the video.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#5
@ronie thank you, it works! Moreover I see that if I request 'streamdetails' field, the 'runtime' field is updated in accordance with 'streamdetails.duration'.
Reply

Logout Mark Read Team Forum Stats Members Help
'Real' runtime of episode0