Created
October 29, 2018 17:35
-
-
Save squaresmile/124f572679a8ad5d846031a649e983b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#probably needed to be run as plex user | |
export LD_LIBRARY_PATH="/usr/lib/plexmediaserver" | |
export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/var/lib/plexmediaserver/Library/Application Support" | |
arg=$1 | |
rtorrent_tv="/rtorrent/tv/" | |
union_tv="/union/tv/" | |
if [[ -f "$arg" ]]; then #check if it's a file | |
directory=$(dirname "$arg") #return base folder if it's a file | |
else | |
directory="$arg" | |
fi | |
#I haven't found a way to automate choosing library_id; the path replacement can probably be simplified based on your setup | |
if [[ $directory == ${rtorrent_tv}* ]]; then | |
scan_directory=${directory/$rtorrent_tv/$union_tv} #replace rtorrent path with union path | |
library_id=4 | |
fi | |
"/usr/lib/plexmediaserver/Plex Media Scanner" --scan --refresh --section "$library_id" --directory "$scan_directory" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment