Trakt for MP2 (1 Viewer)

morpheus_xx

Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    Hi,

    there were many requests to add Trakt / Follow.it support to MP2. As I don't use those services, I need some help in understanding how they work.

    So far I've seen, they provide:
    • user registration
    • ability to upload your details about movies and series
    • synchronize the "watched" indicator of items
    What I've seen is that Trakt API is provided by: https://github.com/Technicolour/Trakt-for-Mediaportal/tree/master/TraktPlugin/TraktAPI (I think by @ltfearme, right?). It offers different handlers to work with MP1 plugins.

    Now we come to the point, how we could port the features to MP2 world:
    I think in MP2 we have only one source for media information: the MediaLibrary (ML). We don't have x plugins to support like in MP1.
    Dealing with the "watched" state would involve different parts:
    1. A plugin would need to be informed, that a MediaItem was played back. We already have 2 kind of this notifications:
      • on playback start the ML (global) will be notified and updates the PlayCount attribute
      • on playback end the UserService (so user dependent) sends "resume state" to server, it persists it in mediaitem-user table
    2. For (re-)imports of media the used MetaDataExtractors (MDEs) first detect the kind of video (series, movie), then it would be possible to ask the Trakt API if the item was watched already

    The IUserProfileDataManagement provides methods to deal with user accounts (currently we implicitely use ClientPC == User), to store common user data and also mediaitem specific data.

    As the online services reqiure authentification, we need to store user credentials in the profile.

    So my questions are:
    Is my understanding of the services correct? What important features I missed?
    @ltfearme what do you think: can we use your(?) trakt api? Can it be made available separately, or could it be integrated into MP2 OnlineLibraries collection? (I think @chefkoch thought about this?) Edit: found the thread with the ideas: https://forum.team-mediaportal.com/...aries-open-the-source-in-a-better-way.117705/

    Please provide feedback, not only from dev's but also users point of view!

    Testbuilds
    2014-03-08:

    2014-03-16:
    • Attached updated plugins for MP2-Client only
     

    Attachments

    • Update_20140316.7z
      1,019.6 KB
    Last edited:

    Edalex

    Community Plugin Dev
  • Premium Supporter
  • January 3, 2008
    2,955
    1,264
    Saratov
    Home Country
    Russian Federation Russian Federation
    As I know ltfearme did a great job in separating MP1 GUI stuff from trakt api so it should be almost ready for using in MP2.
    Just to mention that trakt in addition to sync and upload features alos is a data provider of episodes release dates (calendar), recommendation service (with bad logic though), simple social networking with friends/followers, metadata, trailers, cover art and poster source (search ability is implemented in api) etc.
     

    Lehmden

    Retired Team Member
  • Premium Supporter
  • December 17, 2010
    12,554
    3,936
    Lehmden
    Home Country
    Germany Germany
    Hi.
    To me personally the social network features and the recommendations are not that important. Never used that. To have more Cover art and poster sources can't be bad ofc...
    But the most important thing (and the root case of this services) is the watched flag management. Trakt (same does follw.it) is the best way to keep watched status "uptodate" and to synchronize them between different systems. As I need to use XBMC on some Linux/Android systems (as MP2 did not run on Linux/Android) the watched status is in sync, no matter if I watch a movie with XBMC on my tablet or MP on my TV... This can't be achieved with a local solution, I think.

    In Ideal MP2 will support both services, Trakt and Follw.it at the same time. With MP1 I prefer Follw.it as it is easier to manage. To trigger a manual synchronisation with Trakt is not that easy to find, with Follw.it this only is one button press away. But follw.it support on XBMC is not that reliable (most of the time it didn't work at all) so for that I have both services up and running... And I'm happy too if only Trakt will be supported as Trakt did all I need too...

    I would like to see some "buttons" on Trakt/Follw.it plugin GUI. "Synchronise Collection" (to trigger a manual sync of online and local data), "Clear Online Collection" to refresh the online data based on the recent local data (useful if you've locally deleted a series and you want to wipe this from online also). We could add this to Setup (near input of user credentials), an extra GUI page or the "context menu" on Series / Movies GUI section. Some "Mark Series as watched/unwatched", "Mark Season as watched/unwatched" and "Mark Episode/Movie as watched/unwatched" context menu entries could be very useful also...
     

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,751
    7,196
    Sydney
    Home Country
    Australia Australia
    @ltfearme what do you think: can we use your(?) trakt api? Can it be made available separately, or could it be integrated into MP2 OnlineLibraries collection? (I think @chefkoch thought about this?)
    I have no issues with you using it, I have done a bit of cleanup since @chefkoch last looked at it, it should be good to strip out and make a seperate online library.

    It might be worth waiting until trakt 2.0 which will be coming out soon, they are re-vamping the API, the old one will remain compatible but I think it might be worth holding off until I get a chance to see what changes they do and update it.

    You could start the trakt for MP2 project off with basic support, this would be:
    • Ability to signup from GUI (3 fields required, username, password and email).
    • Ability to send watching state (i.e. send trakt that you're currently watching an episode/movie). Plugin would need to know when playback has started. This would be something on a timer every x minutes.
    • Ability to send scrobble state (i.e. send trakt that you have completed watching an episode/movie). Plugin would need to know when playback stopped and has completed.
    • Ability to send cancel state (i.e. send trakt that you have finished watching an episode/movie but not watched it to completion). Plugin would need to know playback has stopped.
    Short Term goals:
    • Full Library syncing of collected, watched (incl. playcounts), unwatched (something that has been toggled from watched->unwatched) and user ratings. Also listen to add/delete of mediaitems for realtime sync.
    • Rate Dialog, automatic after an episode/movie is watched or user invoked.
    • Send watched/unwatched state when toggled from GUI on a users media item.
    Long Term goals:
    • Syncing and tighter integration of Custom Lists, Watchlists and User Recommendations.
    • GUI windows for user to experience the fullness of trakt e.g.
      • TV Show Calendar (My Shows, Premieres, All Shows)
      • Trending (What people are currently watching on Trakt).
      • Recommendations.
      • Related Movies/Shows.
      • Search.
      • Watchlist and Custom Lists.
      • User Profile
      • User Network (Friends, Followers, Following etc).

    That's a few thoughts off the top of my head, the current MP 1 plugin has all of this plus more but has been in development for a few years now.

    trigger a manual synchronisation with Trakt is not that easy to find.
    lol, that's because it was removed, didn't see the point if it automatically sync's on gui startup and or every x hours and on internal plugin import events. If that is something you feel you really need you can popup over the MP trakt sub-forum and request it ;).
     
    Last edited:

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    • Thread starter
    • Moderator
    • #5
    Thank you a lot for your info, this is very valueable!

    You could start the trakt for MP2 project off with basic support, this would be:
    Ability to signup from GUI (3 fields required, username, password and email).
    Ability to send watching state (i.e. send trakt that you're currently watching an episode/movie). Plugin would need to know when playback has started.
    Ability to send scrobble state (i.e. send trakt that you have completed watching an episode/movie). This would be something on a timer every x minutes. Plugin would need to know when playback stopped and has completed.
    Ability to send cancel state (i.e. send trakt that you have finished watching an episode/movie but not watched it to completion). Plugin would need to know playback has stopped.
    Yes, such things I thought about. I imagine following steps for MP2:
    • Create a new Plugin, include your current library (in any way)
    • Create MP2 settings to store required user information for API access (enable/disable, username, password)
    • Use the Server user management to store the settings. This brings us the option to switch your user identity in multi-seat (as written above, currently user == computer)
    • It would work already to get message about playback started in generally (no matter how long you play it)
    • And we could handle the message that persists resume info (it could be extended to get a "watched" indicator, based on percentage)
    Based on the existing features (MP2 and Trakt API), this could be implemented in few days.

    (One) next step would be a MetaDataExtractor to restore the information on import.
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    • Thread starter
    • Moderator
    • #6
    First status update:

    I took an 11 month old branch from chefkoch and recognized that it didn't build :p. So I copied the trakt api files from source repo into MediaPortal.OnlineLibraries project. I removed many things for the beginning, changed some structure etc...

    The API compiles :)

    Next step was to create a first trakt plugin to configure account details:
    01_settings.png
    02_settings.png
    03_settings.png


    Current progress is commited.
    https://github.com/morpheusxx/MediaPortal-2/compare/dev...OnlineLibs.Trakt.tv

    I'm satisfied about today work of 2 hours :)

    Tomorrow and weekend I will make my first tests with the API itself and I will have many questions, I think (I registered today, so I can start coding and testing). Stay tuned :)
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    • Thread starter
    • Moderator
    • #7
    Ability to signup from GUI (3 fields required, username, password and email).
    Ability to send watching state (i.e. send trakt that you're currently watching an episode/movie). Plugin would need to know when playback has started. This would be something on a timer every x minutes.
    Ability to send scrobble state (i.e. send trakt that you have completed watching an episode/movie). Plugin would need to know when playback stopped and has completed.
    First basic settings GUI for account data is done.
    • Notify playback start is done (watching)
    • Notify playback finishes is done (scrobble)
    • Notify playback canceled is pending (only minor change required)
    I'm still getting used to the API, terms and features.

    I already got an error message when setting a movie to "watched", sounds like "limit per hour reached". Bad for testing.

    Are there limitations to be aware of?

    I should register an own API key (or better product) for MediaPortal 2. This can be done maybe with first test plugin gets available (or with MP2 Beta 1). There is also a huge positive marketing effect: MP2 gets listed as own product, own description, download links a.s.o.

    Next thing I would test is series scrobbling. I already took a brief look into the TraktSeriesScrobble class. Here we could have a problem in supplying required "keys": our MovieAspect includes both IMDBID and TMDBID. SeriesAspect doesn't contain an ID :( We only have Series Name, Year first aired, Season/Episode number. How to deal with this fact? Extension of SeriesAspect? Or can we use the API without external IDs?

    Was a side effect only:I tried to scrobble an episode and got an 404 error. Any idea about this issue?
    The url in browser works, gives correct JSON error message:
    http://api.trakt.tv/show/watching/0edee4275d03fe72117e3f69a28815939b082548


    Finally a new screenshot: Everybody knows what I used for testing :p
    04_movie_scrobble.png
     
    Last edited:

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,751
    7,196
    Sydney
    Home Country
    Australia Australia
    [
    I already got an error message when setting a movie to "watched", sounds like "limit per hour reached". Bad for testing.

    Are there limitations to be aware of?
    Yeah, there is a 10 episode and 2 movies per hour limitation, there is also some checking done on runtime just incase some clients are silly and try to scrobble trailers etc.

    I know that's not the best for testing, I think these limitations were put in place because people wanted great stats and were trying to game the system...not so much and issue anymore so im sure they will revise this in trakt 2.0.

    I should register an own API key (or better product) for MediaPortal 2. This can be done maybe with first test plugin gets available (or with MP2 Beta 1). There is also a huge positive marketing effect: MP2 gets listed as own product, own description, download links a.s.o.
    Yeah its great for marketing MP2, you can register as a seperate MediaCenter and have your own logo for the People Watching section. What might be best is when MP2 picks up and comes out of beta seperate from MP1 then, for now I think you can still have it listed under MediaPortal but still have your own logo and name. I can arrange for that if you want (you can pm me you email and I can forward you in an email to the trakt admins)?

    Next thing I would test is series scrobbling. I already took a brief look into the TraktSeriesScrobble class. Here we could have a problem in supplying required "keys": our MovieAspect includes both IMDBID and TMDBID. SeriesAspect doesn't contain an ID :( We only have Series Name, Year first aired, Season/Episode number. How to deal with this fact? Extension of SeriesAspect? Or can we use the API without external IDs?
    You can get a match on trakt using the show title and year but its not as accurate as an IMDb or TVDb ID, I think it handles aka's but it can't be perfect so if you can make that available in the future that would be best. Does your EpisodeAspect (if you have one) cater for external IDs? Because you can also send along episode_tvdb_id: http://trakt.tv/api-docs/show-scrobble. This is more useful for clients which dont handle aired order, that's another thing you should be aware of, if you can't guarantee this then also send the episode id.

    Finally a new screenshot: Everybody knows what I used for testing :pView attachment 146929
    Awesome, now just need to get it to say "Watching in MediaPortal 2..." :)

    Remember I mentioned the "timer ever x minutes..." for the watching state? If you send watching every 10mins or so, you can see a progress bar as well e.g. you can send how far along into the episode or movie you are.
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    • Thread starter
    • Moderator
    • #10
    Yes, the repeated requests are now also implemented.
    Series seem to work, if title matches. Not sure about localized titles, will check tomorrow (or better today :)). N8...
     

    Users who are viewing this thread

    Top Bottom