Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/BuildImage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
echo "MULTI_ARCH=${{ env.MULTI_ARCH }}" >> $GITHUB_OUTPUT
if [[ -z "${{ env.MOD_VERSION }}" ]]; then
# **** If the mod needs to be versioned, set the versioning logic below. Otherwise leave as is. ****
MOD_VERSION="2.19.0"
MOD_VERSION="2.19.2"
else
MOD_VERSION=${{ env.MOD_VERSION }}
echo "MOD_VERSION_OVERRIDE=true" >> $GITHUB_OUTPUT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

cat <<EOF
----------------
Expand All @@ -23,14 +24,14 @@ fi
for file in /usr/local/bin/striptracks*.sh
do
# Change ownership
if [ $(stat -c '%G' $file) != "abc" ]; then
if [ "$(stat -c '%G' "$file")" != "abc" ]; then
echo "Changing ownership on $file script."
lsiown abc:abc $file
lsiown abc:abc "$file"
fi

# Make executable
if [ ! -x $file ]; then
if [ ! -x "$file" ]; then
echo "Making $file script executable."
chmod +x $file
chmod +x "$file"
fi
done
43 changes: 27 additions & 16 deletions root/usr/local/bin/striptracks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -980,49 +980,60 @@ function call_api {
local message="$2" # Message to log
local method="$3" # HTTP method to use (GET, POST, PUT, DELETE)
local endpoint="$4" # API endpoint to call
local data # Data to send with the request. All subsequent arguments are treated as data.
local -a curl_data_args=() # Use array instead of string for safer argument passing (see issue #118)

# Process remaining data values
shift 4
while (( "$#" )); do
# Escape double quotes in data parameter
local param="${1//\"/\\\"}"
case "$param" in
case "$1" in
"{"*|"["*)
data+=" --json \"$param\""
curl_data_args+=(--json "$1")
shift
;;
*=*)
data+=" --data-urlencode \"$param\""
curl_data_args+=(--data-urlencode "$1")
shift
;;
*)
data+=" --data-raw \"$param\""
curl_data_args+=(--data-raw "$1")
shift
;;
esac
done

local -a curl_args=(
-s
--fail-with-body
-H "X-Api-Key: $striptracks_apikey"
-H "Content-Type: application/json"
-H "Accept: application/json"
)

local url="$striptracks_api_url/$endpoint"
[ $striptracks_debug -ge 1 ] && echo "Debug|$message Calling ${striptracks_type^} API using $method and URL '$url'${data:+ with$data}" | log
local data_info=""
[ ${#curl_data_args[@]} -gt 0 ] && data_info=" with data: ${curl_data_args[*]}"
[ $striptracks_debug -ge 1 ] && echo "Debug|$message Calling ${striptracks_type^} API using $method and URL '$url'$data_info" | log
if [ "$method" = "GET" ]; then
method="-G"
curl_args+=(-G)
else
method="-X $method"
curl_args+=(-X "$method")
fi
local curl_cmd="curl -s --fail-with-body -H \"X-Api-Key: $striptracks_apikey\" -H \"Content-Type: application/json\" -H \"Accept: application/json\" ${data:+$data} $method \"$url\""
[ $striptracks_debug -ge 2 ] && echo "Debug|Executing: $curl_cmd" | sed -E 's/(X-Api-Key: )[^"]+/\1[REDACTED]/' | log
# Add data arguments and url to curl arguments array
curl_args+=("${curl_data_args[@]}")
curl_args+=(--url "$url")
[ $striptracks_debug -ge 2 ] && echo "Debug|Executing: curl ${curl_args[*]}" | sed -E 's/(X-Api-Key: )[^ ]+/\1[REDACTED]/' | log
unset striptracks_result
# (See issue #104)
declare -g striptracks_result

# Retry up to five times if database is locked
local i=0
for ((i=1; i <= 5; i++)); do
striptracks_result=$(eval "$curl_cmd")
striptracks_result=$(curl "${curl_args[@]}")
local curl_return=$?
if [ $curl_return -ne 0 ]; then
local message=$(echo -e "[$curl_return] curl error when calling: \"$url\"${data:+ with$data}\nWeb server returned: $(echo $striptracks_result | jq -jcM 'if type=="array" then map(.errorMessage) | join(", ") else (if has("title") then "[HTTP \(.status?)] \(.title?) \(.errors?)" elif has("message") then .message else "Unknown JSON format." end) end')" | awk '{print "Error|"$0}')
local error_message="$(echo $striptracks_result | jq -jcM 'if type=="array" then map(.errorMessage) | join(", ") else (if has("title") then "[HTTP \(.status?)] \(.title) \(.errors?)" elif has("message") then .message else "Unknown JSON format." end) end')"
local message=$(echo -e "[$curl_return] curl error when calling: \"$url\"$data_info\nWeb server returned: $error_message" | awk '{print "Error|"$0}')
echo "$message" | log
echo "$message" >&2
break
Expand Down Expand Up @@ -1133,7 +1144,8 @@ function check_video {
# Create temporary filename
local basename="$(basename -- "${striptracks_video}")"
local fileroot="${basename%.*}"
export striptracks_tempvideo="$(dirname -- "${striptracks_video}")/$(mktemp -u -- "${fileroot:0:5}.tmp.XXXXXX")"
# ._ prefixed files are ignored by Radarr/Sonarr (see issues #65 and #115)
export striptracks_tempvideo="$(dirname -- "${striptracks_video}")/$(mktemp -u -- "._${fileroot:0:5}.tmp.XXXXXX")"
[ $striptracks_debug -ge 1 ] && echo "Debug|Using temporary file \"$striptracks_tempvideo\"" | log
}
function detect_languages {
Expand Down Expand Up @@ -1260,7 +1272,6 @@ function detect_languages {
local message="Warn|No languages found in any profile or custom format. Unable to use automatic language detection."
echo "$message" | log
echo "$message" >&2
change_exit_status 20
else
# Final determination of configured languages in profiles or custom formats
local profileLangNames="$(echo $profileLanguages | jq -crM '[.[].name]')"
Expand Down