Trakt.tv LiveTV scrobble Development help request.

Discussion in 'Plugin Development' started by Alberto83, May 11, 2017.

  1. Alberto83
    • Team MediaPortal

    Alberto83 Test Group

    Joined:
    August 7, 2012
    Messages:
    336
    Likes Received:
    80
    Gender:
    Male
    Ratings:
    +119 / 1
    Home Country:
    Italy Italy
    Hello all.
    I've been working on adding LiveTV Program scrobbling on the builtin trakt plugin in the last days since i had some free time.
    I'm new to MP2 development and C# development in general, so I decided to start with something that i could actually test every day like scrobbling from Live TV.
    I found some problems while trying to get the right informations for the current program (CurrentMediaItem is always set to "Live TV" for Live tv programs) but i finally found a way using these two lines of code.
    Code (C#):
    1.  
    2. var tvHandler = (SlimTvHandler)ServiceRegistration.Get<ITvHandler>(false);
    3. tvHandler.CurrentProgram.Title
    4.  
    Now i'm facing another issue and after reading the code of Mediaportal 2 i'm stuck. There seems to be no way to know when the current program changes, either because the program ended or because of channel change, at least not using MP Messages. I'd rather use Subscription Queues instead of a thread that every 10 minutes checks if the program is changed like on Trakt for MP1. Can anyone confirm there's no such message? Are there plans to implement it in future releases?
    Using PlayerManagerMessaging.MessageType.PlaybackStateChanged i can detect a channel change (it fires twice though, obviously) but not a program change on the EPG timeline.
    Can someone point me to the right direction, if there's any?



    Thank you! :)
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. aspik
    • Team MediaPortal

    aspik Development Group

    Joined:
    April 14, 2008
    Messages:
    1,270
    Likes Received:
    348
    Ratings:
    +572 / 1
    Hi,

    thanks for you interest in MP2 and trakt, your contribution is welcome!
    Personally I never used trakt on LiveTV and I'm honestly didn't looked how ltfearme implemented LiveTV on his MP1 version.
    Unfortunately I'm not so familiar with the TV part of MP2, so I can't answer your question. I'm sure @morpheus_xx is the right person how can help you with LiveTV.
     
    • Thank You! Thank You! x 1
  4. Alberto83
    • Team MediaPortal

    Alberto83 Test Group

    Joined:
    August 7, 2012
    Messages:
    336
    Likes Received:
    80
    Gender:
    Male
    Ratings:
    +119 / 1
    Home Country:
    Italy Italy
    Thank you for you reply. :)
    While it wouldn't be a problem to create a sleeping thread that wakes up every 10 minutes to check the program status, a native message to know when the current program changes could be a more elegant solution for the problem, I think, that could be used also for other plugins.
    Since Morpheus will read this, i'll take a chance to ask him if there's a special reason why the currentmediaitem title is always set to LiveTV for live streams (but not for recorded streams) instead of the EPG title, if present.
    I read part of the code, but probably not enough to understand why.
     
  5. morpheus_xx
    • Team MediaPortal

    morpheus_xx Lead Dev MP2

    Joined:
    March 24, 2007
    Messages:
    10,856
    Likes Received:
    4,680
    Ratings:
    +6,704 / 11
    Home Country:
    Germany Germany
    Show System Specs
    The logic between recordings and live tv is different for a reason:
    A recording is usually created for a single program. So in this case we can set the program's title as media item title.

    For LiveTV it's different: we are always using timeshift, so you can pause at any moment and continue watch hours later. This means, the "current running program" can be different to the "program at current watching position". This is even more complicated if you zap between channels: the card tunes a new channel, the stream and timeshift buffer will remain. We internally keep a list of all zappings (time + channel) here: MediaPortal-2/SlimTvHandler.cs at 196b021d29f643c8d01600c33df6b636206226da · MediaPortal/MediaPortal-2 · GitHub. You could find the current running "program part" by checking the list of TimeshiftContexts (we do this also to create "chapters", the player can seek back to the channel change positions).

    If you plan to sync LiveTV with trakt you should consider this architecture and more important to build a good rule what you want to set "watching" and "watched" (i.e. zapping for few seconds on a movie, should it be scrobbled?)
     
    • Thank You! Thank You! x 2
  6. aspik
    • Team MediaPortal

    aspik Development Group

    Joined:
    April 14, 2008
    Messages:
    1,270
    Likes Received:
    348
    Ratings:
    +572 / 1
    this is the reason why I didn't use trakt for LiveTV. I can't imagine how this can be reliable implemented.
     
  7. Alberto83
    • Team MediaPortal

    Alberto83 Test Group

    Joined:
    August 7, 2012
    Messages:
    336
    Likes Received:
    80
    Gender:
    Male
    Ratings:
    +119 / 1
    Home Country:
    Italy Italy
    Ahhhh. I never used zapping at all, so I totally didn't think about that; I usually park myself on the channel depending on what I want to see.
    I'll think about it.
     
  8. HTPCSourcer
    • Team MediaPortal
    • Administrator

    HTPCSourcer MP2 Product Manager

    Joined:
    May 16, 2008
    Messages:
    10,453
    Likes Received:
    1,103
    Gender:
    Male
    Ratings:
    +2,366 / 21
    Home Country:
    Germany Germany
    Show System Specs
    @Alberto83 , in any case we will be very interested in testing your work. You can provide patches in the Testing Area for the community to take a look at and provide feedback.

    Regarding watching / zapping you could consider a minimum non-interrupted watch time for a show to be considered as watched, i.e. a counter that is reset whenever you zap.
     
  9. Alberto83
    • Team MediaPortal

    Alberto83 Test Group

    Joined:
    August 7, 2012
    Messages:
    336
    Likes Received:
    80
    Gender:
    Male
    Ratings:
    +119 / 1
    Home Country:
    Italy Italy
    I was exactly thinking about a zap timeout for it. Maybe customizable by the user.
    Would an alert popping up like "Do you want to scrobble <programname>?" be too intrusive? I did something like that on my custom version of trakt for MP1.
     
  10. HTPCSourcer
    • Team MediaPortal
    • Administrator

    HTPCSourcer MP2 Product Manager

    Joined:
    May 16, 2008
    Messages:
    10,453
    Likes Received:
    1,103
    Gender:
    Male
    Ratings:
    +2,366 / 21
    Home Country:
    Germany Germany
    Show System Specs
    My personal preference would be to not have any popup. You either scrobble the info our you don't.
     
    • Agree Agree x 1
  11. aspik
    • Team MediaPortal

    aspik Development Group

    Joined:
    April 14, 2008
    Messages:
    1,270
    Likes Received:
    348
    Ratings:
    +572 / 1
    More appropriate place would be the submit code patches forum. Or event here in the plugin development section. In the end, trakt is a plugin and in future it will be moved to a "standalone" plugin.
     
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!