Trakt for MP2 (1 Viewer)

aspik

Retired Team Member
  • Team MediaPortal
  • April 14, 2008
    1,322
    586
    @ltfearme
    I accidentally discovered a third party lib for the trakt API: TraktApiSharp. Its supports the OAuth authentication, is asynchronous and very easy to use. I switched my project to this lib. If you like, you can check it out and maybe also switch, as it really make things easier :)

    @henso @morpheus_xx
    There were some questions regarding trakt and user management. Can you please tell me, if I need to make trakt somehow "compatible" to the user management? Do I have to know which user is logged in? Is it possible at all to know this in a plugin?


    why was this thread moved to archive??
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,070
    7,459
    Home Country
    Germany Germany
    There were some questions regarding trakt and user management. Can you please tell me, if I need to make trakt somehow "compatible" to the user management? Do I have to know which user is logged in? Is it possible at all to know this in a plugin?
    There is now a lot possible with the latest rework and the addition of user restrictions. And all is available to plugins of course. The main classes/interfaces are the IUserManagement (which has property "CurrentUser" and more), the related messaging that notifies over user identity changes (UserMessaging.SendUserMessage(UserMessaging.MessageType.UserChanged);) and with this recent commit:
    MP2-735: Extend SettingsManager to allow user profile-specific settings. · MediaPortal/MediaPortal-2@d3b8ecf · GitHub
    the "user scope" settings are now related to our user profiles and no longer bound to the logged in Windows account. Note: when the user got changed (see commit linked above), the settings cache will be flushed and new filled with user-specific values. This means it is good not to cache settings instances, but always do a ServiceRegistration.Get<ISettingsManager>.Load(...) which internally caches itself, but now also reflects the current user profile.

    For trakt this means you should define user-specific settings as UserScope and react on the user change message to re-login at trakt.
     

    aspik

    Retired Team Member
  • Team MediaPortal
  • April 14, 2008
    1,322
    586
    For trakt this means you should define user-specific settings as UserScope
    Trakt settings are already defined as per user. Do you mean this scope or is in 2.2 a different user scope?
    and react on the user change message to re-login at trakt.
    Do I need to subscribe to the UserChanged event? In trakt there are two "entry points":
    - in setup model. In EnterContextModel the trakt settings are loaded. So, each user will enter this setup with its own settings, right?
    - in trakt handler. In the ConfigureHandler, scrobbling will be enabled only if trakt is enabled. In the constructor the handler subscribes to the settingsChanged event. Do I get notified by this event also when the user changed? Or only when a user changes his settings?
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,070
    7,459
    Home Country
    Germany Germany
    Trakt settings are already defined as per user. Do you mean this scope or is in 2.2 a different user scope?
    Then everything is fine. The change only affects the interpretation of what a "user" is (from Windows to MP2-UserProfile).
    Do I need to subscribe to the UserChanged event?
    I think you will need to handle the user change event inside the 2nd part (TraktHandler). The SettingsChangeWatcher only fires if any places Saves the setting. Now the user change does not save settings, but flushes cache, so a re-read is needed.

    The setup model should be fine, as it initializes inside workflow.
     

    Alberto83

    Portal Pro
    August 7, 2012
    336
    108
    Home Country
    Italy Italy
    Hi, i was the original OP for the original questions.
    I tried to make some changes to trakt code in MP2 earlier in time but it's waaay beyond my programming skills.

    I made some changes to itfearme code in mp1 just for me to sync live tv tho. if you want some support on the test side, count me in.
    i'm not into the social part of trakt but more into watch status collection sync, but I've been using it for 5 years, so i know it pretty well.
     

    aspik

    Retired Team Member
  • Team MediaPortal
  • April 14, 2008
    1,322
    586
    if you want some support on the test side, count me in.
    welcome on board! :)
    Thanks for the offer, will come back to you when I am so far. Just currently hard to find more free time to finish it...

    i'm not into the social part of trakt but more into watch status collection sync, but I've been using it for 5 years, so i know it pretty well.
    I'm also using it just for syncing, but the social part, calender, trending series, etc, is a nice eye catcher for the community and it would bring MP2 some plus points ;)
     

    Alberto83

    Portal Pro
    August 7, 2012
    336
    108
    Home Country
    Italy Italy
    I'm also using it just for syncing, but the social part, calender, trending series, etc, is a nice eye catcher for the community and it would bring MP2 some plus points ;)
    Oh sure! Absolutely. No, no, for social part I mean the friends part. :D
    I use the calendar, trending and suggestion every day, to see which episode is out. I think it's an essential part. Tying it up with MePo 2 User Profiles would be an amazing feature.
    (and combined with an hypotetical 2.2.1 future feature of multiple concurrent login on the same seat, it would totally rock! No software have such a feature, and as far as I know it's extremely requested :whistle:)
     

    aspik

    Retired Team Member
  • Team MediaPortal
  • April 14, 2008
    1,322
    586
    I'm almost finished with this rework. The necessary user management changes for 2.2 are also done. Plus, a bunch of parameterized unit tests simulating starting/stopping playback, changing user settings and changing the user itself.

    @Alberto83
    Are you still willing to test it? If so, then I'm attaching a first version which is compatible with the 2.2 builds. Please remove the included in 2.2 trakt version by deleting the content of the Trakt directory in the program files MP2 client plugins directory and copy there the content of the attached files archive.

    You can also delete the trakt directory in the MP2 client program data directory, but that should not be necessary as I'm now save/read all trakt data within the MP2 profile ID directory.
    Please use a backup/test trakt account instead of your main account and a test MP2 DB. I tried to make everything working as it should, but there could be still some issues. And I don't want to mess up your main trakt account or MP2 library ;)

    (and combined with an hypotetical 2.2.1 future feature of multiple concurrent login on the same seat, it would totally rock! No software have such a feature, and as far as I know it's extremely requested :whistle:)
    I thought about this and honestly, I'm not sure if this is really a wanted feature. It's not a problem to srobble/sync to trakt for more than one user, but it is a problem to know which trakt user(s) should be used.

    For 2.2 I currently bound the trakt user to the MP2 user profile ID. Means every MP2 user can have only one trakt user. I could allow to add/authorize more trakt users to one MP2 profile, but the problem is to select the right one after the user logs into this MP2 profile. This could be solved be showing a list of authorized trakt users right after the user changed in MP2. In this list the user would have to select the wanted trakt user(s). It isn't very user friendly. Even if I would display such a list (or choose a default one), then there is also a question what to do with an trakt account which was intended to use one time only (guest). Delete after watching a movie? Revoke the authorization?

    IMHO this additional trakt user management layer is way to complicated for the majority of users. I personally have no use even for the MP2 user management because for me a HTPC (or TV) is "user agnostic" even within a family. But that's just my opinion. I think that in general the user management in MP2 is a wanted feature :)

    So, for now I would stay with one trakt user per MP2 user.

    @Brownard
    Sorry to bother you with my silly plugin. I believe you added the recording notification? If you find a sec, I would be grateful, if you could give me some hints how to add such notifications.
    Currently the user has no knowledge if by starting to play a movie/episode the trakt plugin is working properly and sends a scroblle start/stop post to trakt. I would like to add such notification like you did for the recording event. Each time a episode/movie gets played/stopped, a notification would be shown with the note that sending to trakt was successful or not. Of course I would make it configurable i.e. show every time, show only on failure or never.

    @ge2301
    I changed the setup dialog, its not longer necessary to enter the username (it was never necessary for the authorization process. I've added it for the caching mechanism as I didn't know better back then :p).
    Below a screenshot how it now looks in BV. If you want (and have the time) you can correct it according to your taste. The other skins are not yet adjusted. Thanks :)

    @morpheus_xx
    I'll remove in the next days the trakt plugin from the MP2 solution. The online library Trakt will be also removed. I'll do it in the 2.2 branch.
     

    Attachments

    • trakt_plugin.png
      trakt_plugin.png
      815.7 KB
    • Trakt_For_MP2.2_v1.7z
      286.8 KB

    Alberto83

    Portal Pro
    August 7, 2012
    336
    108
    Home Country
    Italy Italy
    I'm almost finished with this rework. The necessary user management changes for 2.2 are also done. Plus, a bunch of parameterized unit tests simulating starting/stopping playback, changing user settings and changing the user itself.

    @Alberto83
    Are you still willing to test it? If so, then I'm attaching a first version which is compatible with the 2.2 builds. Please remove the included in 2.2 trakt version by deleting the content of the Trakt directory in the program files MP2 client plugins directory and copy there the content of the attached files archive.

    You can also delete the trakt directory in the MP2 client program data directory, but that should not be necessary as I'm now save/read all trakt data within the MP2 profile ID directory.
    Please use a backup/test trakt account instead of your main account and a test MP2 DB. I tried to make everything working as it should, but there could be still some issues. And I don't want to mess up your main trakt account or MP2 library ;)
    Ofcourse I am! I use trakt a lot so i'm absolutely glad to.
    I'll create and use a test ID to try it, and if everything is ok i'll switch to main.

    EDIT: What am I supposed to test exactly? Just normal watch usage? Is there any new feature or specific functions I have to focus to?

    I thought about this and honestly, I'm not sure if this is really a wanted feature. It's not a problem to srobble/sync to trakt for more than one user, but it is a problem to know which trakt user(s) should be used.

    For 2.2 I currently bound the trakt user to the MP2 user profile ID. Means every MP2 user can have only one trakt user. I could allow to add/authorize more trakt users to one MP2 profile, but the problem is to select the right one after the user logs into this MP2 profile. This could be solved be showing a list of authorized trakt users right after the user changed in MP2. In this list the user would have to select the wanted trakt user(s). It isn't very user friendly. Even if I would display such a list (or choose a default one), then there is also a question what to do with an trakt account which was intended to use one time only (guest). Delete after watching a movie? Revoke the authorization?

    IMHO this additional trakt user management layer is way to complicated for the majority of users. I personally have no use even for the MP2 user management because for me a HTPC (or TV) is "user agnostic" even within a family. But that's just my opinion. I think that in general the user management in MP2 is a wanted feature :)

    So, for now I would stay with one trakt user per MP2 user.
    I absolutely agree that trakt should be tied per MP2 profile only, I was just hoping one day MP2 will allow multiple profile sign in. :p
    Yes the user management feature is a real deal! For example, I use it a lot to lock delete actions and skin changes for guest user, so that i'm 100% sure nobody is gonna mess with my collection by mistake.
     
    Last edited:

    Brownard

    Development Group
  • Team MediaPortal
  • March 21, 2007
    2,301
    1,886
    Home Country
    United Kingdom United Kingdom
    I would be grateful, if you could give me some hints how to add such notifications.
    Hopefully should be fairly straightforward, you just need to call ISuperLayerManager.ShowSuperLayer with the notification superlayer's name and the duration, e.g.
    C#:
    ServiceRegistration.Get<ISuperLayerManager>().ShowSuperLayer("RecordingStartedNotification", 10);
    For TV this is handled in the SlimTvNotificationModel. The base screen that contains the common layout/animations is defined in the screens subdirectory here, then there's another screen here that inherits from that and defines the information common to both recording started and stopped notifications. The actual superlayer needs to be in the superlayers subdirectory. e.g. the RecordingStartedNotification is defined here, and is just a basic screen that defines the title but inherits the rest of the layout/animations from the base screens.
     

    Users who are viewing this thread

    Top Bottom