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

Alberto83

Portal Pro
August 7, 2012
336
108
Home Country
Italy Italy
Hello there, I'm a long user of Mediaportal but I always managed to fix my problems without having to start new threads.
This time tho, i'm running out of options and I need an advice.

I have MP 1.15 with trakt 5.7.0. Everything in my system is in EN-US even if i'm Italian, because my GF is american and honestly, I find English more comfortable. Everything was working perfectly until I bought a dual tuner DVB-T2 card, grabbed the Italian EPG and enabled the MyTv Handler.
The problem is trakt returns a 404 on scrobbling every Italian localized titles in my EPG. For example:

Bones (non translated TV show title): Perfect scrobble. Log below.
2016-11-21 10:51:01.518 [INFO] [Scrobble][06]: Current program details. Title='Bones', Year='<empty>', Season='4', Episode='1', StartTime='11/21/2016 10:03:00', Runtime='54'
2016-11-21 10:51:01.891 [INFO] [Scrobble][06]: Scrobble Response: {"action":"start","episode":{"ids":{"slug":null,"trakt":140650,"imdb":null,"tmdb":126287,"tvdb":374849,"tvrage":0},"number":1,"season":4,"title":"Yanks in the U.K. (1)"},"movie":null,"progress":74.18,"sharing":{"facebook":false,"tumblr":false,"twitter":false},"show":{"ids":{"slug":"bones","trakt":1898,"imdb":"tt0460627","tmdb":1911,"tvdb":75682,"tvrage":2870},"title":"Bones","year":2005}}


Dr house - Medical Division (Italian translated TV Show Title): wrong scrobble 404, log below.
2016-11-21 10:56:01.518 [INFO] [Scrobble][06]: Current program details. Title='Dr. House - Medical Division', Year='<empty>', Season='7', Episode='21', StartTime='11/21/2016 10:05:00', Runtime='60'
2016-11-21 10:56:01.523 [INFO] [Scrobble][06]: Detected new tv program has started. Previous Program = 'Bones - 4x1', New Program = 'Dr. House - Medical Division - 7x21'
2016-11-21 10:56:01.528 [INFO] [Scrobble][06]: Playback of program on Live TV is considered watched. Title = 'Bones - 4x1'
2016-11-21 10:56:01.795 [ERR ] [Scrobble][06]: Protocol Error, Code = '404', Description = 'Not Found', Url = 'https://api-v2launch.trakt.tv/scrobble/start', Headers = 'Transfer-Encoding: chunked, Connection: keep-alive, Cf-Railgun: ec63978e15 99.99 0.030061 0030 e6be, Vary: Accept-Encoding, X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN, X-Request-Id: b9f6edb8-5116-4265-afcf-e44b9431e647, X-Runtime: 0.022862, X-Xss-Protection: 1; mode=block, CF-RAY: 3053450fdfac0e2a-MXP, Cache-Control: max-age=0, private, no-cache, no-store, must-revalidate, Content-Type: text/html, Date: Mon, 21 Nov 2016 09:56:05 GMT, Set-Cookie: __cfduid=decb14b5e0cac50c6ab21d1790710e1171479722165; expires=Tue, 21-Nov-17 09:56:05 GMT; path=/; domain=.trakt.tv; HttpOnly, Server: cloudflare-nginx'
2016-11-21 10:56:01.856 [INFO] [Scrobble][34]: Scrobble Response: {"action":"scrobble","episode":{"ids":{"slug":null,"trakt":140650,"imdb":null,"tmdb":126287,"tvdb":374849,"tvrage":0},"number":1,"season":4,"title":"Yanks in the U.K. (1)"},"movie":null,"progress":83.38,"sharing":{"facebook":false,"tumblr":false,"twitter":false},"show":{"ids":{"slug":"bones","trakt":1898,"imdb":"tt0460627","tmdb":1911,"tvdb":75682,"tvrage":2870},"title":"Bones","year":2005}}


