Skip to main content

Preserving 'Watched State' when re-organising your Kodi Library

I have lots of friends with various Kodi devices (NUC, Pi, Zbox etc.) and most with Synology NAS boxes but unfortunately, many also with media libraries that are a mess. Asked to get a house with three Kodi devices onto one central Synology based database, I wanted a way to export the media library preserving the watched state and another way to organise the media into separate folders.


Having done it before with two Pi's but with a library that already had movies in separate folders (recommended), I wanted to test a way to do this when my friend had all their movies in one folder and then to bring them back in to all three devices but with the library organised correctly and the watched state preserved.

If you are going to use a central SQL database, all Kodi versions must be the same release but I it it OK to have say 15.1 and 15.2 on the same database.

  1. Export the video library in the master Kodi device (one with most up-to-date library) choosing separate files, YES to 'Export thumbnails and Fanart' and NO to actor thumbs (as these would also be placed in one folder called .actors which is a bit difficult to deal with).
  2. The export process will create .NFO files (containing the embedded watched state) along with all other artwork. If the movies are in one big folder as mine were, the artwork and .NFO will automatically be renamed with the movies name appended to the beginning of the file name
  3. Install 'Ember Media Manager', tell it where your movie library is and accept all the default options proceeding with >next every time until it's ready to go. Your movies should now be in the Ember database.
  4. Under 'Tools', select 'Sort Files into Folders', tell it where the root directory for your movies is under 'Path to Sort' and push 'Go'. In a few seconds, your .NFO, Movie and artwork files will all be in their own folders. Great!
  5. Modify the advancedsettings.xml on all of your Kodi devices to include the following:
    <advancedsettings>
    <videolibrary>
            <importwatchedstate>true</importwatchedstate>
            <importresumepoint>true</importresumepoint>
          </videolibrary>
    </advancedsettings>
  6. Wipe the library from each device by deleting the TVxx.db and MyVideosx.db from Userdata/Database (easiest way to clean database!).
  7. Reboot
  8. Under Video > Files > Add videos... point to your new media library and choose the option "Movies are in separate folders..." when you set the content for your directory. Your movies will now be imported without scraping the Internet as the .NFO files will be read from each movie folder and the 'watched state' and resume point (exported in Step 1) will be restored.

Comments

Popular posts from this blog

Using ESPEasy with Home Assistant via MQTT

Preface: I've just started playing around with Home Assistant on a Raspberry Pi and exploring the world of MQTT to control devices on the network. Learning curve is a bit steep but worth the effort as MQTT is very fast. The hardware and software tools I'm using are as follows: 2 x Sonoff relay units 2 x NodeMCU Boards ESPEasy firmware (must be version 121 or above as that contains the MQTT 'retain' flag option. Home Assistant software on Raspberry Pi2 MQTT Test Software: PC: MQTT.fx Android: MQTT Dashboard

My Notepad++ tricks when editing YAML files in Home Assistant

To comment out a whole section in one go: Highlight the text you want to comment out and use CTRL + Q. If you do this at the start of a line, it will only comment that line. CTRL + Q is toggle mode (comment on/off). CTRL + K will allow you to add multiple comments one after the other.

How to check what entities are filling up your Home Assistant database

If you use the Home Assistant MariaDB add-on, this tip will show you how to query the database so see what Home Assistant entity states are triggering the most, filling up your database. What were going to do: Install the phMyAdmin add-on for MariaDB. Query the MariaDB database. See what entity state changes have the most action. Paste the code below into the SQL query box:  select entity_id,count( * ) from states group by entity_id order by count ( * ) desc; And if you're using the internal home-assistant_v2.db instead, you can use the SQLite Web add-on to achieve the same thing.