bexem / plexcache Goto Github PK
View Code? Open in Web Editor NEWAutomate Plex media management: Efficiently transfer media from the On Deck/Watchlist to the cache, and seamlessly move watched media back to their respective locations.
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.
When I run the script, I have this error:
/mnt/user/system/./locatefileinarray.sh: No such file or directory
don't know where I can find this locatefileinarray.sh file.
As per the subject, I love this script, but I really need it or something like it to monitor my Plex "Watched" content across my users and move it to the array.
That content that has already been watched will be put into long-term storage :)
Be good to also put a timer on it - so after x days of it being added to server, move to array. This way the people that immediately watch a show upon release get to watch it from cache/ssd, and then the slow dribble of other people can then watch it from the array.
Thoughts?
Thanks.
Some severs contain non-standard libraries, such as music videos, youtube videos etc.
It often doesn't make sense to treat these in the same way as other libraries in assuming that users will watch sequentially.
Therefore it should be possible to provide a list of library sections to evaluate.
Hey guys,
I managed to get everything working in my UNRAID environment, despite the fact, that it's throwing errors from the Watchlists others users using my Plex server (does this only work for "local users"?
Also my watchlist is being created, but not copied to cache :(
Don't know where to start sadly...I hope someone can support me :)
I also couldn't use my public dns name for my plex server (even valid certificates and stuff, but it told me "token is malformed"...)
I'm currently going through the setup.py on this in PowerShell on server 2019, when it gets to the point of asking about my cache drive it defaults to /mnt/cache which is the correct location on my unraid server... but it's not giving me an option to specify any unraid details? have i missed something? or can this not communicate with my unraid server, and will i need to "cache" it on the windows machine locally?
I am having an issue trying to use this script. I run it and it'll locate some media successfully and move it to the cache, however its only finding around 100GB on the first run. This left my SSD with >900GB of free space remaining. I ran the script again and it tells me that it located 889GB of media to move, but claims there is only 855GB of free space remaining. Am I doing something wrong that causes it to not find all the media in the first run but does the second? It also seems like a bug that it's telling me there is not enough free space when there is.
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")
Would it be possible to let the script generate an Unraid Notification after each run?
I am getting the bellow. Very confused as I can see the files. Running on Unraid
`root@TheLibrary:/mnt/user/scripts/PlexCache# python3 plexcache.py
*** PlexCache ***
Debug mode is active, NO FILE WILL BE MOVED.
Fetching DuzAwe's onDeck media...
Editing file paths...
Fetching subtitles...
Fetching watched media...
Fetching DuzAwe's watched media...
Editing file paths...
Fetching subtitles...
Nothing to move to array
Error: [Errno 2] No such file or directory: "/mnt/user/TV/It's Always Sunny in Philadelphia (2005) [TVdb-75805]/Season 13/It's.Always.Sunny.in.Philadelphia.-.S13E03.-.The.Gang.Beats.Boggs-.Ladies.Reboot.WEBDL-1080p.mkv"
root@TheLibrary:/mnt/user/scripts/PlexCache# nano plexcache_settings.json
root@TheLibrary:/mnt/user/scripts/PlexCache# python3 plexcache.py
*** PlexCache ***
Fetching DuzAwe's onDeck media...
Editing file paths...
Fetching subtitles...
Loading watched media from cache...
Nothing to move to array
Error: [Errno 2] No such file or directory: "/mnt/user/TV/It's Always Sunny in Philadelphia (2005) [TVdb-75805]/Season 13/It's.Always.Sunny.in.Philadelphia.-.S13E03.-.The.Gang.Beats.Boggs-.Ladies.Reboot.WEBDL-1080p.mkv"
root@TheLibrary:/mnt/user/scripts/PlexCache# ^C
root@TheLibrary:/mnt/user/scripts/PlexCache# ^C
root@TheLibrary:/mnt/user/scripts/PlexCache# ls /mnt/user/TV/It's Always Sunny in Philadelphia (2005) [TVdb-75805]/Season 13/
^C
root@TheLibrary:/mnt/user/scripts/PlexCache# python3 plexcache.py
*** PlexCache ***
Fetching DuzAwe's onDeck media...
Editing file paths...
Fetching subtitles...
Loading watched media from cache...
Nothing to move to array
Error: [Errno 2] No such file or directory: '/mnt/user/TV/Star Trek - Strange New Worlds (2022) [TVdb-382389]/Season 02/Star.Trek-.Strange.New.Worlds.-.S02E07.-.Those.Old.Scientists.WEBDL-2160p.mkv'`
After I downloaded the plexapi and requests files with python, the cmd window says that the files dont exist.
After checking manually in the folder, the files indeed don't exist.
Hey,
I love the script but seem to be having an issue with the on deck information being wrong.
Looking over the debug log it's seeing shows which arnt even on users OnDecks. When I check the cache folder not all of the media which should have been copied over was copied. (There were no copy errors) I've attached the log for reference.
I have a feeling I could have setup some of the cache paths incorrectly as the files which are in the 'plexcache_mover_files_to_exclude' file are the ones which are in the cache.
plexcache_log_latest.log
plexcache_mover_files_to_exclude.txt
Just stumbled across this script and I'm really keen to set it up.
Whilst I admit I have only glazed over the instructions; my only concern is installing it directly onto the Unraid system. The sysadmin in me likes to keep the OS as close to stock as possible in case of future issues.
Would it be easy enough to containerize this? Or better yet create a CA Plugin that can be configured via the GUI and then blown away if I uninstall it?
I'm sure it would get some real traction if the average Joe could just click "Install" from the Unraid Apps store and off they go.
Hello and thank you for your work on PlexCache and also the wiki! I would love to use it, but I still have some questions regarding its setup outside of unraid.
I'm using Ubuntu without bcache or similar things , just straight up ext4 formatted drives and plex in docker and for example:
I have an empty ext4 formatted ssd and a hdd where the media folder for my plex docker is mounted to. I tell the symlink version of the script that the cache folder is on the sdd. What happens if I start the script? Will the specified movies/shows be moved to the cachefolder on the ssd and in their place on the hdd there'll only be a symlink left? So that means I would have to mount the cache folder in the container too. Won't the hdd be woken up anyways when the symlink is accessed by plex?
Just an Idea, which I will look up later: Can't the files simply be copied to the ssd whilst also remaining on the hdd and renamed in such a way that plex prefers the file on the ssd?
I'm having an issue where PlexCache is moving files to the cache (works well and is great) and then when mover runs it moves them back to the array. The next time PlexCache runs it moves files back to the cache... and on and on. I understand the two parts are operating as they should but I'd like to avoid files being shuffled back and forth unnecessarily.
Is there some setting that I'm missing in either setting up PlexCache or in Mover Tuning?
I know that it is possible to have Mover Tuning ignore files listed inside of text file; is it possible to have the PlexCache script generate a text file of the files it wants to keep on the cache?
Running on Unraid through UserScripts is creating permissions issues.
Files are ending up with root/root ownership rather than nobody/users. Running the new permissions tool fixes it.
Is there some way to adjust UserScripts settings or the script to ensure the correct ownership/permissions?
Sometimes i get an error that says:
PlexCache: 06-09-2023 18:00 ERROR Error moving file: [Errno 2] No such file or directory: '/mnt/user0/tv/Ahsoka/Staffel 1/Ahsoka - S01E04 - Part Four - Fallen Jedi.mkv'
The file does not exist in the folder mentioned above. But does exist in the /mnt/user/... share
Why is this happening and how can this be fixed?
I've seen this error before and copying over the file in question fixed it the last time.
Unraid 6.12.4
no ZFS.....yet
plexcache_log_20230906_1837.log
EDIT: In the meantime i upgraded to 6.12.10 and use ZFS. The problem stays the same.
Hey,
there is this particular error which seems to come up more often on my Unraid system.
Sometimes I can fix it via clearing the "plexcache_watched_cache.json" file, but right now it just does not want to work.
I also deleted the particular file it can't find or move but I get the same error.
Newest version of the script, newest Unraid.
Do you have any hints for me to fix that? :)
hello
thanks for this great script but I have few questions about the setup
I guess for the NAS, the script won't work but for my second UnRaid server and the one running this script, how do I set it up?
do I need to install it in my second UnRaid server too?
not sure to understand this line -> Enter the corresponding NAS/Unraid library folder for the Plex mapped folder: (Default is the same as plex as shown) 'J'
using UserScript -> what's the best cronjob to use to run this script? every hour? or just need to run 1 time and its active until the server reboot?
Thank You
Best Regards
I installed plexapi and requests via pip and start the script with python plexcache_setup.py
and immediately get the following error message:
File "plexcache_setup.py", line 24
raise FileNotFoundError(f'Wrong path given, please edit the "{folder}" variable accordingly.')
Where do i find the {folder} variable?
Could you consider adding a feature that monitors whatever media a user starts playing and have the script execute a copy to the unraid cache drive (effectively a copy)? then later purge the clone present in cache mount?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.