Skip to content

Commit f71e56b

Browse files
authored
Merge pull request #935 from TheCaptain989/radarr-striptracks
radarr: striptracks release 2.7.1
2 parents 24cf09e + f8305b0 commit f71e56b

File tree

6 files changed

+106
-19
lines changed

6 files changed

+106
-19
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.gitignore
44
.github
55
.gitattributes
6+
.vscode
67
.assets
78
READMETEMPLATE.md
89
README.md

.github/workflows/BuildImage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
echo "MODNAME=${{ env.MODNAME }}" >> $GITHUB_OUTPUT
2323
echo "MULTI_ARCH=${{ env.MULTI_ARCH }}" >> $GITHUB_OUTPUT
2424
# **** If the mod needs to be versioned, set the versioning logic below. Otherwise leave as is. ****
25-
MOD_VERSION=${GITHUB_SHA:0:7}
25+
MOD_VERSION="2.7.1"
2626
echo "MOD_VERSION=${MOD_VERSION}" >> $GITHUB_OUTPUT
2727
outputs:
2828
GITHUB_REPO: ${{ steps.outputs.outputs.GITHUB_REPO }}

Dockerfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# syntax=docker/dockerfile:1
22

33
## Buildstage ##
4-
FROM ghcr.io/linuxserver/baseimage-alpine:3.19 as buildstage
5-
4+
FROM ghcr.io/linuxserver/baseimage-alpine:3.20 as buildstage
65
ARG MOD_VERSION
76

87
# copy local files
@@ -17,11 +16,14 @@ RUN \
1716

1817
## Single layer deployed image ##
1918
FROM scratch
19+
ARG MOD_VERSION
2020

21-
LABEL org.opencontainers.image.source=https://github.com/TheCaptain989/radarr-striptracks
21+
LABEL org.opencontainers.image.title=radarr-striptracks
2222
LABEL org.opencontainers.image.description="A Docker Mod to Radarr/Sonarr to automatically strip out unwanted audio and subtitle streams"
23+
LABEL org.opencontainers.image.version="${MOD_VERSION}"
24+
LABEL org.opencontainers.image.source="https://github.com/TheCaptain989/radarr-striptracks"
25+
LABEL org.opencontainers.image.authors="TheCaptain989 <thecaptain989@protonmail.com>"
2326
LABEL org.opencontainers.image.licenses=GPL-3.0-only
24-
LABEL org.opencontainers.image.authors="TheCaptain989"
2527

