This commit is contained in:
deathbybandaid 2023-03-15 08:23:22 -04:00
parent dad2cad2c4
commit a0d56c6ec0
4 changed files with 116 additions and 0 deletions

33
plex-cleanbundles.sh Normal file
View File

@ -0,0 +1,33 @@
#!/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
echo "Cleaning Bundles"
curl -X PUT 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

41
plex-emptytrash.sh Normal file
View File

@ -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 "Emptying Trash for key: ${library_number}"
curl -X PUT http://127.0.0.1:32400/library/sections/${library_number}/emptyTrash\?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

39
plex-refreshmetadata.sh Normal file
View File

@ -0,0 +1,39 @@
#!/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 "Running Library Update and metadata refresh for key: ${library_number}"
curl -X PUT http://127.0.0.1:32400/library/sections/${library_number}/refresh\?force=1\&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

View File

@ -5,6 +5,9 @@ echo "Welcome to plex-tools wrapper utility!"
case "$1" in
token) source ./plex-token.sh;;
freshen) source ./plex-freshen.sh;;
trash) source ./plex-emptytrash.sh;;
bundles) source ./plex-cleanbundles.sh;;
metadata) source ./plex-refreshmetadata.sh;;
claim) source ./claimpms.sh;;
sqlite) source ./plex-sqlite.sh;;
dbrepair) source ./DBRepair.sh stop auto start exit;;