perform action when a video is watched - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: perform action when a video is watched (/showthread.php?tid=193790) |
perform action when a video is watched - damonbrodie - 2014-05-02 Hi, I'd like to perform an action on a remote server then a video is mark watched. I've written python before - looks straightforward to write an addon. So it looks to me like the right way is to subclass the player, and take action on onplaybackstopped. From there, figure out what video was just being watched, and then check the database to see if the watched flag is set (i.e. the user watched the video to the end and now the watched flag is set. Does this sound like the right path forward, or is there a better way to do this? Thanks! Damon RE: perform action when a video is watched - Martijn - 2014-05-02 sounds right example https://github.com/XBMC-Addons/service.skin.widgets/blob/master/default.py#L249 onPlayBackEnded and onPlayBackStopped are separate so should tell you if they actually finished it. if playback was stopped at ~90% (or something) it will still mark it as watched. RE: perform action when a video is watched - damonbrodie - 2014-05-02 Martijn, That's perfect - exactly what I needed! RE: perform action when a video is watched - damonbrodie - 2014-05-02 Looking at the infotagvideo I don't see the watched status among the listed elements (but lastplayed is there). Is the watched flag stored elsewhere? RE: perform action when a video is watched - Martijn - 2014-05-02 you need to do a JSON-RPC request to get that. as you have last played you can easily get the specifics for that video RE: perform action when a video is watched - damonbrodie - 2014-05-03 Looks like a much cleaner way is for the add-on to simply capture the VideoLibrary.OnUpdate json notifications. RE: perform action when a video is watched - damonbrodie - 2014-05-03 This is the code I have for subclassing Monitor. Any ideas why this doesn't work? Similar code worked for subclassing Player. PHP Code: import xbmc RE: perform action when a video is watched - damonbrodie - 2014-05-03 Answering this myself for future searches. onDatabaseUpdated does not run when the playcount (watched) is incremented. At least not in Frodo. RE: perform action when a video is watched - User 189010 - 2014-05-06 onDatabaseUpdated will only be called when database gets updated and the DB has been changed. You can do this with the json notification VideoLibrary.OnUpdate and a tcp connection to xbmc's json port (default 9090). Then you can receive a notification when the watchedstate has been changed (maually/automatically) in xbmc You can find an example for the tcp connection in the repository of the german community xbmcnerds http://www.xbmcnerds.com/index.php?page=DownloadDBData&dataID=100 in the service.nfo.watchedstate.updater addon This addon writes the current watchedstate into the nfo files when the watchedstate has been changed in xbmc. Ok, this is not exactly what you are looking for, but the approach is the same RE: perform action when a video is watched - damonbrodie - 2014-05-06 And this is even easier in 13. There is a new Monitor.onNotification you can use. This is the code I ended up with: PHP Code: import xbmc |