2016-02-19, 22:27
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:
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:
To get information about the status of a ListItem, create a dictionary with one of the three combinations:
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):
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:
Development plans:
download link:
script.module.awshandler-0.1.0.alpha.zip
page on github
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.
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,
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.
download link:
script.module.awshandler-0.1.0.alpha.zip
page on github