Kodi Community Forum

Full Version: Clean Library taking too long after source change (backup Kodi viewed movies status)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone,
I'm having a problem with the "Clean Library" function and I hope you can help me saving some time. 

This is the issue: doing a "Clean Library" takes really a lot of time, more than 30 minutes (and during the process Kodi in unresponsive).

I'm using Kodi 17.6 on an Android 6.0 Probox2 Air TV box, connected to a WD MyCloud EX2 Ultra NAS.
I've only two sources, Film and TV Series, that are two different folders on NAS.
The problem started when I changed my router, changed IP to the NAS and changed the communication protocol of my Kodi sources from NFS to SMB. To achieve that, I exported my library, searched and replaced in videodb.xml all occurences of old sources with new ones, than deleted old sources on Kodi (and so removing the whole old library, I suppose), imported the new modified library and manually re-added the sources using SMB.

I've already tried to rollback as much as I can but it has been useless: I exported the library, modified it back from SMB to NFS, re-imported the library, re-added the sources using NFS. Nothing changed.

My questions are:
01) Is there an easy way to fix this?
If there's too much work to do, I would prefer to re-create the library from scratch.

02) Is there an official procedure to follow for this kind of migrations?
I mean, if I have to change an USB drive source and so its name changes or if I change IP or protocol to my NAS.

03) How can I re-create my library from scratch without losing the status of my viewed items?

I've already read a lot of similar threads but most of them aren't solved:

Mac OS X - Kodi doesn't clean library anymore
https://forum.kodi.tv/showthread.php?tid=320419

Clarification of "Clean library..." & help to clean DB
https://forum.kodi.tv/showthread.php?tid=294011

Kodi 16 - Clean Library is taking too long
https://forum.kodi.tv/showthread.php?tid=277679

Kodi 17 - Why Does Clean Library NOT ACTUALLY DO THAT??
https://forum.kodi.tv/showthread.php?tid=312989

I would also like to try this plugin but there's a lot of work to do and I don't use any plugin or streaming service:
Beta - Database Pre-Wash Scrub - remove old junk links and privacy issues
https://forum.kodi.tv/showthread.php?tid=272112

I haven't read this yet:
[RELEASE] Texture Cache Maintenance utility
https://forum.kodi.tv/showthread.php?tid=158373

Thank you in advance!
Long 'waiting periods' usually involve paths/sources that are not accessible. Timeouts per source can make for a long wait.

1) If there was an easy fix, it would be there already.
2) Kodi stores the full paths for each video item. The fastest way to change file paths/protocols is to simply start from scratch. Unless you are a SQL engineer who knows what he/she is doing. See http://kodi.wiki/view/HOW-TO:Share_libra...s_In_MySQL .
3) Do a Video Library Export using Separate Files. This way .nfo files will be created. To preserve watched status and/or resume points, enable these options via the advancedsettings.xml file. See http://kodi.wiki/view/AdvancedSettings.xml#videolibrary .
(2017-11-21, 11:01)Klojum Wrote: [ -> ]Long 'waiting periods' usually involve paths/sources that are not accessible. Timeouts per source can make for a long wait.
You're right.
In my videodb.xml there are a lot of links that refer to a non sense folder, the one I exported the library to:

<art>
<fanart>nfs://192.168.1.103/mnt/HD/HD_a2/Kodi/xbmc_videodb_2017-10-03_New/movies/moviename.jpg</fanart>
<poster>nfs://192.168.1.103/mnt/HD/HD_a2/Kodi/xbmc_videodb_2017-10-03_New/movies/moviename.jpg</poster>
</art>

I will try to re-create the library from scratch, importing the watched state. I'll let you know.
 
(2017-11-21, 11:01)Klojum Wrote: [ -> ]2) Kodi stores the full paths for each video item. The fastest way to change file paths/protocols is to simply start from scratch. Unless you are a SQL engineer who knows what he/she is doing. See http://kodi.wiki/view/HOW-TO:Share_libra...s_In_MySQL .
Oh ok, thanks!
I know a little of MySQL and I could try it.

