Kodi Community Forum
[RELEASE] Trakt Utilities (addon for Trakt.tv usage) - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Program Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=151)
+---- Thread: [RELEASE] Trakt Utilities (addon for Trakt.tv usage) (/showthread.php?tid=98582)



RE: [RELEASE] Trakt Utilities (addon for Trakt.tv usage) - Martijn - 2012-08-30

(2012-08-30, 22:36)seadog Wrote:
(2012-08-30, 21:32)Martijn Wrote:
(2012-08-30, 21:31)seadog Wrote: I think I'll try filing a bug report with xbmc, since I believe it's a bug in the JSON RPC, though I could be wrong

Could also be the progressdialog that hangs.
Be sure to use a official nightly build and provide the crashlog +debug log when filing a trac ticket

I just added a print after the executejsonrpc call to test this, what happens is that (as far as I can tell), I send the episodes to be updated over json rpc, they're being updated but then "CRecentlyAddedJob::UpdateTotal() - Running RecentlyAdded home screen update" hits and the executejsonrpc call never returns (as the thing I'm printing after the call never makes it to the logfile), do you think I should file this as a bug?
jup.
XBMC shouldn't hang
Give detailed instruction on how to reproduce in the ticket



RE: [RELEASE] Trakt Utilities (addon for Trakt.tv usage) - seadog - 2012-09-01

SpoBo how many episodes are you trying to set as seen on XBMC with the sync? I've set ~5000 episodes and I only get 1 hang per total sync, if I then kill xbmc and sync again it all goes through and after that it's not a problem anymore (though I need to add some more error checking and nice information code)


RE: [RELEASE] Trakt Utilities (addon for Trakt.tv usage) - SpoBo - 2012-09-01

About 3500. crashes all the time. Ubuntu 11.10 and XBMC nightlies https://launchpad.net/~nathan-renniewaldock/+archive/xbmc-nightly.

I'll try the most recent code soon.


RE: [RELEASE] Trakt Utilities (addon for Trakt.tv usage) - seadog - 2012-09-02

OK I just did 3 complete syncs with my new change I just pushed (basically just adding a couple of sleeps which is a bit ugly), and I can't get it to hang on sync any more, so hopefully that's an acceptable workaround for now


RE: [RELEASE] Trakt Utilities (addon for Trakt.tv usage) - SpoBo - 2012-09-02

It works!!! Thx man Smile

I'm assuming you only start the sleep after X items have been marked as seen? That way it works fast when there is no work?

Can you do the same thing for movies? It hangs as well for me :x But less frequent than the tv shows.

edit: trying movies now. seems to be working. hung around 70%.


RE: [RELEASE] Trakt Utilities (addon for Trakt.tv usage) - seadog - 2012-09-02

OK I'll add a sleep for the movies, seems to be some sort of race condition I think then, hopefully the xbmc devs can hunt down the problem

Nearly finished re-adding eden support which has turned out to be an... interesting experience to say the least

Just pushed it into develop (I merged the frodo branch with develop)

As for the sleep I'm just sleeping 0.2s before and after a json rpc call, since I'm only doing one call per show or per movie it doesn't slow down the process much at all (since the json calls themselves take longer)


RE: [RELEASE] Trakt Utilities (addon for Trakt.tv usage) - SpoBo - 2012-09-04

Ok makes sense. I hopped over to OpenELEC (sort of tired with Ubuntu crashing out all the time) which is still on Eden. I tested your script. Works beautifully Wink For TV Shows & Movies. Thx for all your hard work. The reason I use trakt is not the social aspect but a backup in the cloud of the stuff I have watched. So beeing able to sync it back to my box is crucial for me Big Grin


You mention re-adding eden support as an interesting experience. well ... you could make it cleaner by instantiating a handler object that knows how to do the action specific for the version of XBMC. You'd have 2 classes. PreFrodoHandler and FrodoHandler. Both classes contain implementationdetails for functions like setXBMCMoviePlaycount but just for their specific version. At the start of the script you check the XBMC version and set a handler variable to to the right class/instance. After that your code just has to deal with 'handler.setXBMCMoviePlaycount' and you don't have to worry about Frodo or Pre-Frodo Wink So no if statements everywhere. The handler knows how to handle what you want :p

In addition, if they ever change the implementation again it's as easy as creating a new Handler class or inheriting and overriding parts of an existing handler.

Hope that made sense? ;o

edit:

Another addition could be the addition of a JSONrpcCall function. Just have it accept the same functions as xbmc.executeJSONRPC and inside your new function call xbmc.executeJSONRPC with the received arguments. But before and after do the 0.2s sleep. If you use that new function everywhere in your code instead of the xbmc one it'll be very easy later on to remove the 2 sleep calls everywhere as soon as they fixed their API. And this function would only have to be present and used in the FrodoHandler.

Just handing out best practices here. Do with it what you will Smile


RE: [RELEASE] Trakt Utilities (addon for Trakt.tv usage) - seadog - 2012-09-04

I use the addon in the exact same way, I don't use all the watch list stuff either (though I do use the rating code sometimes), I just re-added my advanced rating support patches too.

