Add-on:WatchedList

From Official Kodi Wiki
Revision as of 17:20, 31 January 2015 by Schapplm (talk | contribs) (added image)
Jump to navigation Jump to search

WatchedList
icon.png

See this add-on on the kodi.tv showcase

Author: schapplm

Type: Program
Repo: Kodi.tv repo v21
Kodi.tv repo v20
Kodi.tv repo v19

Summary: Save watched Movies and TV Episodes independent from filenames
Home icon grey.png   ▶ Add-ons ▶ WatchedList

Export: Searches the XBMC-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 xbmc.
Automatic background process without user interaction.

Installing

This add-on is installed from the Add-on browser located in Kodi as follows:

  1. Settings
  2. Add-ons
  3. Install from repository
  4. Program Add-ons
  5. WatchedList
  6. Install

Setup

Basic Settings

  1. Debug mode: Show more notifications, create more entries in kodi.log
  2. Update watched state of movies
  3. Update watched state of episodes
  4. Autorun: starts with XBMC after a delay time of x minutes.
  5. Startup delay (see above x). Set the delay time to not disturb directly at startup.
  6. 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.
  7. Update interval (active if set to 'periodic' above)
  8. Follow user ...: Run in background and update the watchedlist database every time the user changes a watched state
  9. Progress dialog: Show a progress bar for every full update. No user interaction possible in this time.

Basic Settings

Database Settings

  1. 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.
  2. DB File: Use a non-default database file (not in [...]/userdata/addon_data/service.watchedlist)
  3. 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".
  4. DB File: Filename of the database (SQLite .db file)
  5. 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).
  6. MySQL: IP-adress of the Server. Make sure, there is a mysql server running. To start, use [MySQL/Setting_up_MySQL this] guide.
  7. MySQL: 3306 is the default mysql port. No need to change it.
  8. MySQL: Name of the database. You manually need to create this database on the mysql server (use phpMyAdmin)
  9. MySQL: Username. This user must exist and have all necessary permissions on the database set before
  10. MySQL: password for this user.


Basic Settings

Useage

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. Then newly watched movies and tv episodes are written to the addon database (Remember): After that, media that is not watched in the XBMC database and was previously marked as watched by the addon is again marked as watched in XBMC.

Database

MySQL Database

The mySQL database stores all relevant information. It looks like this: For the description of the tables read below.

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.

https://sourceforge.net/projects/sqlitebrowser/files/latest/download

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.

Conversion from SQLite database to mysql database

In Version 1.0.0 of this addon, I added the possibility to use a mysql database, which 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:

  1. open the old database file in SQLite database browser
  2. File -> Export -> Database to sql file
  3. bring this into the new format. For Replacement, I used Notepad++ in Windows:
  4. 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)\),"
  5. 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)\)\)"
  6. Save this new sql file
  7. 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.