From a0d56c6ec04026f283bd38a691117f5bc2c83c2d Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 15 Mar 2023 08:23:22 -0400 Subject: [PATCH] test --- plex-cleanbundles.sh | 33 +++++++++++++++++++++++++++++++++ plex-emptytrash.sh | 41 +++++++++++++++++++++++++++++++++++++++++ plex-refreshmetadata.sh | 39 +++++++++++++++++++++++++++++++++++++++ plex-tools.sh | 3 +++ 4 files changed, 116 insertions(+) create mode 100644 plex-cleanbundles.sh create mode 100644 plex-emptytrash.sh create mode 100644 plex-refreshmetadata.sh diff --git a/plex-cleanbundles.sh b/plex-cleanbundles.sh new file mode 100644 index 0000000..be7f69b --- /dev/null +++ b/plex-cleanbundles.sh @@ -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 diff --git a/plex-emptytrash.sh b/plex-emptytrash.sh new file mode 100644 index 0000000..beccd71 --- /dev/null +++ b/plex-emptytrash.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 "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 diff --git a/plex-refreshmetadata.sh b/plex-refreshmetadata.sh new file mode 100644 index 0000000..cbb37df --- /dev/null +++ b/plex-refreshmetadata.sh @@ -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 diff --git a/plex-tools.sh b/plex-tools.sh index bd9e3eb..166e842 100644 --- a/plex-tools.sh +++ b/plex-tools.sh @@ -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;;