My plan at the moment is to finish the last few of features on my todo list then create a release candidate people can use easily, then hopefully do a first release. Then I'm going to refactor the rest of the code (for example the utilities file really shouldn't exist) since I assume people would prefer the last few things on my list (fix sync on startup, add clean tv option, add sync on startup popups and fix the get current rating code for the rating popups) than cleaner code that they almost certainly won't look at anyway


RE: [RELEASE] Trakt Utilities (addon for Trakt.tv usage) - Martijn - 2012-09-04

my advice is to don't bother with the version check and just aim for Frodo.
you can specify the minimal xbmc.addon version from which this will work.


RE: [RELEASE] Trakt Utilities (addon for Trakt.tv usage) - seadog - 2012-09-04

(2012-09-04, 20:35)Martijn Wrote: my advice is to don't bother with the version check and just aim for Frodo.
you can specify the minimal xbmc.addon version from which this will work.

The code to support eden's only about 60 lines and most of that's hidden away from view anyway so I don't really mind leaving it in, but I'm removing it as soon as frodo is stable.


RE: [RELEASE] Trakt Utilities (addon for Trakt.tv usage) - tripkip - 2012-09-04

Failed to sync watched movies. Debugging for the addon enabled. This is what I get:

Code:
21:16:05 T:2958716928  NOTICE: Trakt Utilities: service: script.TraktUtilities - version: 0.6.4
21:16:09 T:2958716928  NOTICE: Trakt Utilities: trakt json url: /account/test/48dfcb4813134da82152984e8c4f329bc8b8b46a
21:16:10 T:2958716928  NOTICE: Trakt Utilities: autostart sync seen movies
21:16:10 T:2958184448  NOTICE: Trakt Utilities: [Notification Service] Waiting~
21:16:10 T:2958716928  NOTICE: Trakt Utilities: trakt json url: /user/library/movies/all.json/48dfcb4813134da82152984e8c4f329bc8b8b46a/tripkip
21:16:15 T:2958716928   ERROR: Error Type: <type 'exceptions.ValueError'>
21:16:15 T:2958716928   ERROR: Error Contents: time data u'' does not match format '%Y-%m-%d %H:%M:%S'
21:16:15 T:2958716928   ERROR: Traceback (most recent call last):
                                              File "/Users/Pieter/Library/Application Support/XBMC/addons/script.TraktUtilities/service.py", line 67, in <module>
                                                autostart()
                                              File "/Users/Pieter/Library/Application Support/XBMC/addons/script.TraktUtilities/service.py", line 50, in autostart
                                                syncSeenMovies(True)
                                              File "/Users/Pieter/Library/Application Support/XBMC/addons/script.TraktUtilities/sync_update.py", line 577, in syncSeenMovies
                                                movies_seen.append({'imdb_id': imdbid, 'title': xbmc_movies[i]['originaltitle'], 'year': xbmc_movies[i]['year'], 'plays': xbmc_movies[i]['playcount'], 'last_played': int(time.mktime(time.strptime(xbmc_movies[i]['lastplayed'], '%Y-%m-%d %H:%M:%S')))})
                                              File "/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/_strptime.py", line 454, in _strptime_time
                                                return _strptime(data_string, format)[0]
                                              File "/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/_strptime.py", line 325, in _strptime
                                                (data_string, format))
                                            ValueError: time data u'' does not match format '%Y-%m-%d %H:%M:%S'



RE: [RELEASE] Trakt Utilities (addon for Trakt.tv usage) - seadog - 2012-09-04

(2012-09-04, 21:17)tripkip Wrote: Failed to sync watched movies. Debugging for the addon enabled. This is what I get:

Code:
21:16:05 T:2958716928  NOTICE: Trakt Utilities: service: script.TraktUtilities - version: 0.6.4
21:16:09 T:2958716928  NOTICE: Trakt Utilities: trakt json url: /account/test/48dfcb4813134da82152984e8c4f329bc8b8b46a
21:16:10 T:2958716928  NOTICE: Trakt Utilities: autostart sync seen movies
21:16:10 T:2958184448  NOTICE: Trakt Utilities: [Notification Service] Waiting~
21:16:10 T:2958716928  NOTICE: Trakt Utilities: trakt json url: /user/library/movies/all.json/48dfcb4813134da82152984e8c4f329bc8b8b46a/tripkip
21:16:15 T:2958716928   ERROR: Error Type: <type 'exceptions.ValueError'>
21:16:15 T:2958716928   ERROR: Error Contents: time data u'' does not match format '%Y-%m-%d %H:%M:%S'
21:16:15 T:2958716928   ERROR: Traceback (most recent call last):
                                              File "/Users/Pieter/Library/Application Support/XBMC/addons/script.TraktUtilities/service.py", line 67, in <module>
                                                autostart()
                                              File "/Users/Pieter/Library/Application Support/XBMC/addons/script.TraktUtilities/service.py", line 50, in autostart
                                                syncSeenMovies(True)
                                              File "/Users/Pieter/Library/Application Support/XBMC/addons/script.TraktUtilities/sync_update.py", line 577, in syncSeenMovies
                                                movies_seen.append({'imdb_id': imdbid, 'title': xbmc_movies[i]['originaltitle'], 'year': xbmc_movies[i]['year'], 'plays': xbmc_movies[i]['playcount'], 'last_played': int(time.mktime(time.strptime(xbmc_movies[i]['lastplayed'], '%Y-%m-%d %H:%M:%S')))})
                                              File "/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/_strptime.py", line 454, in _strptime_time
                                                return _strptime(data_string, format)[0]
                                              File "/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/_strptime.py", line 325, in _strptime
                                                (data_string, format))
                                            ValueError: time data u'' does not match format '%Y-%m-%d %H:%M:%S'

