trakt / script.trakt

Trakt.tv movie and TV show scrobbler for Kodi
GNU General Public License v2.0
324 stars 149 forks source link

Play counts not updated for absolute numbering #168

Open Anthirian opened 10 years ago

Anthirian commented 10 years ago

Hi,

I have a minor issue with the show syncing feature. I watch several anime shows, which I do not rename, but instead in the advancedsettings.xml I modified my <tvshowmatching> to add regexes that allow these to scrape. I then used the TheTVDB scraper in single season mode to add the videos to the library.

When the episodes sync, these files do not get their play counts updated automatically. Its file name is [Taka]_Naruto_Shippuuden_351_[720p][42DF4776].mp4 which corresponds to Naruto Shippuuden S15E31. Is this a bug or intentional?

I have uploaded all relevant log parts to Pastebin. I'm using Frodo 12.2 on Windows 7 x64 SP1.

Thanks in advance

nate1280 commented 10 years ago

There is no code in the addon that supports absolute numbering, all the syncing code is based upon SxxExx numbering.

Anthirian commented 10 years ago

That explains it. Are there plans to include this in a future version, maybe for a Gotham release? I know the scrobbler does support it.

nate1280 commented 10 years ago

Honestly, it never came up till now.

I suppose I could take a look at it and see what would be involved in adding it.

nate1280 commented 10 years ago

The only trouble I can see is, if data retrieved from trakt.tv is not in absolute format, then there's nothing that can be done for comparison, since that would need to be converted to absolute, and well, it wouldn't know what to convert to absolute and what to keep as SxxExx.

Looking at that show on trakt, it would be presented to the addon as SxxExx data.

nate1280 commented 10 years ago

Scrobbling supports this because it can pass on an episode specific tvdb id.

I can't see any relatively easy way of implementing this, so I won't be pursuing it any further, it would just take way to many calls to get the appropriate data then sort it, etc.

Anthirian commented 10 years ago

That's a shame, I would have liked it. So unless Trakt provides episode specific TheTVDB IDs nothing can be done to sync?

nate1280 commented 10 years ago

Unfortunately not even that, its more complicated.

Fairly certain the sync routines would need to be re-written completely, and specific data would need to be available for consumption from trakt, and posting of data as well. So thats quite a few updates to trakts backend api calls there.

Anthirian commented 10 years ago

Well, nothing to do about it then but manually marking them as watched. If and when you do decide to rewrite the sync routines because of another reason, please keep the absolute numbering in mind?

Thanks anyway.

razzeee commented 9 years ago

@Anthirian can you try again when 3.0.0 is pushed? Not sure if it is fixed, but might be worth a look

Anthirian commented 9 years ago

I just did, but there's still a little bug somewhere regarding imports. I'm running the latest version (a74ced1e9787a6230704bfb6a4b820f0d350ad10) of your repo, not trakt's repo (I didn't know the changes were going to get merged). I'll try again once it's ironed out. Should I switch repos for that?

-->Python callback/script returned the following error<--
 - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.ImportError'>
Error Contents: No module named parser
Traceback (most recent call last):
  File "C:\Users\Geert\AppData\Roaming\Kodi\addons\script.trakt\default.py", line 5, in <module>
    import kodilogging
  File "C:\Users\Geert\AppData\Roaming\Kodi\addons\script.trakt\kodilogging.py", line 19, in <module>
    from utilities import getSettingAsBool
  File "C:\Users\Geert\AppData\Roaming\Kodi\addons\script.trakt\utilities.py", line 11, in <module>
    import dateutil.parser
ImportError: No module named parser
-->End of Python script error report<--
razzeee commented 9 years ago

3.0.0 needs three additional dependencies from my repos. You have to also install these

Anthirian commented 9 years ago

Ok, I installed script.module.trakt, script.module.dateutil and script.module.arrow. The next run I noticed the anime playcounts got sent to Trakt, so that part appears to be working. I haven't tested this on my other pc yet, but I will soon. In the meantime I saw two unhandled exceptions, both regarding timeouts, I thought you should know of.

