Automatic cleaning library on all players.

  • I like to clean library on all 12 players automatically after removing movie from the server. I don't want to go to every room and perform library cleaning. I like to do it remotely, at once.
    There is "Update library on startup" option, but there is no "Clean library on startup" option. This option would solve my problem, but the best option would be an order from server (source) or one player to clean libraries on all of them.

    Is it possible?

  • Alternatively, you could run a single centralized database, so any of the Kodi clients could delete stuff from your libraries, instead of doing that 12 times.

    Right now I think you manually delete a file from your server, and Kodi has to clean up after you. Better is to delete your movie from your (centralized) library directly, AND let Kodi remove the file from your source.

    The same applies to adding new movies or tv series. Just a thought.

  • Alternatively, you could run a single centralized database, so any of the Kodi clients could delete stuff from your libraries, instead of doing that 12 times.

    Right now I think you manually delete a file from your server, and Kodi has to clean up after you. Better is to delete your movie from your (centralized) library directly, AND let Kodi remove the file from your source.

    The same applies to adding new movies or tv series. Just a thought.

    I don't understand your suggestion. All movies with meta-data folders and backgrounds are on the server running MyMovies. All players (Kodi clients) get all info from server and update library or on start or manually. Updating library doesn't remove movies deleted from server, it has to be done manually from player (Kodi client). I don't see any automated option like "Clean library on startup" nether option to clean library from remote location. When I go to Kodi remotely there is no option to clean library either.


    You could use JSON-RPC to send cleaning commands to all your boxes. Don't ask me for details, I don't use that. /shrug

    I checked your suggestion. I have to fully investigate this option. Thanks

    Edited once, last by Zygmunt: Merged a post created by Zygmunt into this post. (March 13, 2021 at 7:12 PM).

  • You probably have to make your own script..

    The tools you need are already their with the System Tools Addon..

    I have something similar to what you r asking altough it's a bit more elaborated then just cleaning library..I got a TVHeadend server sending recordings to my box after they r done with comskip etc..that is when inotifywatch from system tools comes in handy..

    What you need to do is set 1 of your boxes that has LibreElec running to watch the folder where your movies are saved with inotifywait..

    It works wonders..

    then set up a script..something like if event is CLOSE_WRITE,CLOSE (movie added) update all libraries,if event is DELETE then clean all libraries..

    ...use kodi-send --action to send commands to clean libraries or update added movies to all boxes..

    Code
    kodi-send --host=xxx.xxx.x.xxx --port=xxxx --action="CleanLibrary(movies)"
    kodi-send --host=xxx.xxx.x.xxx --port=xxxx --action="UpdateLibrary"
  • Klojum and Mario77
    I think that you are right. I should try JSON-RPC and create script. (I never did it but I will try)
    Mario77, you gave me the best clue how to do it. I assume that I have to set static IP for every player and then send the same command to all of them.

    I will try.

  • Klojum and Mario77
    I think that you are right. I should try JSON-RPC and create script. (I never did it but I will try)
    Mario77, you gave me the best clue how to do it. I assume that I have to set static IP for every player and then send the same command to all of them.

    I will try.

    yes they will have to have static IP..

    If you get stuck with script ask here..

    Going to give you a good hint where to start from..all you need is something like this..

    then create another file with just the paths to your movies folders that you want to watch for changes one under the other and set path in script for that file


    Also I just remembered that there is also an addon called WatchDog you can use...but probably you will have to install it on every box and I don t think it's network friendly...it's probably just for connected devices but you can always try..

    The other way in previous post is only set up on 1 box and sends json to all boxes which is better once setup..

    Edited once, last by Mario77: Merged a post created by Mario77 into this post. (March 15, 2021 at 10:29 PM).

  • I don't understand your suggestion.

    As far as I understand it, you have 12 Kodi clients in your household. Each has its own local database running on its SDcard. That means 12 times the maintenance.

    With a single centralized database, every client connects to that one database. All maintenance (adding, deleting, cleaning, etc) will only need to be done once. Without any additional scripts. But you do need a (extra) computer to run the database server on.

    But, do what works for you.

  • Klojum, it may work even better, but Kodi player has to use central library instead of creating library on local storage. I have to check if it is possible. Additional computer is not a problem because I have Media Server and library can be on this server.

    I will look at this option.


    Mario77 Thanks. I will check both options. Will see how it works.

    Edited once, last by Zygmunt: Merged a post created by Zygmunt into this post. (March 21, 2021 at 8:20 PM).

  • If you get stuck with script ask here..

    Going to give you a good hint where to start from..all you need is something like this..

    First I sent command on address line:192.168.1.226:8080/jsonrpc and received answer from player, so I know that I set up player properly.

    I created batch file "update library.bat" but it doesn't work. Problem is that I am hardware, not software guy and don't understand many things.

    I created batch: kodi-send --192.168.1.226:8080 --action="UpdateLibrary" and executed. Nothing. So I understood that I should put other commands as well even I don't understand what they are doing.

    So:

    Also nothing. I assume that there is an error above but I can figure out where because I don't understand many commends above.

    I've read info how to create batch file on different websites but it didn't help.
    Can you help?

  • I have no idea with batch files..that script you run as service with libreelec and it monitors your movie folder...

    so let me try to explain

    create directory

    Code
    /storage/.config/scripts

    create a file in

    Code
    /storage/.config/scripts/inotify.sh

    with the below code and name it inotify.sh , could be anywhere under storage this is just an example

    then create another file in same directory /storage/.config/scripts and name it "paths"

    in this file put the paths to your movie/shows folder..just one under the other...you can monitor how many folders you want..

    as you can see the script above points to this file with the following line --fromfile

    Code
    --fromfile  /storage/.config/scripts/paths

    contents of paths file example;

    Code
    /var/media/HDD/Tv_Shows_Recordings
    /var/media/HDD/Movies
    etc
    etc
    etc

    Then you need to start inotify.sh on startup either with autostart.sh or service via system.d

    Now if your movie folders are on a remote location you might need to mount that path to the box you will be running this script from..


    You need to install virtual.system-tools addon from LibreElec Repo for this to work


    Also you basically don't need the part

    Code
    datetime watched_filename

    I m using that in my script as my script is much more then just that and has logging..but don t complicate things for now.you can leave as is..still works.

    Edited 5 times, last by Mario77: Merged a post created by Mario77 into this post. (March 27, 2021 at 8:05 PM).

  • Mario, I have to do it in one of players/clients, right?

    yes running Libreelec


    Just in case you missed my other post..if you manage to do it this way you can do the job from 1 box across all your boxes..

    Option 2 is you install Watchdog addon from Kodi repo..it's listed as a service addon..it does the job same way for you and it's ready made..you don t need any scripts..slight problem is that you will have to install this addon on every box..only takes few seconds anyway..you don t even have to set it up as it watches your video library paths automatically..

    Edited once, last by Mario77: Merged a post created by Mario77 into this post. (March 26, 2021 at 10:16 PM).

  • I installed Watchdog and played with settings. It doesn't clean library as described but it does after restarting player, so it helps, it does a job.

    This weekend I will try to find option to send command to players from server (WHS 2011) or from PC (WIN7, 8 or 10) and also try to create service following your instruction, Mario77.

  • I installed Watchdog and played with settings. It doesn't clean library as described but it does after restarting player, so it helps, it does a job.

    This weekend I will try to find option to send command to players from server (WHS 2011) or from PC (WIN7, 8 or 10) and also try to create service following

    Might need a restart on first install to start services..

  • I found on "KODI How to" following: HOW-TO:Remotely update library.

    I was sure I found a solution, there are JSON commands already prepared, but:
    1. First two options - I have no idea how to do it.
    2. WIN command prompt looks easy, but there is no curl.exe in downloaded curl folder. I tried several methods, but no success.

    3. HTTP doesn't work on v18 Leia

    So I am in starting point.

  • If I where you I would look into that shared library suggestion.

    1 Centralized library and doesn't matter on which client you update or clean library. When 1 does update/clean it's active for all clients.


    MySQL/Setting up Kodi - Official Kodi Wiki

    Edited once, last by Raven: @admin, when will i get 'xs' to post normal instead of you guys need to verify it? I understand why it is just want to know what I need to do to get rid of this ;) (March 27, 2021 at 9:28 PM).