Law & Order: Unità Speciale (again Italian TV show Translation): Wrong scrobble, 404.
2016-11-21 11:01:05.630 [INFO] [Scrobble][29]: Current program details. Title='Law & Order: Unità Speciale', Year='<empty>', Season='1', Episode='19', StartTime='11/21/2016 10:15:00', Runtime='55'
2016-11-21 11:01:05.635 [INFO] [Scrobble][29]: Detected new tv program has started. Previous Program = 'Dr. House - Medical Division - 7x21', New Program = 'Law & Order: Unità Speciale - 1x19'
2016-11-21 11:01:05.639 [INFO] [Scrobble][29]: Playback of program on Live TV is considered watched. Title = 'Dr. House - Medical Division - 7x21'
2016-11-21 11:01:05.947 [ERR ] [Scrobble][36]: Protocol Error, Code = '404', Description = 'Not Found', Url = 'https://api-v2launch.trakt.tv/scrobble/stop', Headers = 'Transfer-Encoding: chunked, Connection: keep-alive, Cf-Railgun: b0f7fb4fec 99.99 0.073401 0030 e6be, Vary: Accept-Encoding, X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN, X-Request-Id: 43ba08dc-991a-4df4-88d0-2317950f4ef3, X-Runtime: 0.067655, X-Xss-Protection: 1; mode=block, CF-RAY: 30534c62d95c0e24-MXP, Cache-Control: max-age=0, private, no-cache, no-store, must-revalidate, Content-Type: text/html, Date: Mon, 21 Nov 2016 10:01:05 GMT, Set-Cookie: __cfduid=d4a671e8023860efee7765daa984b22451479722465; expires=Tue, 21-Nov-17 10:01:05 GMT; path=/; domain=.trakt.tv; HttpOnly, Server: cloudflare-nginx'
2016-11-21 11:01:05.956 [ERR ] [Scrobble][29]: Protocol Error, Code = '404', Description = 'Not Found', Url = 'https://api-v2launch.trakt.tv/scrobble/start', Headers = 'Transfer-Encoding: chunked, Connection: keep-alive, Cf-Railgun: cc23955881 99.99 0.068734 0030 e6be, Vary: Accept-Encoding, X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN, X-Request-Id: 4d114e0c-81a0-414f-b585-e0f1337c9273, X-Runtime: 0.065807, X-Xss-Protection: 1; mode=block, CF-RAY: 30534c62df960e36-MXP, Cache-Control: max-age=0, private, no-cache, no-store, must-revalidate, Content-Type: text/html, Date: Mon, 21 Nov 2016 10:01:05 GMT, Set-Cookie: __cfduid=d6574efa6e71a6c3a8b065d0d169673981479722465; expires=Tue, 21-Nov-17 10:01:05 GMT; path=/; domain=.trakt.tv; HttpOnly, Server: cloudflare-nginx'


The problem is that if I search 'Dr. House - Medical Division' in trakt it correctly finds the right show, "House", and If i search "'Law & Order: Unità Speciale" it finds correctly "Law & Order: Special Victims Unit"
Could it be that trakt search against the English database instead of the Italian one? When it starts, the logs shows:
2016-11-21 10:10:38.237 [INFO] [MPMain][01]: Initialising My TV plugin handler
2016-11-21 10:10:38.237 [INFO] [MPMain][01]: Using language en-US


Is it possible to force the LiveTV hanlder only to search against the Italian translations for tv shows? All my shows from TV Series and Movies from Movingpictures are in English, so I never noticed this issue in the past. I searched every config file, every settings, but I couldn't find anything.

Any idea?
 

