A small little program that will monitor an rclone log file waiting for notices of file cache expiration. Upon receiving a notice, a local Plex scan of that folder will be triggered and new media will appear in Plex almost instantly.
This is useful for people who run Plex Media Server on a different server than Sonarr/Radarr/etc. It's possible to have media appear in your Plex server within 5-10 minutes of downloading using this program, along with an rclone --cache-tmp-wait-time 5m
.
--log-level INFO
--syslog
OR --log-file /path/to/file.log
git clone https://github.com/stokkes/plex_rcs.git
sudo pip3 install -r requirements.txt
config.yml.default
to config.yml
config.yml
to include your X-Plex-Token, set your media_root
setting and any other settings. _See below for more information on the media_root
setting_.There are two ways I recommend you run this. Using screen
or using the included plex_rcs.service
systemd service (coming soon).
screen
Execute the program using screen:
/usr/bin/screen -dmS plexrcs /path/to/plex_rcs/plex_rcs.py
To view the console: screen -r plexrcs
Coming soon
plex_rcs.service
file and change the path to where the plex_rcs.py
file is located/etc/systemd/service
: sudo cp plex_rcs.service /etc/systemd/service
sudo systemctl daemon-reload
sudo systemctl enable plex_rcs
sudo systemctl start plex_rcs
media_root
configuration settingThis setting may be tricky to figure out at the first glance, but it is critical to get plex_rcs
working properly.
The value of this setting is the folder inside your docker container (if using docker) that contains all your media. Typically, this would be in /media
. If not using docker, this will likely be the path to your rclone cache
remote mount, i.e.: /mnt/media
However, at this time there is 1 requirement:
The root of your rclone cache
remote (i.e.: gdrive-cache:
) must contain all your media in sub-folders, so that the remote and the folder that is mounted inside your docker container/on your system both contain the same sub-folders.
How to test:
rclone lsd cache:
anddocker exec -ti plex ls /media
(where /media
is where your media is located inside your docker container)ls /path/to/rclone/cache/mount
If the result of these two folders yield the same sub-folders, then plex_rcs
will work correctly.
What won't work
rclone lsd cache:
shows many different folders, not just media sub-folderscache:
remote to /mnt/media
using something like rclone mount cache:Media /mnt/media
docker exec -ti plex ls /media
shows only your media sub-foldersI hope to build some logic to help figure this out, but don't hold your breath.
You can test plex_rcs
if you use the built in /var/log/syslog monitoring by executing the following command (replace tvshows
and the series/episode by your values):
logger "Apr 21 07:20:51 plex rclone[21009]: tvshows/Survivor/Season 20/Survivor - S20E01 - Episode.mkv: received cache expiry notification"
If you're monitoring the plex_rcs
console, you should see activity:
Starting to monitor /var/log/syslog with pattern for rclone
Match found: tvshows/Survivor/Season 20/Survivor - S20E01 - Episode.mkv
Processing section 1, folder: /media/tvshows/Survivor/Season 20
GUI: Scanning Survivor/Season 20