Tuesday, 12 April 2016

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.