Skip to content

Instantly share code, notes, and snippets.

@hazcod
Last active May 12, 2020 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hazcod/f5f1d6df32affb3e170bfe917577a774 to your computer and use it in GitHub Desktop.
Save hazcod/f5f1d6df32affb3e170bfe917577a774 to your computer and use it in GitHub Desktop.
Sonarr & Plex plex scanner.
#!/usr/bin/env bash
type="$1"
PLEXSCAN="/Applications/Plex Media Server.app/Contents/MacOS/Plex Media Scanner"
if [ "$type" != "Series" ] && [ "$type" != "Movies" ]; then
echo "Unknown type: $type"
exit 1
fi
section=""
if [ "$type" == "Series" ]; then
from="${sonarr_episodefile_path}"
section="2"
fi
if [ "$type" == "Movies" ]; then
from="${radarr_movie_path}"
section="1"
fi
if [ -z "$from" ]; then
echo "Not uploading empty FROM"
exit
fi
scandir="$(dirname "$from")/"
echo "Scanning media to Plex: $scandir"
"$PLEXSCAN" --verbose --section "$section" --directory "$scandir" --scan --refresh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment