Created
December 7, 2019 16:01
-
-
Save jamiew/bfb239673c4e62a437f40b5831f59e30 to your computer and use it in GitHub Desktop.
WIP script to intelligently upate my Plex library after sabnzbd downloads are done
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 | |
# sabnzbd post-download notification script for Plex | |
# Define $PLEX_TOKEN in your environment | |
# Debug arguments to sab | |
echo "Args:" | |
for word in "$@"; do | |
echo "$word" | |
done | |
# Debug our library mapping... this is also available via Plex API at | |
# curl -s http://localhost:32400/library/sections/?X-Plex-Token=$PLEX_TOKEN | |
echo "Listing all libraries:" | |
export LD_LIBRARY_PATH=/usr/lib/plexmediaserver | |
export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR='/var/lib/plexmediaserver/Library/Application Support' | |
/usr/lib/plexmediaserver/Plex\ Media\ Scanner --list | |
# echo "Updating using directory... 1=$1" | |
# This just totally hangs the process | |
# /usr/lib/plexmediaserver/Plex\ Media\ Scanner --scan --directory "$1" | |
# This returns, but doesn't seem to actually work | |
# /usr/lib/plexmediaserver/Plex\ Media\ Scanner --scan --directory "$1" --section 1 | |
# Scanning whole library works :( | |
# /usr/lib/plexmediaserver/Plex\ Media\ Scanner --scan --section 1 | |
# Using Plex API directly seems to behave better | |
echo "Mass-updating libraries..." | |
for id in 8 12 1 2; do | |
echo -n $id... | |
curl -s "http://localhost:32400/library/sections/$id/refresh?X-Plex-Token=$PLEX_TOKEN" | |
done | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, API version works great