ltfearme

Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,755
    7,200
    Sydney
    Home Country
    Australia Australia
    Hi Alberto83,

    When you send a scrobble to trakt the order of precedence for matching a movie/episode is:
    * trakt id
    * tmdb id / imdb id (movies)
    * show tvdb id (episodes)
    * title (english) + year
    * title (english)

    Unfortunately the scrobble API on trakt does not do any type of localised title matching which is what you need. Since TV EPG's don't have IDs I typically need to rely on the title/year matching which is not good for you with Italian data.

    The only solution I can think of would be to add an option to do a search using the localised title before scrobbling, and use the first matching result if its a success. It wont be perfect, but given you are having success with manual searching on the website it should work okay for the most part. I could cache these results so only one lookup is required.

    Another solution would be to allow the user to create a tv show alias for a title, I could then use the English alias provided by the user.

    What do you think?
     

    Alberto83

    Portal Pro
    August 7, 2012
    336
    108
    Home Country
    Italy Italy
    Hi ltfearme, thanks for the quick response!
    I really thought they allowed to specify language in scrobbles or search, that's a missing feature.

    Yes, i've done some tests with the examples provided and also "la signora in giallo" using a custom api key on the apiary.
    All results returned the original tv show title. I haven't tried in other languages because i don't know the titles.
    A query to Https://api.trakt.tv/search/show?query=Dr house - Medical Division returned

    Body
    [
    {
    "type": "show",
    "score": 31.504982,
    "show": {
    "title": "House",
    "year": 2004,
    "ids": {
    "trakt": 1399,
    "slug": "house",
    "tvdb": 73255,
    "imdb": "tt0412142",
    "tmdb": 1408,
    "tvrage": 3908
    }
    }
    }
    ]

    So this actually works. If before a scrobble you can call this to check the right tv serie ID, it *might* be enough. It needs to know if it's a movie or a show, but i think the logic behind this could be just to check if season and episode is provided for tv shows, otherwise it's a movie. Eventually you can cache the results using localized names, original name, and the serie ID on a db file so that we can edit and eventually fix wrong matches lately by hand.
    Maybe making this an option in the advanced settings to activate would save some delay to those who have the epg in english.
    This is a start, and a quick fix to the problem, while waiting for the API to allow localized search. Would it be too complicated to do?
    I wish I could help but i'm not a programmer. I could test it though.


    EDIT: maybe an evolution to this could be to pop up a menu when it returns multiple results and let the user choose, but I think this could be done later.
     
    Last edited:

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,755
    7,200
    Sydney
    Home Country
    Australia Australia
    Adding a search function before the scrobble event if setting is enabled (only for TV EPG) is easy enough, I can add that for you.I will cache the results in a file so can be edited by the user if not correct.

    I could add a search popup when there is multiple results but lets table that idea for later.
     

    Alberto83

    Portal Pro
    August 7, 2012
    336
    108
    Home Country
    Italy Italy
    That would be awesome! if it works well enough I think it should go to production. I'm sure i'm not the only one with a localized epg here.
    I'm happy to test :)
     

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,755
    7,200
    Sydney
    Home Country
    Australia Australia
    Cool, im currently not able to make the change for a week or two as im moving home so other things are on my plate. I will give you a test build when done.
     

    Alberto83

    Portal Pro
    August 7, 2012
    336
    108
    Home Country
    Italy Italy
    Hi, I had a day off today and I played a little with Visual Studio and the source code of your plugin from GitHub. I managed to get localized tv series and movies scrobbled if they have a translation in the trakt database. I'm no programmer at all so probably this solution is not the best way to do that, but I tested it for 2 hours and it's working (and best of all, it's not crashing).
    It's a primitive workaround (and it doesn't have a control in settings yet), but if you want I can provide the diff file here if someone wants to play with it, until you have time for a real solution. :)
     

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,755
    7,200
    Sydney
    Home Country
    Australia Australia
    Hi Alberto83, feel free to share your solution. I can take a look very soon.

    Thanks!
     

    Alberto83

    Portal Pro
    August 7, 2012
    336
    108
    Home Country
    Italy Italy
    Hi Itfearme, you can find my work in the file attached.
    There's a diff file to apply to copy of the master project and a complete new file that contains most of the logic for the localized search.

    I decided to create a new class to keep your code clean as much as I could. I managed to add a setting in extensions to disable or enable Localized searches (default disabled), and it works. When localized search is disabled almost none of my code runs, which makes it safe in case someone wants to give it a try without breaking the plugin completely. it's just a matter of disabling it.
    I implemented a very primitive caching mechanic on disk which for now requires matching titles by hand from notepad, but considered I started everything yesterday, it's better than nothing.
     

    Attachments

    • Trakt_EPG_Localization.rar
      5.7 KB

    Users who are viewing this thread

    Top Bottom