bexem / PlexCache

Automate Plex media management: Efficiently transfer media from the On Deck/Watchlist to the cache, and seamlessly move watched media back to their respective locations.
88 stars 7 forks source link

Feature request: Add support for creating Unraid Mover ignore file #31

Closed crafty35a closed 3 months ago

crafty35a commented 3 months ago

Unraid's mover tuning plugin has the ability to read a text file with a list of files to be ignored by the mover. It would be great if this script had the ability to create this file. What this would do, for example, is allow you to set the mover to move all files older than N days off the cache, without constantly fighting with the PlexCache script (without this ignore file, PlexCache will move files the cache that are older than N days, then the mover will move them back to the array, and the cycle will continue).

I was able to very easily implement this myself by simply adding this code to the top of the check_free_space_and_move_files function (for now the ignore file path is hardcoded to where I needed it):

    with open('/mnt/user/appdata/plexcache/moverignore.txt', 'w') as f:
        for file in list(set(media_files)): #list/set to remove duplicates from the list
            # If file belongs on the cache, add it to unraid mover ignore text file
            if destination == 'cache':
                # Get the cache file name using the file's path, real_source, and cache_dir
                cache_file_name = get_cache_paths(file, real_source, cache_dir)[1]
                f.write(f"{cache_file_name}\n")
bexem commented 3 months ago
mover_cache_exclude_file = Path(os.path.join(script_folder, "plexcache_mover_files_to_exclude.txt"))
if os.path.exists(mover_cache_exclude_file):
    os.remove(mover_cache_exclude_file)  # Remove the existing 
        if unraid:
            with open(mover_cache_exclude_file, "w") as file:
                for item in cache_files_to_exclude:
                    file.write(str(item) + "\n")

It was already implemented?

crafty35a commented 3 months ago

Where is that code? I do not see it in the latest release that I downloaded directly from this repo EDIT: Looks like it is in the repo code, but there was no release. Might be a good idea to push a new release. Thanks! I will try it out now.

Unrelated question, but are all the settings in plexcache_settings.json documented somewhere? Not all of them are entirely clear to me, and I am not finding documentation in the wiki

bexem commented 3 months ago

Hi there! I apologize for the confusion - I thought I had published the code as a release at the time, but it looks like it was only available in the repo. Thank you for pointing this out.

Regarding the settings in plexcache_settings.json, I appreciate your feedback that some of them aren't entirely clear or explained. I planned on rewriting the code and updating the documentation once I finished, including adding explanations for each setting. I did start refactoring (and tried to get back to it a couple of months ago) but unfortunately work and difficult family circumstances have kept me busy, leaving me little free time and motivation.

I will try to at least release the latest published code in the main branch and put some comments on what the settings variables are for. Hopefully circumstances are going to change and I can get back to coding.

crafty35a commented 3 months ago

No worries, thanks for your work on this, it's very helpful!

rickgardner077 commented 1 week ago

How can I benefit from the mover ignore file if it is not contained in a release? What do I have to do instead of following the setup instructions? Sorry I am a Github n00b