2628
# Add files from buildstage
2729
COPY --from=buildstage /root-layer/ /

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# About
2-
A [Docker Mod](https://github.com/linuxserver/docker-mods) for the LinuxServer.io Radarr/Sonarr v3 Docker container that adds a script to automatically strip out unwanted audio and subtitle tracks, keeping only the desired languages.
3-
4-
**Beginning with version 2.0 of this mod, it only supports v3 or later of Radarr/Sonarr. For legacy Radarr/Sonarr v2 please use mod release 1.3 or earlier**
2+
A [Docker Mod](https://github.com/linuxserver/docker-mods) for the LinuxServer.io Radarr/Sonarr v3 or higher Docker containers that adds a script to automatically strip out unwanted audio and subtitle tracks, keeping only the desired languages.
53

64
**This unified script works in both Radarr and Sonarr. Use this mod in either container!**
75
>**NOTE:** This mod supports Linux OSes only.
8-
9-
Production Container info: ![Docker Image Size](https://img.shields.io/docker/image-size/linuxserver/mods/radarr-striptracks "Container Size")
6+
<!-- markdownlint-disable -->
7+
Production Container info: ![Docker Image Size](https://img.shields.io/docker/image-size/linuxserver/mods/radarr-striptracks "Container Size")
8+
[![linuxserver/docker-mods/mods/radarr-striptracks](https://img.shields.io/badge/dynamic/json?logo=github&url=https%3A%2F%2Fraw.githubusercontent.com%2Fthecaptain989%2Fghcr-pulls%2Fmaster%2Findex.json&query=%24%5B%3F(%40.owner%3D%3D%22linuxserver%22%20%26%26%20%40.repo%3D%3D%22docker-mods%22%20%26%26%20%40.image%3D%3D%22mods%22%20%26%26%20%40.tag%3D%3D%22radarr-striptracks%22)%5D.pulls&label=ghcr%20pulls&color=1572A4)](https://github.com/linuxserver/docker-mods/pkgs/container/mods)
109
Development Container info:
1110
![Docker Image Size](https://img.shields.io/docker/image-size/thecaptain989/radarr-striptracks "Container Size")
12-
![Docker Pulls](https://img.shields.io/docker/pulls/thecaptain989/radarr-striptracks "Container Pulls")
11+
![Docker Pulls](https://img.shields.io/docker/pulls/thecaptain989/radarr-striptracks?logo=docker "Container Pulls")
1312
[![GitHub Super-Linter](https://github.com/TheCaptain989/radarr-striptracks/actions/workflows/linter.yml/badge.svg)](https://github.com/TheCaptain989/radarr-striptracks/actions/workflows/linter.yml "Linter Job")
13+
<!-- markdownlint-restore -->
1414

1515
# Installation
1616
1. Pull your selected container ([linuxserver/radarr](https://hub.docker.com/r/linuxserver/radarr "LinuxServer.io's Radarr container") or [linuxserver/sonarr](https://hub.docker.com/r/linuxserver/sonarr "LinuxServer.io's Sonarr container")) from GitHub Container Registry or Docker Hub:
@@ -101,7 +101,7 @@ The language selection **'Unknown'** will match tracks with **no configured lang
101101

102102
The Radarr language selection **'Any'** has two purposes:
103103
1) It will trigger a search of languages in ***Custom Formats***
104-
2) If none are found, it will will preserve **all languages** in the video file. This is functionally equivalent to calling the script with `--audio :any --subs :any` command-line options. See [Any language code](./README.md#any-language-code) below for more details.
104+
2) If none are found, it will preserve **all languages** in the video file. This is functionally equivalent to calling the script with `--audio :any --subs :any` command-line options. See [Any language code](./README.md#any-language-code) below for more details.
105105

106106
>**Note:** When using the *Custom Format* conditions and scoring to select languages you may not get the results you expect.
107107
>This can be non-intuitive configuration, especially when using negative scoring and the 'Negate' option.
@@ -154,15 +154,15 @@ Where:
154154

155155
Option|Argument|Description
156156
---|---|---
157-
-a, --audio|<audio_languages>|Audio languages to keep<br/>ISO639-2 code(s) prefixed with a colon (`:`)
158-
-s, --subs|<subtitle_languages>|Subtitle languages to keep<br/>IISO639-2 code(s) prefixed with a colon (`:`)
157+
-a, --audio|<audio_languages>|Audio languages to keep<br/>ISO 639-2 code(s) prefixed with a colon (`:`)
158+
-s, --subs|<subtitle_languages>|Subtitle languages to keep<br/>ISO 639-2 code(s) prefixed with a colon (`:`)
159159
-f, --file|<video_file>|If included, the script enters **[Batch Mode](./README.md#batch-mode)** and converts the specified video file.<br/>Requires the `-a` option.<br/>![danger] **WARNING:** Do not use this argument when called from Radarr or Sonarr!
160160
-l, --log|\<log_file\>|The log filename<br/>Default of /config/log/striptracks.txt
161161
-d, --debug|\[\<level\>\]|Enables debug logging. Level is optional.<br/>Default of 1 (low)<br/>2 includes JSON output<br/>3 contains even more JSON output
162162
--help| |Display help and exit.
163163
--version| |Display version and exit.
164164

165-
The `<audio_languages>` and `<subtitle_languages>` are optional arguments that are colon (`:`) prepended language codes in [ISO639-2](https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes "List of ISO 639-2 codes") format.
165+
The `<audio_languages>` and `<subtitle_languages>` are optional arguments that are colon (`:`) prepended language codes in [ISO 639-2](https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes "List of ISO 639-2 codes") format.
166166
For example:
167167

168168
* `:eng`
@@ -188,7 +188,7 @@ Several [Included Wrapper Scripts](./README.md#included-wrapper-scripts) use thi
188188

189189
### Unknown language code
190190
The `:und` language code is a special code. When used, the script will match on any track that has a null or blank language attribute. If not included, tracks with no language attribute will be removed.
191-
>![danger] **NOTE:** It is common for M2TS and AVI containers to have tracks with unknown languages! It is strongly recommended to include `:und` in most instances unless you know exactly what you're doing.
191+
>![danger] **NOTE:** It is common for M2TS and AVI files to have tracks with unknown languages! It is strongly recommended to include `:und` in most instances unless you know exactly what you're doing.
192192

193193
## Special Handling of Audio
194194
The script is smart enough to not remove the last audio track. There is in fact no way to force the script to remove all audio. This way you don't have to specify every possible language if you are importing a foreign film, for example.
@@ -336,5 +336,8 @@ This would not be possible without the following:
336336
The AWK script parsing mkvmerge output is adapted from Endoro's post on [VideoHelp](https://forum.videohelp.com/threads/343271-BULK-remove-non-English-tracks-from-MKV-container#post2292889).
337337
Icons made by [Freepik](https://www.freepik.com) from [Flaticon](https://www.flaticon.com/)
338338

339+
## Legacy Change Notes
340+
Beginning with version 2.0 of this mod, it only supports v3 or later of Radarr/Sonarr. For legacy Radarr/Sonarr v2 please use mod release 1.3 or earlier.
341+
339342
[warning]: .assets/warning.png "Warning"
340343
[danger]: .assets/danger.png "Danger"

SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Only the latest major and minor version are supported.
66

77
| Version | Supported |
88
| ------- | ------------------ |
9-
| 2.6.x | :heavy_check_mark: |
10-
| < 2.6 | :x: |
9+
| 2.7.x | :heavy_check_mark: |
10+
| < 2.7 | :x: |
1111

1212
## Reporting a Vulnerability
1313

root/usr/local/bin/striptracks.sh

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,63 @@ function check_compat {
809809
[ $striptracks_debug -ge 1 ] && echo "Debug|Feature $1 is $([ $striptracks_return -eq 1 ] && echo "not ")compatible with ${striptracks_type^} v${striptracks_arr_version}." | log
810810
return $striptracks_return
811811
}
812+
# Get media management configuration
813+
function get_media_config {
814+
local url="$striptracks_api_url/config/mediamanagement"
815+
[ $striptracks_debug -ge 1 ] && echo "Debug|Getting ${striptracks_type^} configuration. Calling ${striptracks_type^} API using GET and URL '$url'" | log
816+
unset striptracks_result
817+
striptracks_result=$(curl -s --fail-with-body -H "X-Api-Key: $striptracks_apikey" \
818+
-H "Content-Type: application/json" \
819+
-H "Accept: application/json" \
820+
--get "$url")
821+
local striptracks_curlret=$?; [ $striptracks_curlret -ne 0 ] && {
822+
local striptracks_message=$(echo -e "[$striptracks_curlret] curl error when calling: \"$url\"\nWeb server returned: $(echo $striptracks_result | jq -jcrM .message?)" | awk '{print "Error|"$0}')
823+
echo "$striptracks_message" | log
824+
echo "$striptracks_message" >&2
825+
}
826+
[ $striptracks_debug -ge 2 ] && echo "API returned: $striptracks_result" | awk '{print "Debug|"$0}' | log
827+
if [ "$(echo $striptracks_result | jq -crM '.id?')" != "null" ] && [ "$(echo $striptracks_result | jq -crM '.id?')" != "" ]; then
828+
local striptracks_return=0
829+
else
830+
local striptracks_return=1
831+
fi
832+
return $striptracks_return
833+
}
834+
# Update file metadata in Radarr/Sonarr
835+
function set_video_info {
836+
local url="$striptracks_api_url/$striptracks_video_api/$striptracks_video_id"
837+
local data="$(echo $striptracks_videoinfo | jq -crM .monitored='true')"
838+
local i=0
839+
for ((i=1; i <= 5; i++)); do
840+
[ $striptracks_debug -ge 1 ] && echo "Debug|Updating monitored to 'true'. Calling ${striptracks_type^} API using PUT and URL '$url' with data $data" | log
841+
unset striptracks_result
842+
striptracks_result=$(curl -s --fail-with-body -H "X-Api-Key: $striptracks_apikey" \
843+
-H "Content-Type: application/json" \
844+
-H "Accept: application/json" \
845+
-d "$data" \
846+
-X PUT "$url")
847+
local striptracks_curlret=$?; [ $striptracks_curlret -ne 0 ] && {
848+
local striptracks_message=$(echo -e "[$striptracks_curlret] curl error when calling: \"$url\" with data $data\nWeb server returned: $(echo $striptracks_result | jq -jcrM .message?)" | awk '{print "Error|"$0}')
849+
echo "$striptracks_message" | log
850+
echo "$striptracks_message" >&2
851+
}
852+
[ $striptracks_debug -ge 2 ] && echo "Debug|API returned ${#striptracks_result} bytes." | log
853+
[ $striptracks_debug -ge 3 ] && echo "API returned: $striptracks_result" | awk '{print "Debug|"$0}' | log
854+
# Exit loop if database is not locked, else wait 1 minute
855+
if [[ ! "$(echo $striptracks_result | jq -jcrM .message?)" =~ database\ is\ locked ]]; then
856+
break
857+
else
858+
echo "Warn|Database is locked; system is likely overloaded. Sleeping 1 minute." | log
859+
sleep 60
860+
fi
861+
done
862+
if [ $striptracks_curlret -eq 0 -a "${#striptracks_result}" != 0 ]; then
863+
local striptracks_return=0
864+
else
865+
local striptracks_return=1
866+
fi
867+
return $striptracks_return
868+
}
812869
# Exit program
813870
function end_script {
814871
# Cool bash feature
@@ -1140,6 +1197,20 @@ elif [ -n "$striptracks_api_url" ]; then
11401197
echo "$striptracks_message" >&2
11411198
striptracks_exitstatus=17
11421199
fi
1200+
# Check if Radarr/Sonarr are configured to unmonitor deleted videos
1201+
get_media_config
1202+
striptracks_return=$?; [ $striptracks_return -ne 0 ] && {
1203+
# No '.id' in returned JSON
1204+
striptracks_message="Warn|The Media Management Config API returned no id."
1205+
echo "$striptracks_message" | log
1206+
echo "$striptracks_message" >&2
1207+
striptracks_exitstatus=17
1208+
}
1209+
if [ "$(echo "$striptracks_result" | jq -crM ".autoUnmonitorPreviouslyDownloaded${striptracks_video_api^}s")" = "true" ]; then
1210+
striptracks_conf_unmonitor=1
1211+
striptracks_message="Warn|Will compensate for ${striptracks_type^} configuration to unmonitor deleted ${striptracks_video_api}s."
1212+
echo "$striptracks_message" | log
1213+
fi
11431214
else
11441215
# No URL means we can't call the API
11451216
striptracks_message="Warn|Unable to determine ${striptracks_type^} API URL."
@@ -1518,8 +1589,18 @@ elif [ -n "$striptracks_api_url" ]; then
15181589

15191590
# Get new video file id
15201591
if get_video_info; then
1521-
striptracks_videofile_id="$(echo $striptracks_result | jq -crM .${striptracks_json_quality_root}.id)"
1592+
striptracks_videoinfo="$striptracks_result"
1593+
striptracks_videofile_id="$(echo $striptracks_videoinfo | jq -crM .${striptracks_json_quality_root}.id)"
15221594
[ $striptracks_debug -ge 1 ] && echo "Debug|Using new video file id '$striptracks_videofile_id'" | log
1595+
1596+
# Check if video is unmonitored after the delete/import
1597+
if [ $striptracks_conf_unmonitor -eq 1 -a "$(echo "$striptracks_videoinfo" | jq -crM ".monitored")" = "false" ]; then
1598+
striptracks_message="Warn|'$striptracks_title' is unmonitored after deleting the original video. Compensating for ${striptracks_type^} configuration."
1599+
echo "$striptracks_message" | log
1600+
# Set video to monitored again
1601+
set_video_info
1602+
fi
1603+
15231604
# Get new video file info
15241605
if get_videofile_info; then
15251606
striptracks_videofile_info="$striptracks_result"

0 commit comments

Comments
 (0)