-->Python callback/script returned the following error<--
 - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'ReadTimeout'>
Error Contents: (ReadTimeoutError("HTTPSConnectionPool(host='api-v2launch.trakt.tv', port=443): Read timed out. (read timeout=24)",),)
Traceback (most recent call last):
  File "C:\Users\Geert\AppData\Roaming\Kodi\addons\script.trakt\sync.py", line 278, in __addEpisodesToTraktWatched
    self.traktapi.addToHistory(s)
  File "C:\Users\Geert\AppData\Roaming\Kodi\addons\script.trakt\traktapi.py", line 167, in addToHistory
    result = Trakt['sync/history'].add(mediaObject)
  File "C:\Users\Geert\AppData\Roaming\Kodi\addons\script.module.trakt\lib\trakt\interfaces\base\__init__.py", line 18, in wrap
    return func(*args, **kwargs)
  File "C:\Users\Geert\AppData\Roaming\Kodi\addons\script.module.trakt\lib\trakt\interfaces\sync\core\mixins.py", line 49, in add
    data=items
  File "C:\Users\Geert\AppData\Roaming\Kodi\addons\script.module.trakt\lib\trakt\core\http.py", line 89, in post
    return self.request('POST', path, params, data, **kwargs)
  File "C:\Users\Geert\AppData\Roaming\Kodi\addons\script.module.trakt\lib\trakt\core\http.py", line 66, in request
    response = self.session.send(prepared, timeout=timeout)
  File "C:\Users\Geert\AppData\Roaming\Kodi\addons\script.module.requests\lib\requests\sessions.py", line 569, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Geert\AppData\Roaming\Kodi\addons\script.module.requests\lib\requests\adapters.py", line 422, in send
    raise ReadTimeout(e, request=request)
ReadTimeout: HTTPSConnectionPool(host='api-v2launch.trakt.tv', port=443): Read timed out. (read timeout=24)
-->End of Python script error report<--
razzeee commented 9 years ago

The part that timeouts will be retried on the next time you sync, so we should be fine here.

Anthirian commented 9 years ago

I have done some more testing with the official repo version. It appears the playcounts are still not updated for absolute numbering. The relevant section of the log file is below. As a reference I also added a previously deleted show back to Kodi, and those do get updated. All in all nothing has changed regarding absolute numbering. Thanks anyway for updating the plugin to 3.0.0.

