Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
674 changes: 674 additions & 0 deletions service.watchedlist/LICENSE.txt

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions service.watchedlist/addon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.watchedlist"
name="WatchedList"
version="1.2.1"
provider-name="schapplm">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
<import addon="script.module.buggalo" version="1.1.3" /> <!-- min. version 1.1.3 for email report -->
<import addon="script.module.myconnpy" version="1.1.7" /> <!-- mySQL Connector for python. Default in XBMC since Frodo -->
<!--<import addon="script.module.pydevd" version="3.4.1"/> --> <!-- Required for remote debugging in Linux -->
<import addon="script.module.dropbox" version="8.4.0"/> <!-- For Dropbox synchronisation -->
</requires>
<extension point="xbmc.python.script" library="manual.py"> <!--Python code for manual start in the addons menu-->
<provides>executable</provides> <!-- Addon is shown under Programs -->
</extension>
<extension point="xbmc.service" library="default.py" start="login" /> <!-- Python code for autostart -->
<extension point="xbmc.python.module" library="lib" /> <!-- entry to access the WatchedList from other addons -->
<extension point="xbmc.addon.metadata">
<summary lang="en_GB">Save watched state of movies and TV-series episodes independent from filenames</summary>
<summary lang="de_DE">Gesehen-Status von Filmen und Serien-Episoden unabhängig von Dateinamen speichern</summary>
<description lang="en_GB">
Export: Searches the Kodi-Database for watched files. Determine imdb-id and thetvdb-id to identify movies and TV-episodes. Then save the list to a new independent table.
Import: Set the watched state for each video file in Kodi.
Automatic background process without user interaction.</description>
<description lang="de_DE">
Export: Durchsucht die Kodi-Datenbank nach gesehenen Filmen und ordnet den Dateien die eindeutigen Kennnummern von imdb und TheTVDB zu. Gesehene Filme und Episoden werden jeweils in einer eigenen Datenbank gespeichert.
Import: Der Gesehen-Status von Medien in Kodi wird aus der Gesehenen-Tabelle geholt.
Die Synchronisierung geschieht automatisch im Hintergrund ohne Benutzereingriff.</description>
<disclaimer lang="en_GB">This script does not regard the file format. A Movie watched in DVD quality will also set the 1080p version as watched.</disclaimer>
<disclaimer lang="de_DE">Dieses Script ignoriert das Dateiformat. Ein gesehener Film in DVD-Qualität wird auch in der BlueRay-Version als gesehen gekennzeichnet.</disclaimer>
<platform>all</platform>
<license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license>
<forum>http://forum.kodi.tv/showthread.php?tid=164652</forum>
<website>http://kodi.wiki/view/Add-on:WatchedList</website>
<email></email>
<source>https://github.com/SchapplM/xbmc-addon-service-watchedlist</source>
</extension>
</addon>
79 changes: 79 additions & 0 deletions service.watchedlist/changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
version 1.2.1 (26.11.2017)
* Fixed Dropbox API: Change from v1 to v2

version 1.2 (21.05.2017)
* Added API and python module to use this addon in other addons
* minor fixes

version 1.1.4 (28.04.2017)
* Fixed error in English language file

version 1.1.3 (16.04.2017)
* Added verbosity option for graphical user notifications
* Added limitation of number of backup files

version 1.1.2 (12.06.2016)
* Added fix to avoid infinite waiting if startup delay time is 0

version 1.1.1 (29.05.2016)
* Added fix for non-working python dropbox import

version 1.1.0 (02.04.2016)
* Added dropbox synchronization for the database

version 1.0.5 (24.12.2015)
* Enabled IPv6 adresses for hostnames

version 1.0.4 (16.05.2015)
* Fixed mysql timestamp bug

version 1.0.3 (11.01.2015)
* Fixed wrong implementation of startup delay
* Fixed missing startup execution if autostart mode is set to periodic

version 1.0.2 (10.01.2015)
* Fixed support for Database file got lost in version 1.0.0

version 1.0.1 (13.12.2014)
* Fixed unwanted waiting time in autostart

version 1.0.0 (01.09.2014)
* Added mySQL Database support for the WatchedList Database

version 0.9.8 (31.08.2014)
* Fix for Unicode Path problems
* Fix for SQLite Error handling

version 0.9.7 (14.06.2014)
* Added custom sleep function to handle requested shutdown in Gotham

version 0.9.6 (23.09.2013)
* Fixed tvshow id with imdb-scraper

version 0.9.5 (18.09.2013)
* Fixed bug in watching user actions

version 0.9.4 (09.09.2013)
* Fixed bug in watching user actions

version 0.9.3 (04.09.2013)
* Fixed minor bugs

version 0.9.2 (01.08.2013)
* Fixed minor bugs

version 0.9.1 (24.06.2013)
* Fixed: Network share problems in Linux

version 0.9.0 (09.06.2013)
* Added: Check watched-states permanently and enable to set media as unwatched

version 0.8.1 (22.05.2013)
* Fixed: Duplicate movies and tv episodes get marked as watched

version 0.8.0 (16.05.2013)
* Fixed: lastplayed-information is now also stored in the database (although it is sometimes missing in XBMC)
* Added: Exceptions are catched with buggalo and bug reports are sent

version 0.7.0 (11.05.2013)
* Initial release
30 changes: 30 additions & 0 deletions service.watchedlist/default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
This file is entry point for automatic start via Kodi
"""

import lib.watchedlist.utils as utils
from lib.watchedlist.watchedlist import WatchedList
import xbmc

__remotedebug__ = False
# Append pydev remote debugger
if __remotedebug__:
utils.log("Initialize remote debugging.")
# Make pydev debugger works for auto reload.
try:
import pydevd
pydevd.settrace('localhost', port=60678, stdoutToServer=True, stderrToServer=True)
except ImportError:
sys.stderr.write("Error: " +
"You must add org.python.pydev.debug.pysrc to your PYTHONPATH.")
utils.showNotification('WatchedList Error', 'remote debug could not be imported.', xbmc.LOGERROR)
sys.exit(1)
except:
utils.showNotification('WatchedList Error', 'remote debug in pydev is activated, but remote server not responding.', xbmc.LOGERROR)
sys.exit(1)

# Run the program
if xbmc.Monitor().waitForAbort(1.5): # wait 1.5 seconds to prevent import-errors. TODO: Is this workaround still necessary?
sys.exit(0) # Abort was requested while waiting.
utils.log("WatchedList Database Service starting...")
WatchedList().runProgram()
Binary file added service.watchedlist/fanart.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added service.watchedlist/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions service.watchedlist/lib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Dummy file to make this directory a package.
1 change: 1 addition & 0 deletions service.watchedlist/lib/watchedlist/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Dummy file to make this directory a package.
105 changes: 105 additions & 0 deletions service.watchedlist/lib/watchedlist/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
"""
This file contains API functions for the usage of WatchedList with other Kodi addons
"""

import xbmc
import time
from watchedlist import WatchedList
import utils

def change_watched_movie(imdb_id, playCount=1, name=''):
"""
Change the watched state of one movie in the WL database

Args:
imdb_id: ID of the movie in the imdb. Format: Integer, numbers after 'tt0012345'
playCount: Unsigned Integer
name: Title of the movie (optional)

Returns:
Error Code (0=No error)
"""

if len(name) == 0:
name = 'tt%d' % imdb_id
if playCount == 0:
lastPlayed=0
else:
lastPlayed=int(time.time())
row_xbmc = [imdb_id, 0, 0, lastPlayed, playCount, name, 0] # 0imdbnumber, 1empty, 2empty, 3lastPlayed, 4playCount, 5title, 6empty, 7movieid
saveanyway = True
commit = True
lastChange = lastPlayed
with WatchedList(True) as WL:
if WL.get_watched_wl(1): # Read the WL database
utils.showNotification(utils.getString(32102), utils.getString(32602), xbmc.LOGERROR)
return 1
WL.wl_update_media('movie', row_xbmc, saveanyway, commit, lastChange)
return 0

def change_watched_episode(tvdb_id, season, episode, playCount=1, name=''):
"""
Change the watched state of one episode in the WL database

Args:
tvdb_id: ID of the tv show in tvdb. Format: Integer
season: Number of the season (Integer) within the show
episode: Number of the episode within the season (Integer)
playCount: Unsigned Integer
name: Name of the Episode (optional)

Returns:
Error Code (0=No error)
"""

if len(name) == 0:
name = 'tvdb%d S%02dE%02d' % (tvdb_id, season, episode)
if playCount == 0:
lastPlayed=0
else:
lastPlayed=int(time.time())
row_xbmc = [tvdb_id, season, episode, lastPlayed, playCount, name, 0] # 0imdbnumber, 1empty, 2empty, 3lastPlayed, 4playCount, 5title, 6empty, 7movieid
saveanyway = True
commit = True
lastChange = lastPlayed
with WatchedList(True) as WL:
if WL.get_watched_wl(1): # Read the WL database
utils.showNotification(utils.getString(32102), utils.getString(32602), xbmc.LOGERROR)
return 1
WL.wl_update_media('episode', row_xbmc, saveanyway, commit, lastChange)
return 0

def change_watched_episodes(tvdb_id, seasons, episodes, playCount, names=[]):
"""
Change the watched state of multiple episodes of one tv show in the WL database

Args:
tvdb_id: ID of the tv show in tvdb. Format: Integer
seasons: Number of the seasons for the affected episodes (list of Integers)
episodes: Number of the episodes within the seasons (list of Integers, same length as seasons list).
playCount: Unsigned Integer
names: Names of the Episodes (optional, list of strings, same length as lists above)

Returns:
Error Code (0=No error)
"""

if playCount == 0:
lastPlayed=0
else:
lastPlayed=int(time.time())
with WatchedList(True) as WL:
if WL.get_watched_wl(1): # Read the WL database
utils.showNotification(utils.getString(32102), utils.getString(32602), xbmc.LOGERROR)
return 1
for i in range(len(seasons)):
row_xbmc_i = [tvdb_id, seasons[i], episodes[i], lastPlayed, playCount, names[i], 0] # 0imdbnumber, 1empty, 2empty, 3lastPlayed, 4playCount, 5title, 6empty, 7movieid
saveanyway = True
if i == len(seasons)-1:
commit = True # Only commit the last row to reduce file access to the database
else:
commit = False
lastChange = lastPlayed

WL.wl_update_media('episode', row_xbmc_i, saveanyway, commit, lastChange)
return 0
Loading