Trakt.tv LiveTV scrobble Development help request. (1 Viewer)

Alberto83

Test Group
  • Team MediaPortal
  • August 7, 2012
    336
    108
    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.
    C#:
    var tvHandler = (SlimTvHandler)ServiceRegistration.Get<ITvHandler>(false);
    tvHandler.CurrentProgram.Title
    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! :)
     

    aspik

    Development Group
  • Team MediaPortal
  • April 14, 2008
    1,383
    553
    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.
     

    Alberto83

    Test Group
  • Team MediaPortal
  • August 7, 2012
    336
    108
    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.
     

    morpheus_xx

    Lead Dev MP2
  • Team MediaPortal
  • March 24, 2007
    11,390
    6,966
    Germany Germany
    Country flag
    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?)
     

    aspik

    Development Group
  • Team MediaPortal
  • April 14, 2008
    1,383
    553
    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?)
    this is the reason why I didn't use trakt for LiveTV. I can't imagine how this can be reliable implemented.
     

    Alberto83

    Test Group
  • Team MediaPortal
  • August 7, 2012
    336
    108
    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.
     

    HTPCSourcer

    MP2 Product Manager
  • Team MediaPortal
  • May 16, 2008
    11,431
    2,333
    Germany Germany
    Country flag
    @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.
     

    Alberto83

    Test Group
  • Team MediaPortal
  • August 7, 2012
    336
    108
    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.
     

    HTPCSourcer

    MP2 Product Manager
  • Team MediaPortal
  • May 16, 2008
    11,431
    2,333
    Germany Germany
    Country flag
    Would an alert popping up like "Do you want to scrobble <programname>?" be too intrusive?
    My personal preference would be to not have any popup. You either scrobble the info our you don't.
     

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)

    Top Bottom