Skip to content

Action: togglewatched

Razzeee edited this page Jun 24, 2015 · 3 revisions

Overview:

Since Kodi's python interface does not offer an event that triggers when an item's playcount changes, this adds a wrapper around Kodi's built in action ToggleWatched action.

Supported Methods:

There is only one way to use this:

RunScript(script.trakt,action=togglewatched)

Information:

This new action, will ever only work on library items, consider it an extension of the sync features of the trakt script.

Best usage for this, would be to add the following to your keyboard.xml or via an context addon.

<keymap>
  <MyVideoLibrary>
    <keyboard>
      <w>RunScript(script.trakt,action=togglewatched)</w>
    </keyboard>
  </MyVideoLibrary>
</keymap>

This will override Kodi's default action for W causing a ToggleWatched in the video library.

This works on all levels of the video library, movie, show, seasons, and episodes.

When an item or items are successfully marked as watched, a notification will popup indicating this.

How it works

  • For movies and episodes, it gets the item's playcount and other relevant data.
  • For seasons, it will get the playcounts of all the items in the selected season, and add episodes to a list if there playcount is 0.
  • For shows, you guessed it, it will get data for all the episodes, and add those episodes whose playcount is 0 to a list.
  • If nothing has a playcount of 0, it skips dispatching to the service thread. Otherwise, it dispatches a new action to the scripts service thread with the data gathered above.
  • It will now execute ToggleWatched on the item, so Kodi does its normal thing here.
  • The service thread will take the data it got and lookup information on trakt (movies only) and mark those as watched.

Original Pull Request

https://github.com/rectifyer/script.trakt/pull/108