A utility to trigger Plex partial-scans on NFS configurations, on which inotify is not supported
Project description
Plex NFS Watchdog
A utility to trigger Plex partial-scans on NFS configurations, on which inotify is not supported
Table of Contents
:book: About The Project
Inotify is a Linux kernel subsystem that allows monitoring changes to files and directories in real-time. It is commonly used by applications to watch for changes in files or directories and respond accordingly.
Plex makes use of inotify to perform partial scans when a file is added or removed from a directory. This allows Plex to update its library without having to perform a full scan.
Running Plex Media Server with the library located on Network File System (NFS) mounted directories will not trigger such partial scans because inotify doesn't work on NFS. When a file is changed on an NFS mount, it doesn't trigger an inotify event on the client side.
Plex NFS Watchdog is a utility that can be installed on the machine that produces inotify to monitors directories for
changes and triggers a partial scan on the Plex Media Server instance installed in a different machine when a change is
detected by invoking the Plex API.
:gear: Getting Started
To use Plex NFS Watchdog you must ensure that on all machines involved the Plex's Library sections use the same folder
name. The folder path can be different on each machine, but the folder name must be the same.
This is important because the utility will use the folder name to trigger the partial scan.
For example, if you have a library section called "Movies" and the folder name is "Movies", the utility will trigger a partial scan on the "Movies" library section when a change is detected in the "Movies" folder.
Prerequisites
Obtain the Plex Authentication Token for your Plex Media Server instance. You can find instructions on how to do this here.
Installation
You can install this tool as a Python Module using pip
or executing the script directly.
- If you want to install the tool as a Python Module:
- Install the module using pip:
pip install plex-nfs-watchdog - You can run the tool using:
plex-nfs-watchdog
- Install the module using pip:
- If you want to use the script directly:
-
Clone the repository anywhere on your pc:
git clone https://github.com/LightDestory/PlexNFSWatchdog -
Install the requirements using
pip(create avenvif you want):pip install -r requirements.txt -
Run directly from source:
python ./src/plex_nfs_watchdog/plex_nfs_watchdog.py
-
Docker Support
You can also run this tool using Docker Compose.
-
Clone the repository:
- Download the project by running:
git clone https://github.com/LightDestory/PlexNFSWatchdog cd PlexNFSWatchdog
- Download the project by running:
-
Create a
.envfile in the root of the project:- You can use the provided
.env.examplefile as a reference and rename/copy it to.env. - Define the necessary environment variables such as your Plex server address, token, paths to watch, scan interval, and event listeners. See Usage for more details on what to set these variables to.
- You can use the provided
-
Modify
compose.ymlto match your setup:- Ensure the volume paths correctly map to your actual media directories, the same ones you've specified to be watched in the .env file.
-
Build and start the container:
-
Run the following command to start the service in detached mode:
docker compose up -d --build
-
Check logs to monitor the process:
docker logs -f plexnfswatchdog
-
Restart the container if needed:
docker compose restart plexnfswatchdog
-
Stop and remove the container:
docker compose down
-
Usage
This utility requires the following arguments to work:
| Argument | Role |
|---|---|
| --scan | -s | Manually triggers a partial-scan on the given paths |
| --daemon | -d | Starts a watchdog daemon to automatically triggers a partial-scan on the given paths Requires: --interval and --listeners |
| --paths | -p [PATHS...] | A list of folder paths |
| --host | -H HOST | The host of the Plex server Default: http://localhost:32400 |
| --token | -t TOKEN | The token of the Plex server |
| --interval | -i INTERVAL [OPTIONAL] | The interval in seconds to wait between partial-scans. Defaults to 60 |
| --listeners | -l [LISTENERS...] [OPTIONAL] | The event type to watch: move, modify, create, delete, io_close, io_open |
| --allow-folder | Allow folder events to trigger the daemon mode. Defaults to False |
| --always-overwrite-config | Always overwrite the config file with the provided host and token if they are different. Defaults to False |
- Manual Scan example:
plex-nfs-watchdog --scan --paths /path/to/library_section1/section_chield1 --host http://localhost:32400 --token YOUR_TOKEN - Daemon Scan example:
plex-nfs-watchdog --daemon --paths /path/to/library_section1 --host http://localhost:32400 --token YOUR_TOKEN --interval 150 --listeners move modify create delete
Notes
After the first successful run, a cache config file containing Plex's host and token will be created in the user's home directory. This file will be used for subsequent runs, so you don't have to provide them every time.
:dizzy: Contributing
If you are interested in contributing, please refer to Contributing Guidelines for more information and take a look at open issues. Ask any questions you may have and you will be provided guidance on how to get started.
Thank you for considering contributing.
:handshake: Support
If you find value in my work, please consider making a donation to help me create, and improve my projects.
Your donation will go a long way in helping me continue to create free software that can benefit people around the world.
:warning: License
The content of this repository is distributed under the GNU GPL-3.0 License. See LICENSE for more information.
:hammer_and_wrench: Built With
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file plex_nfs_watchdog-0.0.15.tar.gz.
File metadata
- Download URL: plex_nfs_watchdog-0.0.15.tar.gz
- Upload date:
- Size: 26.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5933a2822df2af102ec2320d50010daa9b88906c242e232985bb75ea5120825
|
|
| MD5 |
50460515edba27e1f9b861cd5abc0937
|
|
| BLAKE2b-256 |
733b61327dedea542aea91f9a9eca7de853f86f3a5c6d568dd0817ebeac8b38b
|
Provenance
The following attestation bundles were made for plex_nfs_watchdog-0.0.15.tar.gz:
Publisher:
python-publish.yml on LightDestory/PlexNFSWatchdog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plex_nfs_watchdog-0.0.15.tar.gz -
Subject digest:
c5933a2822df2af102ec2320d50010daa9b88906c242e232985bb75ea5120825 - Sigstore transparency entry: 206531828
- Sigstore integration time:
-
Permalink:
LightDestory/PlexNFSWatchdog@373fb2c01b1491a9b9891d7a25a6dd7ee2aca3ba -
Branch / Tag:
refs/tags/0.0.15 - Owner: https://github.com/LightDestory
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@373fb2c01b1491a9b9891d7a25a6dd7ee2aca3ba -
Trigger Event:
release
-
Statement type:
File details
Details for the file plex_nfs_watchdog-0.0.15-py3-none-any.whl.
File metadata
- Download URL: plex_nfs_watchdog-0.0.15-py3-none-any.whl
- Upload date:
- Size: 25.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ba42410a41100495cc3361e047014e6bc62e7014bd1ad7730528351617c4244
|
|
| MD5 |
267886b4146a85a7be123659b004fe6c
|
|
| BLAKE2b-256 |
df5449f84a8fb7226e34e7bc0179250d35be76fb1c4a69cf23c72baead5926ae
|
Provenance
The following attestation bundles were made for plex_nfs_watchdog-0.0.15-py3-none-any.whl:
Publisher:
python-publish.yml on LightDestory/PlexNFSWatchdog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plex_nfs_watchdog-0.0.15-py3-none-any.whl -
Subject digest:
9ba42410a41100495cc3361e047014e6bc62e7014bd1ad7730528351617c4244 - Sigstore transparency entry: 206531829
- Sigstore integration time:
-
Permalink:
LightDestory/PlexNFSWatchdog@373fb2c01b1491a9b9891d7a25a6dd7ee2aca3ba -
Branch / Tag:
refs/tags/0.0.15 - Owner: https://github.com/LightDestory
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@373fb2c01b1491a9b9891d7a25a6dd7ee2aca3ba -
Trigger Event:
release
-
Statement type: