[Issue] Localized EPG and Trakt MyTV Plugin. (1 Viewer)

Alberto83

Test Group
  • Team MediaPortal
  • August 7, 2012
    336
    108
    Italy Italy
    Hi Itfearme, please ignore the code I posted above.
    I'm working on a complete rework extending your handlers so that my solution will require just 2-3 lines of code on the traktplugin.cs to be enabled and will be completely independent from the rest of your project I'm also working on a GUI to pick manually the shows in case the EPG guide returns bad data. I'll post something very soon.
     

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,697
    7,081
    Sydney
    Australia Australia
    Country flag
    No worries, I haven't had a chance to look yet anyway :)

    At least I have moved in now.
     

    Alberto83

    Test Group
  • Team MediaPortal
  • August 7, 2012
    336
    108
    Italy Italy
    Hello, a little follow up.

    The modified handler is feature complete, and I'm testing it before cleaning the code. Unfortunately I wasn't able to debug it from visual studio (it was always crashing), so I had to use the trakt log as checkpoints to remove bugs. Once it's safe I'll remove most of the logging directives or wrap them inside an #if debug, as of now it's very chatty.
    The program uses a modified MyETVLive class if the feature is enabled, otherwise the standard untouched MyTVLive class is used, so it's very easy to go back to the standard feature if there's a bad bug. There are two new settings that enables or disables the new MyETVLive class and the scrobble notification.
    NewSettings.jpg

    I'll explain better my code when I post it, but from the user perspective it works like this:

    When a new program is detected it first checks the cache. If a record is found, it's considered safe (cache is populated manually through a GUI) and it scrobble.
    If not, it tries to scrobble the program using the EPG title. If the scrobble is not successful, calls a search on trakt using the title as query and Title,translations as fields. If the search returns a single record, it uses the record to scrobble. Otherwise it pops up a dialog asking the user to start a manual match through the GUI.
    ManualSelect Dialog.jpg
    The manual gui (below) presents the result of the search, and allows to override it with a manual search where the user inputs the title.
    SelectShowGUI.jpg
    The result is cached so that no future actions are required. If the dialog is dismissed, the response will be cached and it won't try again to scrobble the program nor ask to manual match it anymore.
    The cache is then saved on a text file for manual editing in the same folder of TbdbCache when mediaportal closes.
    Any successful scrobble can pop up a notification with a 3 seconds timeout, if the setting is enabled:
    NotificationSuccessful.jpg

    I'm still trying to fix some bugs on the GUI for the manual selection, mostly about the listcontrol focus and the window dismissal, but I'm using it since a week and it works pretty good on scrobbling. I hope to post a bug free solution after Christmas.

    For those who whants to test it, again, no worries about breaking the plugin. if you disable the ETV setting you'll fall back to the old final handler and everything will work as before.
     
    Last edited:

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,697
    7,081
    Sydney
    Australia Australia
    Country flag
    Its looking good Alberto83, the GUI needs some work but you haven't finished it yet. Was an interesting idea to put the results in window as opposed to a dialog, I guess thats a good thing so it doesn't interfere as much from the actual watching.

    I will need to get a TVTuner to test and review as I no longer have one in my Dev box, to be honest I dont even enable scrobbling for Live TV as the Australian TV EPG does not give you episode and season numbers.
     
    Last edited:

    Alberto83

    Test Group
  • Team MediaPortal
  • August 7, 2012
    336
    108
    Italy Italy
    By putting the results on a window you mean a dialog and call a DoModal when needed? I tried that but I couldn't successfully catch the keyboard input after. I should probably start another thread over the scrobble one, I'll give it a try.

    I'm trying other solutions than a GUI because I have some issues with the videoplayer. When it stops I can't go back to the previous window since the previous window is the fullscreen player which is destroyed. do you have any suggestions to handle that? Fixed it calling the ActivateWindow with GUIGraphicsContext.IsFullScreenVideo as param.

    EDIT: my code also handles shows where there's no season or episode number by asking manually to match them. Also the Italian EPG guide sometimes don't put them.
     
    Last edited:

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,697
    7,081
    Sydney
    Australia Australia
    Country flag
    Sorry, what I meant was Full-size window vs small modal dialog (similar to a context menu).

    Where it prompts you to select a season / episode if none, how does it distinguish between a movie and a episode? I believe the current code just assumes a movie if no season / episode info available. It's very possible you are watching an episode but it auto scrobbles as a movie because it finds a match for the title.
     

    Alberto83

    Test Group
  • Team MediaPortal
  • August 7, 2012
    336
    108
    Italy Italy
    Sorry, what I meant was Full-size window vs small modal dialog (similar to a context menu).
    You're right about full size vs small modal dialog. I implemented it today using a customized GUIDialogMenu, now there's a new setting users can enable to switch from full GUI to the dialog gui. The dialog is less intrusive but cannot show OSD details while open, which means sometimes it's not that easy to see the current right show, especially with shows without episode or season numbers in the EPG. I still need to fix the manual search keyboard popup. when it returns back to the dialog, it loses focus and remains on top. I think i'll probably have to fall back to full GUI for that.

    Where it prompts you to select a season / episode if none, how does it distinguish between a movie and a episode? I believe the current code just assumes a movie if no season / episode info available. It's very possible you are watching an episode but it auto scrobbles as a movie because it finds a match for the title.
    The problem about wrong type detection was one of the first i tried to address. It's obviously not 100% perfect, and incredible to say, works better with localized titles than original titles. When you query trakt for a localized title infact, it usually returns one single original title, meaning there's really no need for manual intervention. However, there's still a chance the code gets the wrong scrobble, hence the successful scrobble dialog with 5 secs timeout. Interacting will stop the scrobble and fall back to manual GUI.
    Anyways i handled it this way. There's a big big IF statement now on the scrobble thread
    1. It first checks cached results. cached results are of the type TraktEPGCacheRecord, a new Class {"movie":{TraktMovieSummary},"show":{TraktShowSummary},"type":"TYPE"}. They are considered safe, because i cache only shows and movies matched manually with user intervetion, so it's supposed to be correct. I scrobble using the data from there, overriding the videoinfo.
    2. If there's no match from cache, it tries scrobbling with the original title from the EPG. I had to do that because some shows in the EPG might not be translated. This follows the very logic already in your MyTVLive class. If the scrobble returns a response code of "0" it's successful and pops up a dialog with a 3sec timeout that eventually allows to override it.
    3. If i get a response code other that "0", it assumes it's a localized title and tries to search its original title by querying trakt with this URI:
      Code:
      https://api-v2launch.trakt.tv/search/movie,show?query=$TITLEFROMEPG$&fields=title,translations,aliases.
      If the search returns one single match, it uses that to scrobble (i'm still thinking if it should cache that, i'd rather keep cache for manual scrobble, so 100% safe matches). Otherwise manual intervention is needed and launches a dialog to ask the user if he wants to start manual GUI.
    So whenever it scrobbles something wrong, the user can stop the scrobble and trigger the manual match. Given that the manual match is cached, the more you manual match, the less you'll have to do that in the future.
    NB: if the user dismiss the dialog about the manual GUI match it caches the result with a special TraktEPGCacheRecord with type:"nullType" which prevents from scrobbling that again. This is useful for those shows or programs that don't have a record on trakt. See regional programs, or news or whatever.

    The logic behind it is actually very simple, unfortunately i had to debug the whole thing using logs instead of the visual studio debugger, because it crashes every time on my desktop. This means every time i find something wrong, i have to check the logs and see the variables content printed on traktplugin.log, very time consuming. If i have time after christmas i'll try to fix this debug crashing thing.
     
    Last edited:

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,697
    7,081
    Sydney
    Australia Australia
    Country flag
    Sounds like a good implementation Alberto83, it might be also worth looking up the cache in the MyRecordings scrobbler. Presumably it would have the same issue as an EPG?

    Regarding your crash, that sounds like a royal pain, I can't say I have every encountered VS crash in the debugger before. Are you using Express of the Full version? Im using the full version of VS2010.
     

    Alberto83

    Test Group
  • Team MediaPortal
  • August 7, 2012
    336
    108
    Italy Italy
    Sounds like a good implementation Alberto83, it might be also worth looking up the cache in the MyRecordings scrobbler. Presumably it would have the same issue as an EPG?

    I haven't checked MyRecordings yet, but yes, it's worth a look.
    I have a couple of remaining bugs to fix first, one regarding the gui being called but not showing up. It's weird, because there's no exception thrown on mediaportal-error.log and actually the gui IS there but it's like not drawn. If you click somewhere on the screen, it actually executes instructions. It's driving me crazy because it seems to happen randomly without a pattern. Has it ever happened to you?
    I'm calling the GUI with:
    Code:
    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.EPGShowSelect, GUIGraphicsContext.IsFullScreenVideo);
    and depending if isFullScreenVideo was on and the player stopped i call
    Code:
          if (wasFullScreenVideo && GUIGraphicsContext.IsPlayingVideo)
                {
                    GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO, true);
                }
                else
                {
                    GUIWindowManager.ShowPreviousWindow();
                }
    I handled it this way because i programmatically call the GUI while the player is fullscreen. This means if video is stopped, the previous window, which is the fullplayer video, cannot exist anymore. by replacing the fullscreen player with my gui i actually solve the problem.

    The second bug is something i knew since the beginning, and i'm fixing it right now. The IF statement is pretty big and it could happen that someone stops the player before the thread scrobble is returned. This throws a serie of NullReferenceException, especially when the IF statement is waiting for user input on a dialog. I just need to add some control variables. I have a try catch block to avoid crashes, but i'm trying to avoid the program to throw the exception since I read they're very expensive, and handle the problem gracefully instead.


    Regarding your crash, that sounds like a royal pain, I can't say I have every encountered VS crash in the debugger before. Are you using Express of the Full version? Im using the full version of VS2010.
    I'm using VS2015 Community. I'm not a programmer, my maing work is as sysadmin, but i'm using this project to learn programming. I problably configured something wrong, being not so comfortable with visual studio yet, but i'll try to fix it on christmas when i'll have more spare time. Actually i have to, there's no other ways i could have a look at the first problem.
     

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,697
    7,081
    Sydney
    Australia Australia
    Country flag
    one regarding the gui being called but not showing up. It's weird, because there's no exception thrown on mediaportal-error.log and actually the gui IS there but it's like not drawn. If you click somewhere on the screen, it actually executes instructions. It's driving me crazy because it seems to happen randomly without a pattern. Has it ever happened to you?
    I can't recall if I have witnessed that, strange you wouldn't see any errors logged though.

    I'm using VS2015 Community. I'm not a programmer, my maing work is as sysadmin, but i'm using this project to learn programming. I problably configured something wrong, being not so comfortable with visual studio yet, but i'll try to fix it on christmas when i'll have more spare time. Actually i have to, there's no other ways i could have a look at the first problem.
    Im not a programmer either by trade, i'm a test analyst. I started off learning C# by helping out with the tvseries plugin.

    Since I got a new pc, I have also refreshed a lot of software including VStudio. I will be upgrading the project to 2015 so will see if there is anything odd happening like it crashing when debugging MP. I'm probably not going to be very active during the holiday period (Dec-Jan) as the sun is shining down in this hemisphere this time of year :)
     

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

    OP Similar threads Forum Replies Date
    R MP2 GUI Issues General 7
    morpheus_xx [WiP] WIP 2.3 Fanart issues? MediaPortal 2 13
    morpheus_xx [Help Me!] Build issues on TeamCity MediaPortal 2 1
    W Not finding/matching new series - thetvdb issue? My TVSeries 3
    J [fixed] Import issue with alternate movie title matching the name of another movie Submit: Bug Reports 7
    1gkar Latest Intel HD4600 Drivers Issue General Support 1
    J Odd issues with Freesat EPG - MP2 General 18
    DHosein Mediaportal & Antimalware Service High CPU issue General Support 2
    J MediaPortal TV Server and Kodi media source issues General 9
    S Movie navigation issues in MP2 General 8
    cbr954rr Issue BOOTSUWRNQ with online videos? Plugin Development 1
    2BitSculptor MP1.23 release mediainfo issue? MediaPortal 1 Talk 4
    A TV Channel Combination - case issue Television (MyTV frontend and TV-Server) 0
    Edwardfc [solved] Mp 2.2.1 Configuration Issues - Goes to Sleep while playing Music General 6
    G Amazon Prime (Online Videos) Issue Plugin Development 6
    joecrow 1.22.0 MPE Manager issues. 1.22 5
    M [solved] MP2 v 2.2.1 Issue - Registry Key not created General 5
    D [solved] Multiple issues with new MP2.2.1 install 2.2 Archive 7
    S [solved] Live TV subtitle issue if not using 100% font General 31
    T FF or Rewind video issue watch/edit Videos 0
    K server issue OffTopic 0
    T Issues with MediaPortal not starting correctly using versions after 1.20 Final General Support 6
    johns11 [solved] MP2.2 TV configuration issue General 4
    A Issues with new install of My Emulators 2 My Emulators 11
    R [fixed] [MP2-799] New Manual Schedule issue. 2.2 Archive 8
    Top Bottom