2020-01-25, 16:55
PLEASE USE THE NEWER VERSION WITH HARD LINKS -> https://forum.kodi.tv/showthread.php?tid...pid2925727
Unfortunately this version has a big disadvantage. If some directory names (especially the collection path) are changed the links will break. But maybe the source code is useful for someone.
Restore your data with v0.5 e.g.
To check if you have already broken links, run this script with
The last option is to run this script with
Centralization and deduplication of ".actors" directories? yes, please!
Discussed many times in various forums, but never really implemented...
Well, with the script below, you finally can do that....
Admittedly a very quick & dirty assembled solution to simply accept the challenge....
V0.5 is no longer compatible with V0.1, but don't worry, you can still restore your data, see below.
KODI: Do not forget to enable Settings -> Media -> Videos -> Library -> Download actor thumbnails option, or you will not see any actor thumbnail.
Local files will be used first, that's the trick.
Windows user:
The script was created and tested under Linux BASH (Ubuntu). It may or may not work on Windows 10 if you enable Linux support there, but feel free to try it if you are brave enough.
Source code:
Unfortunately you can't upload files here, for the source code see post 2
Not every distribution supports every command or their parameters. So it is possible that it will not work on every system.
But I strongly recommend that you read on first.
Requirements:
The file system where your movie collection is stored must support symbolic links.
Worst case scenario:
The ".actors" directories will be shot up.
In this case simply delete them and reload the images via tmm. That's it.
But there is also a local possibility to restore them, see below.
Nevertheless a word of warning:
I have tested the script myself, but there is no WARRANTY...
If you are not familiar with Linux, better leave it alone.
ALWAYS test it yourself in a test environment first. To keep the script small, it generates hardly usable error messages.
The savings potential:
Since we are talking about a relation of one too many it depends on how many movies/tv shows an actor appears in. Since everyone usually has favorite actors, the hit rate will definitely be high. So if you have a large collection you can easily get several 100MB of the same data. Without big bla bla, about 50% of space saving.
The how:
Per collection a central directory called ".centralized" will be created to store the actor images.
The script will first copy and then link all files in any ".actors" directory.
A simplified example with Christian Bale from the dark knight collection. Already with one actor we have saved 100KB (3 x 37KB on disc), or 75% in this case.
Unfavorable cases:
You have distributed different collections to different external systems, e.g. Nas, then the potential savings may be smaller. Whether it works depends on the settings of the respective system, which I cannot go into here.
The files might not be linked anymore and will still appear twice. You could try running this script locally on these devices, but remember to configure the script with absolute paths.
Restore your data:
Starting with version 0.5 you can also undo all changes. To do so, change to the collection directory and call the script via its abspolute path. Everything else is done automatically. For more details see the example below.
Configuration:
There are only 2 settings, found at the top of the script. Be sure to set them correctly, otherwise the world may end...
yourCollections: Folders in which your "COLLECTIONS" are stored. Use only absolute paths.
checkForTmm: Can be 1|0 BE CAREFUL! 0 = The script is also executed when tmm is running. This has unforeseeable consequences.
However, checking for tmm only works if you use the script on the same system.
Usage:
For some fun you can even see how fast certain commands are.
New command line parameters:
--help Shows this help
Call following options inside the desired collection folder.
--restore All symlinks are replaced with their original files
--migrate01 Undo all changes from v0.1
--check Shows a list of broken symlinks
--delete Deletes all broken symlinks
Virtualization:
The script has already processed tmm_test, so no new (unlinked) files are found.
Restoring content, undo virtualization:
We are already in the collection directory tmm_test2 and call the script via its absolute path and parameter --restore. The script will now restore all symlinked files.
All images are now restored in their original place. Note that the same images are still present in the .centralized folder. You can now delete this directory if you no longer need it.
Migration of v0.1:
We are already in the collection directory tmm_test and call the script via its absolute path and parameter --migrate01.
This collection was virtualized with v0.1.
Unfortunately this version has a big disadvantage. If some directory names (especially the collection path) are changed the links will break. But maybe the source code is useful for someone.
Restore your data with v0.5 e.g.
./actorsCentralizer.sh --restore
ASAP!To check if you have already broken links, run this script with
--check
The last option is to run this script with
--delete
to delete all broken links and then download the images with tmm again. Sorry for the inconveniences.Centralization and deduplication of ".actors" directories? yes, please!
Discussed many times in various forums, but never really implemented...
Well, with the script below, you finally can do that....
Admittedly a very quick & dirty assembled solution to simply accept the challenge....
V0.5 is no longer compatible with V0.1, but don't worry, you can still restore your data, see below.
KODI: Do not forget to enable Settings -> Media -> Videos -> Library -> Download actor thumbnails option, or you will not see any actor thumbnail.
Local files will be used first, that's the trick.
Windows user:
The script was created and tested under Linux BASH (Ubuntu). It may or may not work on Windows 10 if you enable Linux support there, but feel free to try it if you are brave enough.
Source code:
Unfortunately you can't upload files here, for the source code see post 2
Not every distribution supports every command or their parameters. So it is possible that it will not work on every system.
But I strongly recommend that you read on first.
Requirements:
The file system where your movie collection is stored must support symbolic links.
Worst case scenario:
The ".actors" directories will be shot up.
In this case simply delete them and reload the images via tmm. That's it.
But there is also a local possibility to restore them, see below.
Nevertheless a word of warning:
I have tested the script myself, but there is no WARRANTY...
If you are not familiar with Linux, better leave it alone.
ALWAYS test it yourself in a test environment first. To keep the script small, it generates hardly usable error messages.
The savings potential:
Since we are talking about a relation of one too many it depends on how many movies/tv shows an actor appears in. Since everyone usually has favorite actors, the hit rate will definitely be high. So if you have a large collection you can easily get several 100MB of the same data. Without big bla bla, about 50% of space saving.
The how:
Per collection a central directory called ".centralized" will be created to store the actor images.
The script will first copy and then link all files in any ".actors" directory.
Code:
/absolutepath of collection/%movie%/.actors/%actor%.jpg --> /absolutepath of collection/.centralized/token/%actor%.jpg
A simplified example with Christian Bale from the dark knight collection. Already with one actor we have saved 100KB (3 x 37KB on disc), or 75% in this case.
Code:
tmm_test
├──.centralised
│ └── c
│ └── ch
│ └── Christian_Bale.jpg
├── Movies
├── Movie 1
│ └── Christian_Bale.jpg -> /home/USER/Videos/tmm_test/.centralised/c/ch/Christian_Bale.jpg
├── Movie 2
│ └── Christian_Bale.jpg -> /home/USER/Videos/tmm_test/.centralised/c/ch/Christian_Bale.jpg
├── Movie 3
│ └── Christian_Bale.jpg -> /home/USER/Videos/tmm_test/.centralised/c/ch/Christian_Bale.jpg
└── Movie 4
└── Christian_Bale.jpg -> /home/USER/Videos/tmm_test/.centralised/c/ch/Christian_Bale.jpg
Unfavorable cases:
You have distributed different collections to different external systems, e.g. Nas, then the potential savings may be smaller. Whether it works depends on the settings of the respective system, which I cannot go into here.
The files might not be linked anymore and will still appear twice. You could try running this script locally on these devices, but remember to configure the script with absolute paths.
Restore your data:
Starting with version 0.5 you can also undo all changes. To do so, change to the collection directory and call the script via its abspolute path. Everything else is done automatically. For more details see the example below.
Configuration:
There are only 2 settings, found at the top of the script. Be sure to set them correctly, otherwise the world may end...
yourCollections: Folders in which your "COLLECTIONS" are stored. Use only absolute paths.
Code:
└── tmm_test <----- This is what you need
├── movies
│ └── .....
└── shows
└── .....
However, checking for tmm only works if you use the script on the same system.
Code:
#################### USER CONFIGURATION ######################
yourCollections=("Folder 1" "Folder 2" "and so on")
checkForTmm=1
Usage:
- Never use the standard applications of windows, as this will change the formatting and the script will no longer work.
- Copy the source code in a file e.g. "actorCentralizer.sh
- mark it as executable chmod +x actorCentralizer.sh
- you can start it with ./ actorCentralizer.sh
For some fun you can even see how fast certain commands are.
New command line parameters:
--help Shows this help
Call following options inside the desired collection folder.
--restore All symlinks are replaced with their original files
--migrate01 Undo all changes from v0.1
--check Shows a list of broken symlinks
--delete Deletes all broken symlinks
Virtualization:
The script has already processed tmm_test, so no new (unlinked) files are found.
Code:
---------------------------------------------------------
.actors centralization & deduplication has started...
Version 0.5
---------------------------------------------------------
Collection: [/media/NAS/Multimedia/TMM_TEST]
Symlinks: not supported... <--- Symlinks over Samba are not supported on this NAS
---------------------------------------------------------
Collection: [/home/user/Videos/tmm_test]
Symlinks: supported... <--- Symlinks are supported, everything is fine
Searching for .actors folders...Done in 0.00855936 second(s)
Found 0 MB in 0 files. <--- No physical files found (already symlinked collection)
no files found...
---------------------------------------------------------
Collection: [/home/user/Videos/tmm_test2]
Symlinks: supported...
Searching for .actors folders...Done in 1.1085 second(s)
Found 26.2695 MB in 823 files.
Centralized folder: [/home/user/Videos/tmm_test2/.centralized]
Copy OK: 823 Errors: 0 Symlink OK: 823 Errors: 0
------------------------ summary ------------------------
Centralized folder before 0 MB, now 11.1367 MB <--- 11MB vs 26MB!!!!
---------------------------------------------------------
Restoring content, undo virtualization:
We are already in the collection directory tmm_test2 and call the script via its absolute path and parameter --restore. The script will now restore all symlinked files.
All images are now restored in their original place. Note that the same images are still present in the .centralized folder. You can now delete this directory if you no longer need it.
Code:
user@pc:~/Videos/tmm_test2$ /home/user/Videos/actorsCentralizer/actorsCentralizer_0.5.sh --restore
Restoring .actors folders in /home/user/Videos/tmm_test2
Searching for .actor folders...
Found 823 files.
Copy OK: 823 Errors: 0
Done in 1.5599 second(s)
Migration of v0.1:
We are already in the collection directory tmm_test and call the script via its absolute path and parameter --migrate01.
This collection was virtualized with v0.1.
Code:
user@pc:~/Videos/tmm_test$ /home/user/Videos/actorsCentralizer/actorsCentralizer_0.5.sh --migrate01
Migrating v0.1 content in /home/user/Videos/tmm_test
Searching for .actors folders...
Found 11 folders.
Copy OK: 11 Errors: 0
Done in 0.0639293 second(s)
---------------------------------------------------------
Restoring .actors folders in /home/user/Videos/tmm_test
Searching for .actors folders...
Found 823 files.
Copy OK: 823 Errors: 0
Done in 1.68524 second(s)
---------------------------------------------------------
You should now have all files on their old places. Run this script again to virtualize them.
---------------------------------------------------------