Looks to me like you're using the "master" branch, you need to go to the develop branch: https://github.com/seadog/script.traktutilities/tree/develop make sure you uninstall the currently installed version you have properly (remove it from the addon menu, close xbmc, delete .xbmc/packages/addon/script.traktutilities/(whatever).zip, then restart xbmc, install the develop version from a zip file then restart xbmc again, I'll fix the terrible "install new version" behavior once I've added the last features to be able to release a "proper" version.

edit: hit the wrong posts quote button


RE: [RELEASE] Trakt Utilities (addon for Trakt.tv usage) - tripkip - 2012-09-04

(2012-09-04, 21:37)seadog Wrote: Looks to me like you're using the "master" branch, you need to go to the develop branch: https://github.com/seadog/script.traktutilities/tree/develop make sure you uninstall the currently installed version you have properly (remove it from the addon menu, close xbmc, delete .xbmc/packages/addon/script.traktutilities/(whatever).zip, then restart xbmc, install the develop version from a zip file then restart xbmc again, I'll fix the terrible "install new version" behavior once I've added the last features to be able to release a "proper" version.

edit: hit the wrong posts quote button

Code:
21:43:08 T:2958716928  NOTICE: -->Python Interpreter Initialized<--
21:43:08 T:2958716928   ERROR: /Users/Pieter/Library/Application Support/XBMC/addons/script.trakt/utilities.py:19: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
                                              import sha # Python 2.5 and earlier
21:43:32 T:2958184448   ERROR: Error Type: <type 'exceptions.UnboundLocalError'>
21:43:32 T:2958184448   ERROR: Error Contents: local variable 'progress' referenced before assignment
21:43:32 T:2958184448   ERROR: Traceback (most recent call last):
                                              File "/Users/Pieter/Library/Application Support/XBMC/addons/seadog-script.traktutilities-96835d9/service.py", line 71, in <module>
                                                autostart()
                                              File "/Users/Pieter/Library/Application Support/XBMC/addons/seadog-script.traktutilities-96835d9/service.py", line 40, in autostart
                                                su.syncMovies(daemon=True)
                                              File "/Users/Pieter/Library/Application Support/XBMC/addons/seadog-script.traktutilities-96835d9/sync_update.py", line 108, in syncMovies
                                                _updateXBMCMoviePlaycounts(xbmc_playcount_update, progress, daemon)
                                            UnboundLocalError: local variable 'progress' referenced before assignment



RE: [RELEASE] Trakt Utilities (addon for Trakt.tv usage) - seadog - 2012-09-04

Are you using the auto sync on startup feature? I've just added a new commit that should solve that error for movies (but don't use autosync for TV yet, I'm re-adding that feature later tonight) and as far as I know there aren't any autosync pop ups yet (doing that later tonight again)


RE: [RELEASE] Trakt Utilities (addon for Trakt.tv usage) - tripkip - 2012-09-04

(2012-09-04, 22:00)seadog Wrote: Are you using the auto sync on startup feature? I've just added a new commit that should solve that error for movies (but don't use autosync for TV yet, I'm re-adding that feature later tonight) and as far as I know there aren't any autosync pop ups yet (doing that later tonight again)

I tried again with your latest commits in place (ca91c1d884784e77afb0ba89ca73a8183ee45d4a) but same error still. I only checked movies sync.

Code:
22:02:50 T:2957651968   ERROR: Error Type: <type 'exceptions.UnboundLocalError'>
22:02:50 T:2957651968   ERROR: Error Contents: local variable 'progress' referenced before assignment
22:02:50 T:2957651968   ERROR: Traceback (most recent call last):
                                              File "/Users/Pieter/Library/Application Support/XBMC/addons/seadog-script.traktutilities-ca91c1d/service.py", line 71, in <module>
                                                autostart()
                                              File "/Users/Pieter/Library/Application Support/XBMC/addons/seadog-script.traktutilities-ca91c1d/service.py", line 40, in autostart
                                                su.syncMovies(daemon=True)
                                              File "/Users/Pieter/Library/Application Support/XBMC/addons/seadog-script.traktutilities-ca91c1d/sync_update.py", line 111, in syncMovies
                                                _updateXBMCMoviePlaycounts(xbmc_playcount_update, progress, daemon)
                                            UnboundLocalError: local variable 'progress' referenced before assignment