50 lines
1.2 KiB
Bash
50 lines
1.2 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
|
|
|
|
array=$LOCAL_LIBRARIES_IDS
|
|
array2=$LOCAL_LIBRARIES_TITLES
|
|
|
|
# run a loop against each library
|
|
echo "Emptying Trash for all libraries"
|
|
i=0
|
|
while [ $i -lt ${#array[*]} ]; do
|
|
echo ${array[$i]} is in ${array2[$i]}
|
|
i=$(( $i + 1));
|
|
done
|
|
|
|
for index in ${!LOCAL_LIBRARIES_[*]}
|
|
do
|
|
library_id=${LOCAL_LIBRARIES_IDS[$index]}
|
|
#"${LOCAL_LIBRARIES_IDS[index]}"
|
|
library_title="${LOCAL_LIBRARIES_TITLES[index]}"
|
|
|
|
echo "Emptying Trash for Library: ${library_id} ${library_title}"
|
|
curl -X GET http://127.0.0.1:32400/library/sections/${library_id}/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
|