TLDR: Move the media currently On Deck on Plex from the array to the cache (unraid).
This is a script in Python made to help me saving some energy by reducing the need to spin up the array/disk(s) when watching recurrent media, such as a TV series. The script moves not only the media (Movies and Shows) that is "On Deck" but also the next 51 episodes of each TV Series (and/or Anime) to the cache (SSD) drive, which is faster and more power-efficient than the regular disk. Additionally, it will also move the subtitles to prevent the need to spin up the entire drive for a small amount of data. This script is designed to work with Unraid, but can be adapted for use with other systems.
While I am still new to Python and the code may not be the most efficient, it has been working seamlessly for several days (and counting).
To use the script there are different ways but DO NOT forget to change the plex url and token2 variables accordingly.
A) Run it on Chronos3 (docker container, easily installable from the unraid app store):
- Allocate another path to the default ones, point it at "/mnt" in both the host and the container.
- Once you are in the Chronos web interface:
- Add a new script
- Configure how to trigger (personally using cron) the script;
- List the two requirements (plexapi and psutil) in the Pip requirements box;
- Save;
- Press "Install pip requirements";
- Past the content of the plexondeckcache.py in the Python script box.
- Save.
- Execute (or wait for the script to be triggered);
- Enjoy.
B) Install python directly on Unraid (probably using NerdTools4 plugin) but you will need to manually install the two dependency the script requires (plexapi and psutil); and run it by cron (or User Scripts plugin5). I don't advise this method but it works.
Thank you to brimur/preCachePlexOnDeckEpiosodes.py Your script is what helped and inspired me.
Footnotes
-
If you want to fetch more episodes, change this variable at the beginning of the script "number_episodes". ↩