diff --git a/plex-analyze.sh b/plex-analyze.sh new file mode 100644 index 0000000..e87b37a --- /dev/null +++ b/plex-analyze.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +update_from_cli() { + # ChuckPa already wrote a great function for getting host info + source ./HostConfig.sh + echo "Getting Host Information" + HostConfig + plex_scanner_location="$PKGDIR/Plex Media Scanner" + + echo "Getting Plex Library list" + echo $("$plex_scanner_location" --list) + + exit +} + +update_from_api() { + # get plex token + source ./plex-token.sh + + # run a loop against each library + for library_number in `curl -s -H "Accept: application/json" -H "X-Plex-Token: ${LOCAL_PLEX_TOKEN}" http://127.0.0.1:32400/library/sections | jq -M -r '.MediaContainer.Directory[] | "\(.key)"'` + do + + echo "Analyzing for key: ${library_number}" + curl -X PUT http://127.0.0.1:32400/library/sections/${library_number}/analyze\?X-Plex-Token=${LOCAL_PLEX_TOKEN} + + done + +} + +case "$2" in + cli) update_from_cli;; + ""|api) update_from_api;; + *) echo "'$2' is not a valid plex-tools freshen command";; +esac + + +# clean PhotoTranscoder Cache +#echo "Deleting PhotoTranscoder Cache" +#CACHEPATH="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder" +#find "${CACHEPATH}" -type f -delete diff --git a/plex-tools.sh b/plex-tools.sh index 166e842..1007b00 100644 --- a/plex-tools.sh +++ b/plex-tools.sh @@ -6,6 +6,7 @@ case "$1" in token) source ./plex-token.sh;; freshen) source ./plex-freshen.sh;; trash) source ./plex-emptytrash.sh;; + analyze) source ./plex-analyze.sh;; bundles) source ./plex-cleanbundles.sh;; metadata) source ./plex-refreshmetadata.sh;; claim) source ./claimpms.sh;;