RatingPosterDB / rpdb-folders

Monitors Media Folders and Adds Images with Ratings (poster.jpg / background.jpg) from the RPDB API
GNU Lesser General Public License v2.1
25 stars 2 forks source link

[Feature Request] Option to delay Plex Metadata Refresh #39

Closed ghost closed 2 years ago

ghost commented 2 years ago

[Feature Request] Option to delay Plex Metadata Refresh When I'm done with these GH issues, they'll have turned into a long novel. Sorry for the inconvenience. But hopefully all the explanations will make a better case, for why this feature would be nice to have. Atleast in my weird case/setup.

Is your feature request related to a problem? Please describe. As of now, there's no option to delay the Plex metadata refresh. In my case, this is a problem because if RPDB is installed on a different server than the one running Plex Media Server (PMS), the metadata refresh will have no effect because it will refresh the metadata when the poster file has not been updated.

My Setup pt1: Server Setup I have to dedicated servers, both running Linux/Ubuntu. Here's a short overview of what applications is running on the two servers:

Server 1 (SRV1): Download Server
- Bazarr
- Bazarr4K
- Mergerfs (fused cloud & local folders)
- NZBGet
- Nginx / Web server
- Prowlarr
- RPDB
- Radarr
- Radarr4K
- Rclone Mount (cloud storage)
- Sonarr
- Sonarr4K
- Tautulli
- qBittorrent

Server 2 (SRV2): PMS Server
- Doplarr
- Overseerr
- Plex Media Server
- Rclone Mount (cloud storage)

My Setup pt2: mergerfs & rclone On the SRV1 I use mergerfs and rclone's mount to get the local disks and cloud storage to work together in a very smooth way. The SRV2 doesn't use the mergerfs mount, ONLY the rclone mount for Plex to access the cloud storage drive.

Mergerfs primary function is to merge the two drives (the local drive and the mounted cloud storage drive) into a folder I called gmedia. The mergerfs mounting command looks like this:

/usr/bin/mergerfs /home/appbox/private/local:/home/appbox/m/gcd/plex /home/appbox/gmedia -o rw,use_ino,allow_other,func.getattr=newest,category.action=all,category.create=ff,cache.files=auto-
full,dropcacheonclose=true,cache.symlinks=true,cache.readdir=true

The folders fused are: /home/appbox/private/local is the local storage disk /home/appbox/m/gcd/plex is the cloud storage mount

into /home/appbox/gmedia. So the /gmedia folder will contain:

/gmedia
   /home/appbox/private/local/ [local storage folders]
   /home/appbox/m/gcd/plex/    [cloud storage folders]

But obviously fused together. So for the system and applications reading the /gmedia folder, it'll look as if both all the newly/daily downloaded files, and the files already present in the cloud storage mount, is all there in the same /gmedia folder.

The mergerfs command variables are setup like so:

My Setup pt3: How it works with RPDB So on SRV1, everything is pointed towards the fused folder, which is /gmedia Everything that gets saved to /gmedia actually gets saved to the local drive: /home/appbox/private/local, because of the mergerfs variables explained above.

RPDB is also setup to use the /gmedia folder. It'll do a daily scan with this simple script, starting at 11:00AM:

#!/bin/bash

# Exit if running
if [[ $(pidof -x "$(basename "$0")" -o %PPID) ]]; then
echo "Already running, exiting..."; exit 1; fi

/usr/bin/bash -c "/opt/rpdb/rpdb-folders --remote="full-scan"" >> /home/appbox/logs/rpdb/rpdb.log 2>&1

This will then scan the /gmedia folder. Which means it'll both scan all the folders in the cloud storage mount, and the locally downloaded ones. So for any newly downloaded movies, it'll download the poster.jpg files, and they'll get uploaded with the daily upload script. If an overwrite scan is to be done, all the new poster.jpg files generated, will also be saved to the local storage, and later uploaded with the daily upload script. This setup works wonderfully tbh. All credits to this dude.

This is the daily upload script. Which is just a fancy script for moving/uploading all the files from /home/appbox/private/local to the cloud storage. This script runs at 12:30AM every day, via a simple cronjob.

Then, as the files get uploaded to the cloud storage, the PMS on SRV2 picks it up automatically, and scans the new items/movies/series in automatically.

My Setup pt4: The real problem The real problem is now this: On SRV1 it'll download the poster.jpg files for the newly downloaded movies and series. And that'll tell RPDB to tell Plex to Refresh the Metadata for the movies that has either been updated or got a new poster.jpg generated.

On SRV2 meanwhile, this will have no effect, since the poster.jpg file is still on SRV1 as local storage, and has not yet been uploaded through the daily upload script.

Describe the solution you'd like The perfect solution would obviously be a "delay" feature, to the Plex Metadata Refresh. I would love to be able to delay the Metadata Refresh to after my upload script has done running, which in my case would be around 4:00PM.

This poses several problems though, as RPDB needs to save, log and/or cache all the previous movie/series matches and poster.jpg upgrades, to be able to remember what movies/series it'll need to do a metadata refresh.

E.g. if the RPDB app closes/crashes, or if the server rebooted, the refresh wouldn't happen, as it would have lost the saved data.

So maybe if RPDB utilized some sort of database file/sqlite/mariadb/postgres for storing the matches, that have to be delayed. Just the thought of working with database-files makes my head hurt, so I can't fault you, if you hate that idea.

Additional context Sorry again for these massive wall of texts. And sorry if there are parts that doesn't make any sense.

jaruba commented 2 years ago

@VP-EN

I'm not sure if it will work as expected for your scenario, but I hope it will. In the new v0.2.0 version I added a Time of Day setting to Plex updates. I did not test this properly at all though, so please comment with feedback.

I will consider this issue resolved in the meanwhile, you can reopen it if needed.