15:19:40 T:10408   DEBUG: [script.trakt] sync: [Episodes Sync] 2 show(s) have episodes (9) to be added to your Trakt.tv collection.
15:19:40 T:10408   DEBUG: [script.trakt] sync: [Episodes Sync] Episodes added: Naruto Shippuden [tvdb: 79824] - S01E398, S01E396, S01E397, S01E399, S01E402, S01E400, S01E401
15:19:40 T:10408   DEBUG: [script.trakt] sync: [Episodes Sync] Episodes added: Nieuwe Buren [tvdb: 285532] - S01E08, S01E07
15:19:40 T:10408   DEBUG: [script.trakt] sync: [traktAddEpisodes] Shows to add {'shows': [{'seasons': [{'episodes': [{'title': u'1x398. The Night Before the Second Exam', 'ids': {'tvdb': u'5121937'}, 'number': 398, 'watched_at': u'2015-03-07 00:55:21+00:00', 'collected_at': u'2015-02-14 00:20:17+00:00', 'runtime': 0}, {'title': u'1x396. Three Problems', 'ids': {'tvdb': u'5088098'}, 'number': 396, 'watched_at': u'', 'collected_at': u'2015-02-14 00:27:01+00:00', 'runtime': 0}, {'title': u'1x397. The One Fit To Be Leader', 'ids': {'tvdb': u'5088099'}, 'number': 397, 'watched_at': u'2015-03-07 00:55:18+00:00', 'collected_at': u'2015-02-14 00:33:41+00:00', 'runtime': 0}, {'title': u'1x399. Survival in the Desert of Evil', 'ids': {'tvdb': u'5121938'}, 'number': 399, 'watched_at': u'2015-03-07 00:55:24+00:00', 'collected_at': u'2015-02-14 00:40:19+00:00', 'runtime': 0}, {'title': u'1x402. Escape vs. Pursuit', 'ids': {'tvdb': u'5129694'}, 'number': 402, 'watched_at': u'2015-03-07 00:55:39+00:00', 'collected_at': u'2015-03-05 12:17:20+00:00', 'runtime': 0}, {'title': u'1x400. As a Taijutsu User', 'ids': {'tvdb': u'5129692'}, 'number': 400, 'watched_at': u'', 'collected_at': u'2015-02-19 12:26:20+00:00', 'runtime': 0}, {'title': u'1x401. The Resolved One', 'ids': {'tvdb': u'5129693'}, 'number': 401, 'watched_at': u'', 'collected_at': u'2015-02-26 12:17:17+00:00', 'runtime': 0}], 'number': 1}], 'title': u'Naruto Shippuden', 'ids': {'tvdb': u'79824'}, 'year': 2008}]}
15:19:40 T:10408   DEBUG: [script.trakt] requests.packages.urllib3.connectionpool: "POST /sync/collection HTTP/1.1" 201 None
15:19:40 T:10408   DEBUG: [script.trakt] sync: [traktAddEpisodes] Shows to add {'shows': [{'seasons': [{'episodes': [{'title': u'1x08. Aflevering 8', 'ids': {'tvdb': u'4993185'}, 'number': 8, 'watched_at': u'', 'collected_at': u'2015-03-09 14:19:30+00:00', 'runtime': 0}, {'title': u'1x07. Aflevering 7', 'ids': {'tvdb': u'4993184'}, 'number': 7, 'watched_at': u'', 'collected_at': u'2015-03-09 14:16:13+00:00', 'runtime': 0}], 'number': 1}], 'title': u'Nieuwe Buren', 'ids': {'tvdb': u'285532'}, 'year': 2014}]}
15:19:40 T:10408   DEBUG: [script.trakt] requests.packages.urllib3.connectionpool: "POST /sync/collection HTTP/1.1" 201 None
15:19:40 T:10408   DEBUG: [script.trakt] sync: [traktAddEpisodes] Finished with 0 error(s)
15:19:40 T:10408   DEBUG: [script.trakt] sync: [Episodes Sync] Trakt.tv episode collection is clean, no episodes to remove.
15:19:40 T:10408   DEBUG: [script.trakt] sync: [Episodes Sync] 1 show(s) are missing playcounts on Trakt.tv
15:19:40 T:10408   DEBUG: [script.trakt] sync: [Episodes Sync] Episodes updated: Naruto Shippuden [tvdb: 79824] - S01E402, S01E397, S01E398, S01E399
15:19:40 T:10408   DEBUG: [script.trakt] sync: [traktUpdateEpisodes] Shows to update {'shows': [{'seasons': [{'episodes': [{'title': u'1x402. Escape vs. Pursuit', 'number': 402, 'ids': {'tvdb': u'5129694'}, 'watched_at': u'2015-03-07 00:55:39+00:00', 'collected_at': u'2015-03-05 12:17:20+00:00', 'runtime': 0}, {'title': u'1x397. The One Fit To Be Leader', 'number': 397, 'ids': {'tvdb': u'5088099'}, 'watched_at': u'2015-03-07 00:55:18+00:00', 'collected_at': u'2015-02-14 00:33:41+00:00', 'runtime': 0}, {'title': u'1x398. The Night Before the Second Exam', 'number': 398, 'ids': {'tvdb': u'5121937'}, 'watched_at': u'2015-03-07 00:55:21+00:00', 'collected_at': u'2015-02-14 00:20:17+00:00', 'runtime': 0}, {'title': u'1x399. Survival in the Desert of Evil', 'number': 399, 'ids': {'tvdb': u'5121938'}, 'watched_at': u'2015-03-07 00:55:24+00:00', 'collected_at': u'2015-02-14 00:40:19+00:00', 'runtime': 0}], 'number': 1}], 'year': 2008, 'ids': {'tvdb': u'79824'}, 'title': u'Naruto Shippuden'}]}
15:19:40 T:10408   DEBUG: [script.trakt] requests.packages.urllib3.connectionpool: "POST /sync/history HTTP/1.1" 201 None
15:19:40 T:10408   DEBUG: [script.trakt] sync: [traktUpdateEpisodes] Finished with 0 error(s)
15:19:41 T:10408   DEBUG: [script.trakt] sync: [Episodes Sync] 1 show(s) shows are missing playcounts on Kodi
15:19:41 T:10408   DEBUG: [script.trakt] sync: [Episodes Sync] Episodes updated: Nieuwe Buren [tvdb: 285532] - S01E08, S01E07
15:19:41 T:10408   DEBUG: [script.trakt] sync: [Episodes Sync] chunk [{'params': {'playcount': 1, 'lastplayed': '2015-01-08 19:21:55', 'episodeid': 372}, 'jsonrpc': '2.0', 'method': 'VideoLibrary.SetEpisodeDetails', 'id': 0}, {'params': {'playcount': 1, 'lastplayed': '2015-01-08 19:21:55', 'episodeid': 371}, 'jsonrpc': '2.0', 'method': 'VideoLibrary.SetEpisodeDetails', 'id': 1}]
15:19:41 T:10408   DEBUG: CAnnouncementManager - Announcement: OnUpdate from xbmc
15:19:41 T:10408   DEBUG: GOT ANNOUNCEMENT, type: 16, from xbmc, message OnUpdate
15:19:41 T:10408   DEBUG: CAnnouncementManager - Announcement: OnUpdate from xbmc
15:19:41 T:10408   DEBUG: GOT ANNOUNCEMENT, type: 16, from xbmc, message OnUpdate
15:19:41 T:10408   DEBUG: [script.trakt] sync: [Episodes Sync] result None
15:19:41 T:10408   DEBUG: [script.trakt] sync: [Episodes Sync] Shows on Trakt.tv (35), shows in Kodi (36).
15:19:41 T:10408   DEBUG: [script.trakt] sync: [Episodes Sync] Episodes on Trakt.tv (268), episodes in Kodi (278).
15:19:41 T:10408   DEBUG: [script.trakt] sync: [Episodes Sync] Complete.
15:19:41 T:10408   DEBUG: [script.trakt] sync: [Sync] Finished synchronization with Trakt.tv
razzeee commented 9 years ago

The logfile you posted should work, unless the episode number is matching higher than the id. I'll check on that.

razzeee commented 9 years ago

Yeah, we shouldn't send the episode number if we have the id. Will try to fix that later today in the dev branch.

razzeee commented 9 years ago

@tknorris can you tell me from memory if episodes I've added from SALTS/Genesis to my library have episode ids? I would have to create a testcase and that would probably take me some time.

s7eele commented 9 years ago

would it be as simple as a search for 'episodeid' or something similar and looking for an id @razzeee, tk will probably be here before i finish but it cant hurt to look anyway, i have .strm in my library from 1ch, salts and genesis so no problem

contents of .strm file from salts:

plugin://plugin.video.salts/?episode=12&title=Family+Guy&ep_title=Stewie+is+Enceinte&season=13&video_type=Episode&mode=get_sources&dialog=True&year=1999&ep_airdate=2015-03-08&slug=family-guy

contents of .strm file from 1Channel/Primewire:

plugin://plugin.video.1channel/?img=&imdbnum=&url=%2Ftv-2571193-Bobs-Burgers%2Fseason-5-episode-14&title=Bob%27s+Burgers&video_type=episode&mode=GetSources&dialog=1

contents of .strm file from genesis:

plugin://plugin.video.genesis/?action=play&name=The+Blacklist+S02E14&title=T.+Earl+King+VI&year=2013&imdb=2741602&tvdb=266189&season=2&episode=14&show=The+Blacklist&show_alt=The+Blacklist&date=2015-03-05&genre=Action+%2F+Crime+%2F+Drama+%2F+Mystery&url=http%3A%2F%2Fwww.imdb.com%2Ftitle%2Ftt2741602%2F

razzeee commented 9 years ago

thats a start, but we would need the imdbnumber and probably ['uniqueid']['unknown']

s7eele commented 9 years ago

cool, i mostly understand that but i was just talking about whether or not the .strm files had an episode id lol

razzeee commented 9 years ago

Well, sending the correct data to trakt doesn't seem to be the problem. We just have to change everything series related to episode mediaObjects. But it fails prior to that when Kodi is comparing the local data vs the trakt data. I have the same case with an show that uses the dvd order, some will always be marked as "need to be synced". Crap

tknorris commented 9 years ago

SALTS uses slugs for shows and movies, and then adds in the season and episode numbers for episodes.

I'm considering switching SALTS to uses trakt id's instead of slugs due to the occasional issues that using slugs causes. It's a somewhat major undertaking though because even the DB data is stored as slugs.

razzeee commented 9 years ago

Would that mean also for the episode level or just show /movie level?

tknorris commented 9 years ago

My intent would be to use trakt ids for shows and movies, but continue to use Season and Episode #s for episodes because I have to have them to look up videos on the scraper sites.

razzeee commented 9 years ago

So every show will have the air order numbering in case of salts?

tknorris commented 9 years ago

yes, since that's the default on tvdb and trakt, that would be the net result. SALTS is almost exclusively driven by the content on trakt, so Season 5 Epsiode 10 would be whatever this call would return with those values: http://docs.trakt.apiary.io/#reference/episodes/summary/get-a-single-episode-for-a-show

anzerman commented 9 years ago

Hi,

I am hoping this is the right place.. I have some anime that seems to be having an issue with scrobbling with trakt. Specifically episode 59 from Hunter x Hunter, which happens to be the first episode of what TVDB considers the second season.

I have the show added to the Kodi library using absolute order and TVDB as the scraper. Please see the log. http://pastebin.com/YmuVVrNb

Is this something that is still currently in progress at the moment? Or is there something on my end that I need to change?

Cheers.

razzeee commented 9 years ago

Abolute order doesn't work. And will probably not work for months to come. If you use the normal air order you will be fine.

Anthirian commented 9 years ago

I remember it used to work a while back. Someday an update broke this functionality. Why would it be that hard to get it working again?

razzeee commented 9 years ago

Well your last statement in this topic was that is was not working and this ticket is still open. I would have closed this if I knew this was working.

Anthirian commented 9 years ago

Apologies for not being clear. My issue was with the syncing of play counts for absolute numbers. If I understand anzerman correctly, his issue was with scrobbling. This used to work fine, but lately I see that Naruto Shippuuden for example does not scrobble. I have not thoroughly tested this, but it looks like anzerman is seeing similar symptoms.

razzeee commented 9 years ago

Can you try the latest version from https://github.com/Razzeee/script.trakt/tree/dev and send me a new log?

Anthirian commented 9 years ago

I'll try to get around to it next week, but I'm quite strapped for time right now. On Wed 9 Sep 2015 at 13:40 Razzeee notifications@github.com wrote:

Can you try the latest version from https://github.com/Razzeee/script.trakt/tree/dev and send me a new log?

— Reply to this email directly or view it on GitHub https://github.com/trakt/script.trakt/issues/168#issuecomment-138884651.

razzeee commented 3 years ago

So, did you end up testing this?

Anthirian commented 3 years ago

Unfortunately not :(

I actually moved away from Kodi a while ago and now almost exclusively make use of Plex, so my feature request is no longer needed. I would close the ticket but it may still be worthwile to implement, so I'll leave that up to you.