Alpha Addon Watchstates Handler module
#1
Addon Watchstates Handler

Module addon for Kodi enables storing of watchstates (watched/partially watched) for video addons separately from Kodi DB.

First, the reason for the creation of this module. Generally, Kodi stores above watchstates, identifing them by paths (links) or virtual paths. Links, in reality, may be changed over time on sites that may also change the virtual paths in addons. This module maintains the above watchstates, identifying them by one of the following combinations:
  • a title,
  • a combination of title / season number / series number,
  • a combination of title / season number / series title or release date.
The first option is suitable for movies or any video clips. Second - for the TV series. The third - for the TV series, when the series number is not specified, but we know only the title or release date of the series.

This module can be used by installing it in parallel with the addon, or by including it as an internal library. (Note: The second option I have not tested yet). Other advantages, in addition to the immutability of the watchstates marks with the time, is the sharing of watchstates DB among addons using the module, and saving those marks when cleaning the Kodi library.

At this time, there is a necessary condition for the use of the module: the importing addons must use setResolvedUrl function for video playback. This is due to this function correctly maintains the watchstates marks of viewing videos using the virtual paths in Kodi DB. Since the module is not the service-addon, it must use this information to then associate it with the above-described combinations.

Usage:

The following instruction explains how to embed and use the module in an addons.
First import and initialize the module:
Code:
import AWSHandler
AWSHandler.InitDB()

To get information about the status of a ListItem, create a dictionary with one of the three combinations:
  • a title,
  • a combination of a title / season number / series number,
  • a combination of a title / season number / series title or release date,
and request for watchstate information:
Code:
info = {'title': title, 'season': season, 'episode': episode, 'episode_info': episode_info}
res = AWSHandler.CheckWS(info)

here, title - is unicode-string with the movie or TV show title,
episode_info - unicode-string with the title of a series or a series release date,
season and episode - integer or string with the season number and the series number. Season number can be not specified (i.e, if the season is not known, it is better not to specify it, because season 1 will have a different identifier).

Set the watchstate mark (in the next releases I plan to move it inside the module):
Code:
if res:
    if res['wflag']: listitem.setInfo(type = 'video', infoLabels = {'playcount': 1, 'overlay': 5})
    else:
        listitem.setProperty('ResumeTime', res['resumetime'])
        listitem.setProperty('TotalTime', res['totaltime'])

When playback is started, add the above-described combination 'info' for ListItem into the update queue. This can be done both before and after running. After is better, as this will not waste time at playback startup:
Code:
xbmcplugin.setResolvedUrl(h, True, listitem)
AWSHandler.QueueWS(info)

Development plans:
  • Add an interface for importing another DB.
  • Add an interface to manage watchstates, including the ability to specify alternative names (aliases) of movies / TV series.
  • Add the possibility to process ListItem in CheckWS(), setting the mark automatically.
  • Add CheckWSMany() function for processing of ListItems array.
  • Move the excessive log messages into the debug mode.
The module was tested by me, but it is on alpha-stage because not all functions from the development plans are implemented yet. (Also, because it is intended for all platforms, but tested on win7 only by now.)

download link:
script.module.awshandler-0.1.0.alpha.zip
page on github
Reply
#2
(2016-02-19, 22:27)kit500 Wrote: Addon watchstates handler
Thanks for this project, I would like to help...

I was planning on the same type of project, you beat me to it Wink

I'd like to suggest you use some of the standard Kodi setinfo labels and extend variables to include imdb,tvdb ids Smile

http://mirrors.kodi.tv/docs/python-docs/...em-setInfo
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#3
Thanks for the reply and for the suggestion.
imdb,tvdb can it handle the resume time? Smile

edit:

I was misunderstood initially.
At current time I don't plan to include another ids, thereto identifying by infolabels is looks too complex.
Reply

Logout Mark Read Team Forum Stats Members Help
Addon Watchstates Handler module0