Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to setup correctly if movies/tv are on differents NAS/Unraid server #27

Open
Speedmod88 opened this issue Feb 14, 2024 · 3 comments

Comments

@Speedmod88
Copy link

hello

thanks for this great script but I have few questions about the setup

  1. How do I setup correctly if I have 1 NAS and 1 UnRaid server as Remote connection and 1 UnRaid server with Plex running on it?
    ex: /mnt/remote/NAS , /mnt/remote/Unraid2 , /mnt/user/media

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?

  1. 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'

  2. 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

@bexem
Copy link
Owner

bexem commented Feb 14, 2024

Hi there,

Sorry would you mind to expand how you have your server(s) and plex setup?
Either way the script needs to be able to access the directories where you store your media, the cache drive/directory and be able to communicate to the plex server (the script doesn't need to run on the same machine).
I would run the script on the server holding the files so that when it moves the file there is no network overhead.

When the script prompts with "Enter the corresponding NAS/Unraid library folder for the Plex mapped folder: (Default is the same as Plex as shown) 'J'", it's asking you to specify the path where the media for that Plex library is stored on your UnRaid server/NAS. This allows the script to map the Plex library to the physical location of your media files. If the path is the same as the one Plex uses, you can just hit Enter.

For setting this up as a UserScript and determining the best cronjob, it highly depends on how frequently your Plex media library updates. Running it every hour might be overkill for most users, but if you have a rapidly changing library (e.g., frequent additions or media consumption), it could be justified ** but you might run in watchlist api call limits which are controlled directly by Plex **.

A more conservative approach might be once a day during a low-usage period if your library isn't changing constantly. This limits disruptions and ensures the cache is fresh daily. For example, a cron job set to run daily at 3 AM would look like this in crontab format:

0 3 * * * /path/to/your/script/plexcache.py

I personally run it once a day.

Adjust the schedule according to your specific needs and server usage patterns. The script isn't active in the background; it's executed each time based on the cron schedule you set.

Best Regards and happy streaming!

@Speedmod88
Copy link
Author

Speedmod88 commented Feb 15, 2024

my plex setup are:

plex docker running on server TOWER

movies/tv folder inside Plex server are mount like this

for Movies:
- /data/movie/A 
- /data/movie/B
- /data/movie/C
- /TOWER/movie/A
- /TOWER/movie/B
- /TOWER/movie/C
- /NAS/movie/A
- /NAS/movie/B
- /NAS/movie/C

For TV:
- /data/tv/
- /TOWER/tv/
- /NAS/tv/

Docker mount are:

- /data -> /mnt/remote/UnRaid2/media/
- /TOWER -> /mnt/user/media/
- /NAS -> /mnt/remote/NAS/media/

anyway I can have an example to how to set plexCache on my setup please??

Thanks a lot :)

@bexem
Copy link
Owner

bexem commented Feb 16, 2024

Given the complexity of your media storage across three distinct folders/servers, running the script initially in debug mode is a wise first step. This mode avoids any file manipulation.

To potentially resolve this, you might consider restructuring your folder mappings within the Plex server Docker settings as follows:

- /data/movie -> /media/movies/data  
- /TOWER/movie -> /media/movies/TOWER  
- /NAS/movie -> /media/movies/NAS  
- /data/tv/ -> /media/tv/data  
- /TOWER/tv/ -> /media/tv/TOWER  
- /NAS/tv/ -> /media/tv/NAS

However, this adjustment alone might not fully address the issue due to the limitation of the real_source variable, which expects a singular path but in your case, corresponds to three unique locations.

For instance, when mapping a movie from Plex with the proposed configuration, it might interpret the path as:
"/media/movies/data/Jurassic Park/jurassicpark.mkv"
which the script then tries to correlate with a path like:
"/mnt/user/movies/Jurassic Park/jurassicpark.mkv"

This works fine for media directly under /mnt/user/ but fails for items in /TOWER or /NAS, leading to errors.

If you could create some 'virtual' folder where your "/mnt/user" "/TOWER" and "/NAS" can be mapped to so that you can point the script to it? I'm not sure if possible.

It's theoretically possible to enhance the script to handle multiple real_source paths to smartly navigate across multiple storage locations, verifying/mapping each path's existence.

I have not abandoned the project but I have been dragged away from all this from different reasons and I am not sure when I will be able to get back to it, I will definitely add it to my todo list for my rewrite which I did start but getting covered by virtual dust bunnies.

"plex_source": "/media/",
"plex_library_folders": [
    "movies",
    "tv"
],
"cache_dir": "/mnt/cache/", # Modify this path to your cache drive/folder
**_"real_source": "/mnt/user/",_** # The issue lies here
"nas_library_folders": [
    "movies",
    "tvseries"
],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants