From 8f77d45db24897f216379fe95afb512a9b70053a Mon Sep 17 00:00:00 2001 From: TheCaptain989 Date: Thu, 31 Aug 2023 20:05:06 -0500 Subject: [PATCH] Update striptracks.sh - Second attempt at bug fix (commit 75039d3) --- root/usr/local/bin/striptracks.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/root/usr/local/bin/striptracks.sh b/root/usr/local/bin/striptracks.sh index 1650875..cf82a3b 100755 --- a/root/usr/local/bin/striptracks.sh +++ b/root/usr/local/bin/striptracks.sh @@ -612,7 +612,7 @@ function get_rename { function rename_video { local url="$striptracks_api_url/command" local data="{\"name\":\"RenameFiles\",\"${striptracks_video_type}Id\":$striptracks_rescan_id,\"files\":[$striptracks_videofile_id]}" - echo "Info|Renaming new video file per ${striptracks_type^}'s rules to \"${striptracks_renamedvideo##*/}\"" | log + echo "Info|Renaming new video file per ${striptracks_type^}'s rules to \"$(basename "$striptracks_renamedvideo")\"" | log [ $striptracks_debug -ge 1 ] && echo "Debug|Renaming \"$striptracks_newvideo\". Calling ${striptracks_type^} API using POST and URL '$url' with data $data" | log unset striptracks_result striptracks_result=$(curl -s --fail-with-body -H "X-Api-Key: $striptracks_apikey" \ @@ -1287,13 +1287,12 @@ elif [ -n "$striptracks_api_url" ]; then } # Check if new video is in list of files that can be renamed if [ -n "$striptracks_result" -a "$striptracks_result" != "[]" ]; then - striptracks_videofile_id="$(echo $striptracks_result | jq -crM ".[] | select(.existingPath | endswith(\"${striptracks_newvideo##*/}\")) | .${striptracks_json_quality_root}Id")" - striptracks_renamedvideo="${striptracks_newvideo%/*}/$(echo $striptracks_result | jq -crM ".[] | select(.existingPath | endswith(\"${striptracks_newvideo##*/}\")) | .newPath")" + striptracks_renamedvideo="$(echo $striptracks_result | jq -crM ".[] | select(.${striptracks_json_quality_root}Id == $striptracks_videofile_id) | .newPath")" # Rename video if needed - if [ -n "$striptracks_videofile_id" ]; then + if [ -n "$striptracks_renamedvideo" ]; then rename_video striptracks_return=$?; [ $striptracks_return -ne 0 ] && { - striptracks_message="Error|[$striptracks_return] ${striptracks_type^} error when renaming \"${striptracks_newvideo##*/}\" to \"${striptracks_renamedvideo##*/}\"" + striptracks_message="Error|[$striptracks_return] ${striptracks_type^} error when renaming \"$(basename "$striptracks_newvideo")\" to \"$(basename "$striptracks_renamedvideo")\"" echo "$striptracks_message" | log echo "$striptracks_message" >&2 striptracks_exitstatus=17