TMDB integration

Added by Philipp Grosswiler about 9 years ago

I have seen an initial attempt to include TMDB support in Showtime. What are the plans for finishing it up?

It would be really great to have more information to the movies (including posters and ratings). What's the status on it?


Replies (5)

RE: TMDB integration - Added by Philipp Grosswiler about 9 years ago

Just out of curiosity I spent some time analyzing the code and improving the TMDb integration. I also came across some bugs or strange behavior. I wanted to fully automate the TMDb authentication process by generating a token (HTTP request), then logging in with the user's account and granting Showtime the permission to use TMDb, then generating the session key. This all works after small corrections in the fileaccess/fa_http.c source. Especially about cookie handling and redirection.

Let me explain in more detail:

1.) Redirection
When I issue an HTTP request, in this case a FORM POST, the server replies with a 302 response and the new location to go. Showtime correctly parses it and redirects there, but the problem is that it sends the whole FORM POST again. Which is not necessary. The redirection should only HTTP GET the new location without posting anything (means dropping the postdata and postcontenttype).

2.) Cookies
The HTTP request (FORM POST) is transmitting user name and password, so the server replies with some Set-Cookie response headers. Those are parsed correctly by Showtime. However, the current implementation does not fully comply with the specifications, e.g. it requires the attributes Path and Domain to be present. Those are clearly marked optional and the cookies aren't included in the following request (validate_cookie). Also the expiration date of cookies aren't handled at all.

I have fixed all those problems/misbehavior described above, and I can successfully generate the session key.

Now with this it would be possible to rate movies directly within Showtime, or get any information available on TMDb to show up in the movie description window. But there is currently no implementation in Showtime to do so.

As Andreas already pointed out in another thread on this forum (PS3), it's not high priority. Maybe I could give a hand to implement it, but I need some pointers where to implement it to be consistent with the programming style.

RE: TMDB integration - Added by Andreas Smas about 9 years ago

Philipp Grosswiler wrote:

Just out of curiosity I spent some time analyzing the code and improving the TMDb integration. I also came across some bugs or strange behavior. I wanted to fully automate the TMDb authentication process by generating a token (HTTP request), then logging in with the user's account and granting Showtime the permission to use TMDb, then generating the session key. This all works after small corrections in the fileaccess/fa_http.c source. Especially about cookie handling and redirection.

Let me explain in more detail:

1.) Redirection
When I issue an HTTP request, in this case a FORM POST, the server replies with a 302 response and the new location to go. Showtime correctly parses it and redirects there, but the problem is that it sends the whole FORM POST again. Which is not necessary. The redirection should only HTTP GET the new location without posting anything (means dropping the postdata and postcontenttype).

Correct, i've fixed this. see 88c2afb7

2.) Cookies
The HTTP request (FORM POST) is transmitting user name and password, so the server replies with some Set-Cookie response headers. Those are parsed correctly by Showtime. However, the current implementation does not fully comply with the specifications, e.g. it requires the attributes Path and Domain to be present. Those are clearly marked optional and the cookies aren't included in the following request (validate_cookie). Also the expiration date of cookies aren't handled at all.

This should be rather easy to fix as well. I'm just gonna make sure it works with the current stuff that uses cookies

I have fixed all those problems/misbehavior described above, and I can successfully generate the session key.

Now with this it would be possible to rate movies directly within Showtime, or get any information available on TMDb to show up in the movie description window. But there is currently no implementation in Showtime to do so.

As Andreas already pointed out in another thread on this forum (PS3), it's not high priority. Maybe I could give a hand to implement it, but I need some pointers where to implement it to be consistent with the programming style.

I'm not really sure what the best path forward here is. Just using the file hash to resolve TMDB is one way forward but i don't know how good the hitrate is for such queries.

Rather it would be good if showtime could infer the movie title based on the files parent directory name, the file name itself and perhaps some metadata in it and optionally scan .nfo and .txt files for IMDB urls. Ie. Some kind of "scene/warez file" -> Movie ID mapper.

Once showtime can do that I think it would make sense to query TMDB for info.

An additional thing is to store this data in a local db. This could also be used for local search, rating, restart-at-last-position and play-counter. I'm thinking of using sqlite here...

Well well.. just some random thoughs from a sunny Sweden :-)

RE: TMDB integration - Added by Philipp Grosswiler about 9 years ago

Great work as usual :)

I think hashing is not a bad idea as long as you use original scene sources :) ... and I think TMDb is doing exactly the same. But you are right, there should be other means to find the name of the movie. Your suggestions sound promising. Also about storing additional information about the movie in a local sqlite database...

Did you hear about GeeXboX Valhalla (or libvalhalla)? Well, since you are Swedish, you should already be familiar with that :) ... Do you think it would be of value to integrate that library into Showtime? It does quite some things that Showtime is already doing in finding metadata, but in my opinion it goes even further.

libvalhalla is a library written in C. It is a media scanner, that stores various information in an SQLite database and relies on FFmpeg (libavformat and libavutil) and libcurl. It features many Internet grabbers that allows automatic download of covers, lyrics, informations on media files, tags retrival in video and music files and so on.

It is a free software - it is licensed under the terms of the GNU Lesser General Public License (GNU/LGPL) version 2.1+.

RE: TMDB integration - Added by Girish Patel almost 8 years ago

I see that TMDB has been worked on lately. Is it working in Showtime yet? And will it have an option to be turned on and off (like in the Navi-x plugin) or will it be as a default? Thanks.

RE: TMDB integration - Added by Andreas Smas almost 8 years ago

It's on by default

(1-5/5)