plex-tools/plex-freshen.sh
deathbybandaid fe5aba277f test
2024-02-22 08:16:40 -05:00

49 lines
1.3 KiB
Bash

#!/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
source ./plex-library-ids.sh
# run a loop against each library
for library_number in $LOCAL_LIBRARIES_IDS
do
echo "Running Library Update and metadata refresh for key: ${library_number}"
curl -X GET http://127.0.0.1:32400/library/sections/${library_number}/refresh\?force=1\&X-Plex-Token=${LOCAL_PLEX_TOKEN}
echo "Emptying Trash for key: ${library_number}"
curl -X GET http://127.0.0.1:32400/library/sections/${library_number}/emptyTrash\?X-Plex-Token=${LOCAL_PLEX_TOKEN}
done
echo "Cleaning Bundles"
curl -X GET http://127.0.0.1:32400/library/clean/bundles?X-Plex-Token=${LOCAL_PLEX_TOKEN}
}
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