So the export-import library process is meant to be used only if you change your player device but you keep your files in the same location-source?
(2017-11-21, 11:01)Klojum Wrote: [ -> ]3) Do a Video Library Export using Separate Files. This way .nfo files will be created. To preserve watched status and/or resume points, enable these options via the advancedsettings.xml file. See http://kodi.wiki/view/AdvancedSettings.xml#videolibrary .
I'm sorry Klojum, I've read it but I don't understand.
How can I import these information from the exported NFOs to my new clean library?

I create advancedsettings.xml, i set <importwatchedstate>true</importwatchedstate> and <importresumepoint>true</importresumepoint>, I export the current library but then what do I have to do?
Do I have to copy the NFOs somewhere?

I'm beginning doing some tests, by the way...
Ok, I did it, without wasting too much time on it.

That's what I did, briefly:

01) Created advancedsettings.xml and put it on Userdata folder.
You have to do this in order to export "watched state" and "resume point" of every item (during video library export using separate files), basically the history of what movies and episodes you've already watched.
On Android, Userdata folder is Android/data/org.xbmc.kodi/files/.kodi/userdata/ on internal memory (not SD card) (Ref: http://kodi.wiki/view/Userdata_folder).
See below the content of advancedsettings.xml
(Ref: http://kodi.wiki/view/HOW-TO:Backup_the_video_library)

02) Launched a video library export using separate files.
It created a lot of files per episode-movie, in the same folder of the video file, like "Episode.nfo", "Episode-thumb.jpg", and in the root folder of season, like "tvshow.nfo", "banner.jpg", "poster.jpg" and so on.
I don't like this approach but those files contain "watched state" and "resume point" of every item so it's really pratical and handy.
You have to answer yes to every question.
(Ref: http://kodi.wiki/view/HOW-TO:Backup_the_video_library)

03) Moved all of my "MyVideos.db" and "sources.xml" files out of userdata/Database and userdata folder.
This way, Kodi created a brand new empty database.
My files were "MyVideos90.db", "MyVideos99.db" and "MyVideos107.db" in userdata/Database and "sources.xml" in userdata.
On Android, Database folder is Android/data/org.xbmc.kodi/files/.kodi/userdata/Database on internal memory (not SD card) (Ref: http://kodi.wiki/view/Userdata_folder).
(Ref: http://kodi.wiki/view/HOW-TO:Backup_the_video_library)

04) Re-added my sources from scratch (importing also "watched state" and "resume point" of every item).
On Settings > Media Settings > Manage Sources > Video > Add Video. I used SMB protocol, as I wanted to since beginning.
Given that I initially did a video export using separate files, the video import also automatically imported all the watched states and resume points of every item, the current status of what movies and episodes I've already watched.
And the import process was way faster than creating the library from zero and re-downloading every info.
Please be aware that if you're importing your library on a new device (different from the one you exported it from) you need do to the step 01 before starting the import process.
(Ref: http://kodi.wiki/view/Adding_video_sources)

At this point, I already had what I wanted: 
- A fresh brand new library;
- A backup and restore of movies and episodes I've already watched;
- A "Clean library" process that now takes 1 minute to complete, not 1 hour;
- My video sources using SMB protocol.

I added this step to have an additional always up-to-date backup of movies and episodes I've already watched ("watched states" and "resume points"):

05) Installed Trakt add-on to synchronize the viewed items on cloud.
Trak is a social network that is able to keep track of everything you've watched on Kodi. (You can also scrobble what you're watching with you followers).
I created and account, installed the add-on an configured it. It's really easy and quick.
I've set it to automatically sync everytime I update or clean my library.
I choosed Trakt over WatchedList because it was faster to configure and easier to use.
This is an actual live backup, instead of video library export that is a manual task you have to do.
(Ref:
https://www.htpcbeginner.com/backup-kodi...ed-status/
https://www.htpcbeginner.com/kodi-trakt-addon/
https://www.htpcbeginner.com/kodi-trakt-backup-restore/)

99) Content of advancedsettings.xml:
Quote:<advancedsettings>
  <videolibrary>
    <importwatchedstate>true</importwatchedstate>
    <importresumepoint>true</importresumepoint>
  </videolibrary>
</advancedsettings>

Thank you Klojum for pointing me in the right direction.
I really hope this is going to help someone else in my same situation.

Best regards.