Skip to content

Instantly share code, notes, and snippets.

@eralpkaraduman
Created November 12, 2019 23:05
Show Gist options
  • Save eralpkaraduman/3d5d4bd64ca42a8197d8eb36fe536318 to your computer and use it in GitHub Desktop.
Save eralpkaraduman/3d5d4bd64ca42a8197d8eb36fe536318 to your computer and use it in GitHub Desktop.
refreshing PLEX libraries by $LIBRARY_KEY using http api
# Install Dependency: apt-get install jq
$PLEX_USERNAME="[email protected]"
$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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment