# Install Dependency: apt-get install jq $PLEX_USERNAME="youremail@host.com" $PLEX_PASSWORD="yourpassword" $LIBRARY_TITLE="Movies" #TV, Music, etc PLEX_TOKEN=`curl -s -X POST \ -H "X-Plex-Client-Identifier: jenkins" \ -H "X-Plex-Product: jenkins" \ -H "X-Plex-Version: 1.0.0" \ --user $PLEX_USERNAME:$PLEX_PASSWORD \ https://plex.tv/users/sign_in.json | jq -r .user.authToken` LIBRARY_KEY=`curl -H 'Accept: application/json' \ http://localhost:32400/library/sections?X-Plex-Token=$PLEX_TOKEN | \ jq -r ".MediaContainer.Directory[] | select(.title==\"$LIBRARY_TITLE\") | .key"` echo "Library key for $LIBRARY_TITLE is $LIBRARY_KEY" curl "http://localhost:32400/library/sections/$LIBRARY_KEY/refresh?X-Plex-Token=$PLEX_TOKEN"