|Need help with this add-on? See here.|
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.
To install this add-on you must do so from the Add-on manager from within Kodi by going to:
- Install from repository (v15/v16) / Get add-ons (v14)
- Kodi add-on repository
- Program Add-ons
2.1 Basic Settings
- Debug mode: Show more notifications, create more entries in kodi.log
- Update watched state of movies
- Update watched state of episodes
- Autorun: starts with XBMC after a delay time of x minutes.
- Startup delay (see above x). Set the delay time to not disturb directly at startup.
- Autostart mode: 'one update' only does one full update of the watchedlist and then quits. 'periodic' executes this update in the interval given below. 'no update' does no full update. You have the possibility to run WatchedList in background.
- Update interval (active if set to 'periodic' above)
- Follow user ...: Run in background and update the watchedlist database every time the user changes a watched state
- Progress dialog: Show a progress bar for every full update. No user interaction possible in this time.
2.2 Database Settings
- DB Method: Either use a SQLite db file or a mysql server for the database of this addon. I recommend a mysql database, since there were problems with the SQLite database file consistency since XBMC v13. The default setting is a local SQLite db file. This is suitable for backup of the local watched states in case of file movements or Kodi database cleaning.
- DB File: Use a non-default database file (not in [...]/userdata/addon_data/service.watchedlist)
- DB File: Path to the database-file. To add a network path for access from multiple clients you can browse the path in xbmc or edit this value manually in the "%appdata%\XBMC\userdata\addon_data\service.watchedlist\settings.xml".
- DB File: Filename of the database (SQLite .db file)
- DB File: Create a zip backup copy (ca. 40 KB) of the database (ca 100 KB) each time before writing it. With this you can restore any state you want, e.g. when you mess with your kodi-database and too much media is marked as watched. On the contrary the directory will be filled with new files on every change to the WL-DB (no file Rotation, drive space).
- MySQL: IP-adress of the Server. Make sure, there is a mysql server running. To start, use [MySQL/Setting_up_MySQL this] guide.
- MySQL: 3306 is the default mysql port. No need to change it.
- MySQL: Name of the database. You manually need to create this database on the mysql server (use phpMyAdmin)
- MySQL: Username. This user must exist and have all necessary permissions on the database set before
- MySQL: password for this user.
This addon runs in the background as a service. There is no interaction with the user. The script only gives messages about the current operation
- After Startup, the databases are searched for watched-information (Notification 1).
- Then newly watched movies and tv episodes are written to the addon database (Notification 2).
- After that, media that is not watched in the Kodi database and was previously marked as watched by the addon is again marked as watched in Kodi ( Notifications 3 and 4).
2.4.1 MySQL Database
The mySQL database stores all relevant information. It looks like this:
For the description of the tables read below.
2.4.2 SQLite Database file
The SQLite Database file option is no longer recommended. To transfer an existing SQLite WatchedList? Database, read below.
The script creates a SQLite database. To view the database I used SQLite Database Browser.
This figure shows the SQLite db file with automatically created backup copies.
The database has three tables.
The first table stores the watched movies by imdb-number. The title column is only for easier user access to the table.
The second table stores watched tv episodes with unique number for the TV Show (this field is called imdbnumber in XBMC, but this is the TheTVDB number). The names of the tv shows are stored in a third table, only for better readability.
2.4.3 Conversion from SQLite database to mysql database
In Version 1.0.0 of this addon, the possibility to use a mysql database was added. This has a few advantages over the SQLite Database file:
- simultaneous access possible
- mysql handles all the database access, therefore no permanent backup copying necessary
- no filesystem access in the addon. Should lead to fewer errors
How to convert the database from SQLite db file to mysql:
- open the old database file in SQLite database browser
- File -> Export -> Database to sql file
- bring this into the new format. For Replacement, I used Notepad++ in Windows:
- Replace regular expression
"INSERT INTO movie_watched VALUES\((\d+),(\d+),(\d+),(\d+),"with
"INSERT IGNORE INTO movie_watched VALUES\((\1),(\2),FROM_UNIXTIME\((\3)\),FROM_UNIXTIME\((\4)\),"
- Replace regular expression
"INSERT INTO episode_watched VALUES\((\d+),(\d+),(\d+),(\d+),(\d+),(\d+)\)"with
"INSERT IGNORE INTO episode_watched VALUES\((\1),(\2),(\3),(\4),FROM_UNIXTIME\((\5)\),FROM_UNIXTIME\((\6)\)\)"
- Replace regular expression
- Save this new sql file
- execute the commands in the "INSERT"-commands in the sql query interface in phpmyadmin after the tables were generated at the first start of the watchedlist addon with mysql option enabled.
3 Technical Details
The XBMC Database is queried and updated with JSON-RPC. It should not matter whether you use xbmc mysql or xbmc local database.
The watched-status is only stored based on imdb/thetvdb number. Different Versions of a movie (DVD, BlueRay, Extended Edition, Directors Cut) are all considered equally watched.
- Online List of watched movies
- http://code.google.com/p/xbmc-follwit/ (Last update April 2012, probably not Frodo-compatible)
- separate script to scan xbmc library (probably not executable from within xbmc)
- other similar addons
- http://code.google.com/p/xbmc-watched-data/ (defect in Frodo?)
- http://forum.kodi.tv/showthread.php?tid=129448&pid=1401643#pid1401643 (working in Frodo, a little bug, because comparison of names instead of unique numbers)
- Export watched flag in nfo file and Import it back again:
6 Feedback and Discussion
In case of errors or questions, please post them in the forum thread.