diff --git a/.assets/add-custom-format.png b/.assets/add-custom-format.png
new file mode 100644
index 0000000..9940c52
Binary files /dev/null and b/.assets/add-custom-format.png differ
diff --git a/.assets/add-language-condition.png b/.assets/add-language-condition.png
new file mode 100644
index 0000000..18d06f1
Binary files /dev/null and b/.assets/add-language-condition.png differ
diff --git a/.assets/custom-format-condition.png b/.assets/custom-format-condition.png
deleted file mode 100644
index d24c862..0000000
Binary files a/.assets/custom-format-condition.png and /dev/null differ
diff --git a/.assets/custom-format-conditions.png b/.assets/custom-format-conditions.png
new file mode 100644
index 0000000..7df17e4
Binary files /dev/null and b/.assets/custom-format-conditions.png differ
diff --git a/.assets/custom-format-score.png b/.assets/custom-format-score.png
deleted file mode 100644
index a77eb41..0000000
Binary files a/.assets/custom-format-score.png and /dev/null differ
diff --git a/.assets/danger.png b/.assets/danger.png
deleted file mode 100644
index f9d46cc..0000000
Binary files a/.assets/danger.png and /dev/null differ
diff --git a/.assets/notes.png b/.assets/notes.png
new file mode 100644
index 0000000..1773c13
Binary files /dev/null and b/.assets/notes.png differ
diff --git a/.assets/radarr-quality-profile.png b/.assets/radarr-quality-profile.png
index 47e11b1..a1fb2db 100644
Binary files a/.assets/radarr-quality-profile.png and b/.assets/radarr-quality-profile.png differ
diff --git a/.github/workflows/BuildImage.yml b/.github/workflows/BuildImage.yml
index 9a4c4f4..7ff8728 100644
--- a/.github/workflows/BuildImage.yml
+++ b/.github/workflows/BuildImage.yml
@@ -22,7 +22,7 @@ jobs:
echo "MODNAME=${{ env.MODNAME }}" >> $GITHUB_OUTPUT
echo "MULTI_ARCH=${{ env.MULTI_ARCH }}" >> $GITHUB_OUTPUT
# **** If the mod needs to be versioned, set the versioning logic below. Otherwise leave as is. ****
- MOD_VERSION="2.8.0"
+ MOD_VERSION="2.9.0"
echo "MOD_VERSION=${MOD_VERSION}" >> $GITHUB_OUTPUT
outputs:
GITHUB_REPO: ${{ steps.outputs.outputs.GITHUB_REPO }}
diff --git a/README.md b/README.md
index cedf76d..549221e 100644
--- a/README.md
+++ b/README.md
@@ -2,29 +2,25 @@
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.
**This unified script works in both Radarr and Sonarr. Use this mod in either container!**
->**NOTE:** This mod supports Linux OSes only.
+
+>![notes] This mod supports Linux OSes only.
-Production Container info: 
-[%5D.pulls&label=ghcr%20pulls&color=1572A4)](https://github.com/linuxserver/docker-mods/pkgs/container/mods)
+Production Container info: [](https://hub.docker.com/r/linuxserver/mods/tags?name=radarr-striptracks "Docker image size")
+[](https://github.com/linuxserver/docker-mods/pkgs/container/mods "GitHub package pulls")
Development Container info:
-
-
-[](https://github.com/TheCaptain989/radarr-striptracks/actions/workflows/linter.yml "Linter Job")
+[](https://hub.docker.com/r/thecaptain989/radarr-striptracks "Docker image size")
+[](https://hub.docker.com/r/thecaptain989/radarr-striptracks "Docker container pulls")
+[](https://github.com/TheCaptain989/radarr-striptracks/actions/workflows/BuildImage.yml "BuildImage job")
# Installation
-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:
- `docker pull lscr.io/linuxserver/radarr:latest` OR
- `docker pull lscr.io/linuxserver/sonarr:latest`
-
-2. Configure the Docker container with all the port, volume, and environment settings from the *original container documentation* here:
- **[linuxserver/radarr](https://hub.docker.com/r/linuxserver/radarr "Radarr Docker container")**
- **[linuxserver/sonarr](https://hub.docker.com/r/linuxserver/sonarr "Sonarr Docker container")**
+1. Configure your selected Docker container with all the port, volume, and environment settings from the *original container documentation* here:
+ **[linuxserver/radarr](https://hub.docker.com/r/linuxserver/radarr "Radarr Docker container")** OR **[linuxserver/sonarr](https://hub.docker.com/r/linuxserver/sonarr "Sonarr Docker container")**
1. Add the **DOCKER_MODS** environment variable to your `compose.yml` file or `docker run` command, as follows:
- - Stable release: `DOCKER_MODS=linuxserver/mods:radarr-striptracks`
+ - Stable/Production release: `DOCKER_MODS=linuxserver/mods:radarr-striptracks`
- Dev/test release: `DOCKER_MODS=thecaptain989/radarr-striptracks:latest`
- *Example Docker Compose YAML Configuration*
+ *Example Docker Compose YAML Configuration*
```yaml
version: "2.1"
@@ -46,7 +42,8 @@ Development Container info:
restart: unless-stopped
```
- *Example Docker Run Command*
+
+ Example Docker Run Command
```shell
docker run -d \
@@ -63,64 +60,109 @@ Development Container info:
lscr.io/linuxserver/radarr
```
- *Example Synology Configuration*
+
+
+ Synology Screenshot
+
+ *Example Synology Configuration*

+
+
2. Start the container.
-3. Configure a custom script from Radarr's or Sonarr's *Settings* > *Connect* screen and type the following in the **Path** field:
+2. Configure a custom script from Radarr's or Sonarr's *Settings* > *Connect* screen and type the following in the **Path** field:
`/usr/local/bin/striptracks.sh`
- *Example*
- 
+
+ Screenshot
+
+ *Example Custom Script*
+ 
+
+
The script will detect the language(s) defined in Radarr/Sonarr for the movie or TV show and only keep the audio and subtitles selected.
Alternatively, a wrapper script or an environment variable may be used to more granularly define which tracks to keep. See [Wrapper Scripts](./README.md#wrapper-scripts) or [Environment Variable](./README.md#environment-variable) for more details.
-# Usage
+ >![notes] You **must** configure language(s) in Radarr/Sonarr *or* pass command-line arguments for the script to do anything! See the next section for an example.
+
+## Radarr Configuration Example
+The following is a simplified example and steps to configure Radarr so the script will keep Original and English languages of an imported movie.
+
+1. Create a new *Custom Format* called "***My Languages***":
+
+
+ Screenshot
+
+ *New Custom Format Example*
+ 
+
+
+
+2. Add two *Language Conditions* to the format, one for English, and one for Original:
+
+
+ Screenshots
+
+ *New Language Conditions Example*
+ 
+
+ *Custom Format Conditions Example*
+ 
+
+
+
+3. Edit the 'Any' Quality Profile, changing the Language to "***Any***" and the *Score* to "***10***":
+
+
+ Screenshot
+
+ *Radarr Quality Profile Example*
+ 
+
+
+
+Now, when Radarr imports a movie with the 'Any' Quality Profile, the script will keep only Original and English languages. This is equivalent to calling the script with `--audio :org:eng --subs :org:eng` command-line arguments.
+See [Automatic Language Detection](./README.md#automatic-language-detection) for more details.
+
+# Usage Details
The source video can be any mkvtoolnix supported video format. The output is an MKV file with the same name and the same permissions. Owner is preserved if the script is executed as root.
Chapters, if they exist, are preserved. The Title attribute in the MKV is set to the movie title plus year
(ex: `The Sting (1973)`) or the series title plus episode information (ex: `Happy! 01x01 - What Smiles Are For`).
The language of the video file will be updated in the Radarr or Sonarr database to reflect the actual languages preserved in the remuxed video, and the video will be renamed according to the Radarr/Sonarr rules if needed (for example, if a removed track would trigger a name change.)
If you've configured the Radarr/Sonarr **Recycle Bin** path correctly, the original video will be moved there.
-![danger] **NOTE:** If you have *not* configured the Recycle Bin, the original video file will be deleted/overwritten and permanently lost.
+>![warning] **WARNING:** If you have *not* configured the Recycle Bin, the original video file will be deleted/overwritten and permanently lost.
If the resulting video file would contain the same tracks as the original, and it's already an MKV, the remux step is skipped.
## Automatic Language Detection
Beginning with version 2.0 of this mod, the script may be called with no arguments. It will detect the language(s) configured within Radarr/Sonarr on the particular movie or TV show.
-Language selection(s) may be configured in ***Quality Profiles*** (only in Radarr), ***Custom Formats*** (in Radarr v3 and higher and Sonarr v4 and higher), or ***Language Profiles*** (Sonarr v3). Example screenshots are below.
+Language selection(s) may be configured in ***Custom Formats*** (in Radarr v3 and higher and Sonarr v4 and higher), ***Quality Profiles*** (only in Radarr), or ***Language Profiles*** (Sonarr v3). Example screenshots are below.
Both audio **and** subtitle tracks that match the configured language(s) are kept.
The language selection **'Original'** will use the language Radarr pulled from [The Movie Database](https://www.themoviedb.org/ "TMDB") or that Sonarr pulled from [The TVDB](https://www.thetvdb.com/ "TVDB") during its last refresh.
-Selecting this language is functionally equivalent to calling the script with `--audio :org --subs :org` command-line options. See [Original language code](./README.md#original-language-code) below for more details.
+Selecting this language is functionally equivalent to calling the script with `--audio :org --subs :org` command-line arguments. See [Original language code](./README.md#original-language-code) below for more details.
-The language selection **'Unknown'** will match tracks with **no configured language** in the video file. Selecting this language is functionally equivalent to calling the script with `--audio :und --subs :und` command-line options. See [Unknown language code](./README.md#unknown-language-code) below for more details.
+The language selection **'Unknown'** will match tracks with **no configured language** in the video file. Selecting this language is functionally equivalent to calling the script with `--audio :und --subs :und` command-line arguments.
+See [Unknown language code](./README.md#unknown-language-code) below for more details.
The language selection **'Any'** has two purposes (Radarr only):
1) It will trigger a search of languages in ***Custom Formats***
- 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.
+ 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 arguments.
+ See [Any language code](./README.md#any-language-code) below for more details.
->**Note:** When using the *Custom Format* language conditions and scoring you may not get the results you expect.
+>![notes] When using *Custom Format* language conditions and scoring you may not get the results you expect.
>This can be non-intuitive configuration, especially when using negative scoring, the 'Negate' option, and the 'Except Language' option.
>The script does not care what custom format is *detected* by Radarr/Sonarr on the video file, only what the *scores* are in the *Quality Profile*.
>If you choose to use Custom Formats, it is **highly recommended** to first run the script with the debug option `-d`, perform some test downloads and script runs, and then examine your results and the script logs closely to be sure things are working the way you want them to.
It is **highly recommended** to review the [TraSH Guides](https://trash-guides.info/Radarr/Tips/How-to-setup-language-custom-formats/) setup instructions for Language Custom Formats.
-*Radarr Quality Profile Example*
-
-
-*Custom Format Condition Example*
-
-
-*Radarr Custom Format Language Score Example*
-
-
### Language Detection Precedence
-The following chart represents the order of precedence that the script follows to decide which language(s) to select when there are multiple settings configured. Moving left to right, it will stop when it finds a configured language.
+The following chart represents the order of precedence that the script uses to decide which language(s) to select when there are multiple settings configured. Moving left to right, it will stop when it finds a configured language.
```mermaid
graph LR
@@ -137,12 +179,13 @@ graph LR
```
Descriptively, these steps are:
-1. Command-line options (or environment variable) override all automatic language selection.
-2. If there are no command-line options, the video's *Quality Profile* is examined for a language configuration (only supported in Radarr).
-3. If there is no *Quality Profile* language **or** it is set to 'Any', then examine the *Custom Formats* and scores associated with the quality profile. All language conditions with positive scores *and* negated conditions with negative scores *and* non-negated Except Language conditions with negative scores are selected.
-4. If the *Custom Format* scores are zero (0) or there are none with configured language conditions, examine the *Language Profile* (only supported in Sonarr v3)
+1. Command-line arguments (or environment variable) override all automatic language selection.
+2. If there are no command-line arguments, the video's *Quality Profile* is examined for a language configuration (only supported in Radarr).
+3. If there is no *Quality Profile* language **or** it is set to 'Any', then examine the *Custom Formats* and scores associated with the quality profile.
+All language conditions with positive scores *and* Negated conditions with negative scores *and* non-Negated Except Language conditions with negative scores are selected.
+4. If the *Custom Format* scores are zero (0) or there are none with configured language conditions, use the *Language Profile* (only supported in Sonarr v3)
->**Note:** For step 3 above, using *Custom Formats* when 'Any' is in the *Quality Profile* is consistent with the behavior described in [TRaSH Guides](https://trash-guides.info/Radarr/Tips/How-to-setup-language-custom-formats/ "TraSH Guides: How to setup Language Custom Formats").
+>![notes] For step 3 above, using *Custom Formats* when 'Any' is in the *Quality Profile* is consistent with the behavior described in [TRaSH Guides](https://trash-guides.info/Radarr/Tips/How-to-setup-language-custom-formats/ "TraSH Guides: How to setup Language Custom Formats").
## Command-Line Syntax
@@ -150,20 +193,24 @@ Descriptively, these steps are:
The script also supports command-line arguments that will override the automatic language detection. More granular control can therefore be exerted or extended using tagging and defining multiple *Connect* scripts (this is native Radarr/Sonarr functionality outside the scope of this documentation).
The syntax for the command-line is:
-`striptracks.sh [{-a|--audio} [{-s|--subs} ] [{-f|--file} ]] [{-l,--log} ] [{-d|--debug} []]`
+`striptracks.sh [{-a|--audio} [{-s|--subs} ] [{-f|--file} ]] [{-l,--log} ] [{-c,--config} ] [{-d|--debug} []]`
-Where:
+
+Table of Command-Line Arguments
Option|Argument|Description
---|---|---
-a, --audio||Audio languages to keep
ISO 639-2 code(s) prefixed with a colon (`:`)
-s, --subs||Subtitle languages to keep
ISO 639-2 code(s) prefixed with a colon (`:`)
--f, --file||If included, the script enters **[Batch Mode](./README.md#batch-mode)** and converts the specified video file.
Requires the `-a` option.
![danger] **WARNING:** Do not use this argument when called from Radarr or Sonarr!
--l, --log|\|The log filename
Default of /config/log/striptracks.txt
--d, --debug|\[\\]|Enables debug logging. Level is optional.
Default of 1 (low)
2 includes JSON output
3 contains even more JSON output
+-f, --file||If included, the script enters **[Batch Mode](./README.md#batch-mode)** and converts the specified video file.
Requires the `-a` option.
![notes] **Do not** use this argument when called from Radarr or Sonarr!
+-l, --log|\|The log filename
Default is /config/log/striptracks.txt
+-c, --config|\|Radarr/Sonarr XML configuration file
Default is /config/config.xml
+-d, --debug|\[\\]|Enables debug logging. Level is optional.
Default is 1 (low)
2 includes JSON output
3 contains even more JSON output
--help| |Display help and exit.
--version| |Display version and exit.
+
+
The `` and `` 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.
For example:
@@ -175,7 +222,7 @@ For example:
Multiple codes may be concatenated, such as `:eng:spa` for both English and Spanish. Order is unimportant.
->![warning] **NOTE:** If no subtitle language is detected via Radarr/Sonarr configuration or specified on the command-line, all subtitles are removed.
+>![warning] **WARNING:** If no subtitle language is detected via Radarr/Sonarr configuration or specified on the command-line, all subtitles are removed.
### Any language code
The `:any` language code is a special code. When used, the script will preserve all language tracks, regardless of how they are tagged in the source video.
@@ -185,12 +232,12 @@ The `:org` language code is a special code. When used, instead of retaining a sp
As an example, when importing "*Amores Perros (2000)*" with options `--audio :org:eng`, the Spanish and English audio tracks are preserved.
Several [Included Wrapper Scripts](./README.md#included-wrapper-scripts) use this special code.
->![danger] **NOTE:** This feature relies on the 'originalLanguage' field in the Radarr/Sonarr database. The `:org` code is therefore invalid when used in Batch Mode.
+>![notes] This feature relies on the 'originalLanguage' field in the Radarr/Sonarr database. The `:org` code is therefore invalid when used in Batch Mode.
> The script will log a warning if it detects the use of `:org` in an invalid way, though it will continue to execute.
### Unknown language code
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.
->![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.
+>![warning] **WARNING:** 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.
## Special Handling of Audio
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.
@@ -201,6 +248,9 @@ There is no way to force the script to remove audio tracks with these codes.
## Examples
+
+Command-line Examples
+
```shell
-d 2 # Enable debugging level 2, audio and subtitles
# languages detected from Radarr/Sonarr
@@ -209,38 +259,45 @@ There is no way to force the script to remove audio tracks with these codes.
:eng "" # Keep English audio and remove all subtitles
-d -a :eng:kor:jpn -s :eng:spa # Enable debugging level 1, keeping English, Korean, and Japanese audio, and
# English and Spanish subtitles
--f "/path/to/movies/Finding Nemo (2003).mkv" -a :eng:und -s :eng
+-f "/movies/Finding Nemo (2003).mkv" -a :eng:und -s :eng
# Batch Mode
# Keep English and Unknown audio and English subtitles, converting
# video specified
-a :any -s "" # Keep all audio and remove all subtitles
```
+
+
## Wrapper Scripts
To supply arguments to the script, you must either use one of the included wrapper scripts, create a custom wrapper script, or set the `STRIPTRACKS_ARGS` [environment variable](./README.md#environment-variable).
### Included Wrapper Scripts
For your convenience, several wrapper scripts are included in the `/usr/local/bin/` directory.
-You may use any of these scripts in place of `striptracks.sh` mentioned in the [Installation](./README.md#installation) section above.
+You may use any of these in place of `striptracks.sh` mentioned in the [Installation](./README.md#installation) section above.
+
+
+List of scripts
```shell
striptracks-debug.sh # Use detected languages, but enable debug logging
striptracks-debug-2.sh # Use detected languages, enable debug logging level 2
striptracks-debug-max.sh # Use detected languages, enable highest debug logging
-striptracks-dut.sh # Keep Dutch audio and subtitles
+striptracks-dut.sh # Keep Dutch and Unknown audio, and Dutch subtitles
striptracks-eng.sh # Keep English and Unknown audio, and English subtitles
striptracks-eng-debug.sh # Keep English and Unknown audio, and English subtitles, and enable debug logging
-striptracks-eng-fre.sh # Keep English, French, and Unknown audio and English subtitles
+striptracks-eng-fre.sh # Keep English, French, and Unknown audio, and English and French subtitles
striptracks-eng-jpn.sh # Keep English, Japanese, and Unknown audio and English subtitles
-striptracks-fre.sh # Keep French audio and subtitles
-striptracks-fre-debug.sh # Keep French audio and subtitles, and enable debug logging
-striptracks-ger.sh # Keep German audio and subtitles
-striptracks-spa.sh # Keep Spanish audio and subtitles
-striptracks-org-eng.sh # Keep Original, English, and Unknown audio, and English and Unknown subtitles
-striptracks-org-ger.sh # Keep Original and German audio, and Original and German subtitles
-striptracks-org-spa.sh # Keep Original and Spanish audio, and Original and Spanish subtitles
+striptracks-fre.sh # Keep French and Unknown audio, and French subtitles
+striptracks-fre-debug.sh # Keep French and Unknown audio, French subtitles, and enable debug logging
+striptracks-ger.sh # Keep German and Unknown audio, and German subtitles
+striptracks-spa.sh # Keep Spanish and Unknown audio, and Spanish subtitles
+striptracks-org-eng.sh # Keep Original, English, and Unknown audio, and Original and English subtitles
+striptracks-org-ger.sh # Keep Original, German, and Unknown audio, and Original and German subtitles
+striptracks-org-spa.sh # Keep Original, Spanish, and Unknown audio, and Original and Spanish subtitles
```
+
+
### Example Wrapper Script
To configure an entry from the [Examples](./README.md#examples) section above, create and save a file called `striptracks-custom.sh` to `/config` containing the following text:
@@ -258,31 +315,36 @@ chmod +x /config/striptracks-custom.sh
Then put `/config/striptracks-custom.sh` in the **Path** field in place of `/usr/local/bin/striptracks.sh` mentioned in the [Installation](./README.md#installation) section above.
->**Note:** If you followed the Linuxserver.io recommendations when configuring your container, the `/config` directory will be mapped to an external storage location. It is therefore recommended to place custom scripts in the `/config` directory so they will survive container updates, but they may be placed anywhere that is accessible by Radarr or Sonarr.
+>![notes] If you followed the Linuxserver.io recommendations when configuring your container, the `/config` directory will be mapped to an external storage location. It is therefore recommended to place custom scripts in the `/config` directory so they will survive container updates, but they may be placed anywhere that is accessible by Radarr or Sonarr.
## Environment Variable
-The `striptracks.sh` script also allows the use of arguments provided by the `STRIPTRACKS_ARGS` environment variable. This allows advanced use cases without having to provide a custom script.
+The `striptracks.sh` script can read command-line arguments from the `STRIPTRACKS_ARGS` environment variable. This allows advanced use cases without having to provide a custom script.
-For example, the following value in your `docker run` command would Keep English, Japanese, and Unknown audio and English subtitles:
-
-```shell
--e STRIPTRACKS_ARGS='--audio :eng:jpn:und --subs :eng'
-```
-
-In Docker Compose this will look like this:
+For example, the following lines in your `compose.yml` file would keep English, Japanese, and Unknown audio and English subtitles:
```yaml
environment:
- STRIPTRACKS_ARGS=--audio :eng:jpn:und --subs :eng
```
-*Example Synology Configuration*
-
+In a `docker run` command, it would be:
->**NOTE:** The environment variable settings are *only* used when **no** command-line arguments are present. **Any** command-line argument will disable the use of the environment variable.
+```shell
+-e STRIPTRACKS_ARGS='--audio :eng:jpn:und --subs :eng'
+```
+
+
+Synology Screenshot
+
+*Example Synology Configuration*
+
+
+
+
+>![notes] The environment variable is *only* read when **no** command-line arguments are present. **Any** command-line argument will disable the use of the environment variable.
## Triggers
-The only events/notification triggers that are supported are **On Import** and **On Upgrade**
+The only events/notification triggers that are supported are **On Import** and **On Upgrade**. The script will log an error if executed by any other trigger.
## Batch Mode
Batch mode allows the script to be executed independently of Radarr or Sonarr. It converts the file specified on the command-line and ignores any environment variables that are normally expected to be set by the video management program.
@@ -290,10 +352,10 @@ Batch mode allows the script to be executed independently of Radarr or Sonarr.
Using this function, you can easily process all of your video files in any subdirectory at once. See the [Batch Example](./README.md#batch-example) below.
### Script Execution Differences in Batch Mode
-Because the script is not called from within Radarr or Sonarr, expect the following behavior while in Batch Mode:
-* *The filename must be specified on the command-line.*
(The `-f` option places the script in Batch Mode)
+Because the script is not called from within Radarr or Sonarr, their database is unavailable to the script. Therefore, expect the following behavior while in Batch Mode:
+* *The filename must be specified on the command-line.*
The `-f` option places the script in Batch Mode
* *No audio or subtitles language detection occurs.*
Both the audio and subtitles languages must be specified on the command-line.
-* *The `:org` language code is meaningless.*
The original video language cannot be determined without the Radarr/Sonarr database.
+* *The `:org` language code is meaningless.*
The original video language cannot be determined.
* *The resultant MKV embedded title attribute is set to the basename of the file minus the extension.*
The canonical name of the movie/TV show cannot otherwise be determined.
* *Radarr or Sonarr APIs are not called and their database is not updated.*
This may require a manual rescan of converted videos.
* *Original video files are deleted.*
The Recycle Bin function is not available.
@@ -305,6 +367,12 @@ To keep English and Unknown audio and English subtitles on all video files endin
find /movies/ -type f \( -name "*.mkv" -o -name "*.avi" -o -name "*.mp4" \) | while read file; do /usr/local/bin/striptracks.sh -f "$file" -a :eng:und -s :eng; done
```
+Here's another example to keep English, Danish, and Unknown languages on all video files in your `./videos` directory (requires the `file` program; testable with `file -v`):
+
+```shell
+find ./videos/ -type f | while read filename; do if file -i "$filename" | grep -q video; then /usr/local/bin/striptracks.sh -f "$filename" --audio :eng:dan:und --subs :eng:dan:und; fi; done
+```
+
## Logs
By default, a log file is created for the script activity called:
@@ -315,7 +383,7 @@ This log can be inspected or downloaded from Radarr/Sonarr under *System* > *Log
Script errors will show up in both the script log and the native Radarr/Sonarr log.
Log rotation is performed with 5 log files of 512KB each being kept.
->![danger] **NOTE:** If debug logging is enabled with a level above 1, the log file can grow very large very quickly. *Do not leave high-level debug logging enabled permanently.*
+>![warning] **WARNING:** If debug logging is enabled with a level above 1, the log file can grow very large very quickly. *Do not leave high-level debug logging enabled permanently.*
# Uninstall
To completely remove the mod:
@@ -342,4 +410,4 @@ Icons made by [Freepik](https://www.freepik.com) from [Flaticon](https://www.fla
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.
[warning]: .assets/warning.png "Warning"
-[danger]: .assets/danger.png "Danger"
+[notes]: .assets/notes.png "Note"
diff --git a/SECURITY.md b/SECURITY.md
index 8f46036..d8bfb32 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -6,8 +6,8 @@ Only the latest major and minor version are supported.
| Version | Supported |
| ------- | ------------------ |
-| 2.8.x | :heavy_check_mark: |
-| < 2.8 | :x: |
+| 2.9.x | :heavy_check_mark: |
+| < 2.9 | :x: |
## Reporting a Vulnerability
diff --git a/root/usr/local/bin/striptracks-dut.sh b/root/usr/local/bin/striptracks-dut.sh
index a55829d..57571f6 100755
--- a/root/usr/local/bin/striptracks-dut.sh
+++ b/root/usr/local/bin/striptracks-dut.sh
@@ -1,3 +1,3 @@
#!/bin/bash
-. /usr/local/bin/striptracks.sh :nld:dut :nld:dut
+. /usr/local/bin/striptracks.sh :nld:dut:und :nld:dut
diff --git a/root/usr/local/bin/striptracks-fre-debug.sh b/root/usr/local/bin/striptracks-fre-debug.sh
index 918a198..8c3b765 100755
--- a/root/usr/local/bin/striptracks-fre-debug.sh
+++ b/root/usr/local/bin/striptracks-fre-debug.sh
@@ -1,3 +1,3 @@
#!/bin/bash
-. /usr/local/bin/striptracks.sh -d :fre:fra :fre:fra
+. /usr/local/bin/striptracks.sh -d :fre:fra:und :fre:fra
diff --git a/root/usr/local/bin/striptracks-fre.sh b/root/usr/local/bin/striptracks-fre.sh
index 998ce43..832339b 100755
--- a/root/usr/local/bin/striptracks-fre.sh
+++ b/root/usr/local/bin/striptracks-fre.sh
@@ -1,3 +1,3 @@
#!/bin/bash
-. /usr/local/bin/striptracks.sh :fre:fra :fre:fra
+. /usr/local/bin/striptracks.sh :fre:fra:und :fre:fra
diff --git a/root/usr/local/bin/striptracks-ger.sh b/root/usr/local/bin/striptracks-ger.sh
index 62047ab..00b99fe 100755
--- a/root/usr/local/bin/striptracks-ger.sh
+++ b/root/usr/local/bin/striptracks-ger.sh
@@ -1,3 +1,3 @@
#!/bin/bash
-. /usr/local/bin/striptracks.sh :ger:deu :ger:deu
+. /usr/local/bin/striptracks.sh :ger:deu:und :ger:deu
diff --git a/root/usr/local/bin/striptracks-org-eng.sh b/root/usr/local/bin/striptracks-org-eng.sh
index 8422147..364dbd3 100755
--- a/root/usr/local/bin/striptracks-org-eng.sh
+++ b/root/usr/local/bin/striptracks-org-eng.sh
@@ -1,3 +1,3 @@
#!/bin/bash
-. /usr/local/bin/striptracks.sh --audio :org:eng:und --subs :eng:und
+. /usr/local/bin/striptracks.sh --audio :org:eng:und --subs :org:eng
diff --git a/root/usr/local/bin/striptracks-org-ger.sh b/root/usr/local/bin/striptracks-org-ger.sh
index 7af8133..e715e37 100755
--- a/root/usr/local/bin/striptracks-org-ger.sh
+++ b/root/usr/local/bin/striptracks-org-ger.sh
@@ -1,3 +1,3 @@
#!/bin/bash
-. /usr/local/bin/striptracks.sh --audio :org:ger:deu --subs :org:ger:deu
+. /usr/local/bin/striptracks.sh --audio :org:ger:deu:und --subs :org:ger:deu
diff --git a/root/usr/local/bin/striptracks-org-spa.sh b/root/usr/local/bin/striptracks-org-spa.sh
index 6c0ce0d..4c84007 100755
--- a/root/usr/local/bin/striptracks-org-spa.sh
+++ b/root/usr/local/bin/striptracks-org-spa.sh
@@ -1,3 +1,3 @@
#!/bin/bash
-. /usr/local/bin/striptracks.sh --audio :org:spa --subs :org:spa
+. /usr/local/bin/striptracks.sh --audio :org:spa:und --subs :org:spa
diff --git a/root/usr/local/bin/striptracks-spa.sh b/root/usr/local/bin/striptracks-spa.sh
index 92f6c4e..2464f25 100755
--- a/root/usr/local/bin/striptracks-spa.sh
+++ b/root/usr/local/bin/striptracks-spa.sh
@@ -1,3 +1,3 @@
#!/bin/bash
-. /usr/local/bin/striptracks.sh :spa :spa
+. /usr/local/bin/striptracks.sh :spa:und :spa
diff --git a/root/usr/local/bin/striptracks.sh b/root/usr/local/bin/striptracks.sh
index 2f15355..82d1c75 100755
--- a/root/usr/local/bin/striptracks.sh
+++ b/root/usr/local/bin/striptracks.sh
@@ -12,19 +12,22 @@
# NOTE: ShellCheck linter directives appear as comments
-# Dependencies:
-# mkvmerge
-# mkvpropedit
-# sed
-# awk
-# curl
-# jq
-# numfmt
-# stat
-# nice
-# basename
-# dirname
-# mktemp
+# Dependencies: # sudo apt install mkvtoolnix jq
+# From mkvtoolnix:
+# mkvmerge
+# mkvpropedit
+# From jq:
+# jq
+# Generally always available:
+# sed
+# awk
+# curl
+# numfmt
+# stat
+# nice
+# basename
+# dirname
+# mktemp
# Exit codes:
# 0 - success; or test
@@ -88,6 +91,8 @@ Options and Arguments:
from Radarr or Sonarr!
-l, --log Log filename
[default: /config/log/striptracks.txt]
+ -c, --config Radarr/Sonarr XML configuration file
+ [default: ./config/config.xml]
-d, --debug [] Enable debug logging
level is optional, between 1-3
1 is lowest, 3 is highest
@@ -129,6 +134,11 @@ Examples:
echo "$usage" >&2
}
+# Log command-line arguments
+if [ $# -ne 0 ]; then
+ striptracks_prelogmessagedebug="Debug|Command line arguments are '$*'"
+fi
+
# Check for environment variable arguments
if [ -n "$STRIPTRACKS_ARGS" ]; then
if [ $# -ne 0 ]; then
@@ -205,6 +215,17 @@ while (( "$#" )); do
exit 3
fi
;;
+ -c|--config ) # *arr XML configuration file
+ if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+ # Overrides default /config/config.xml
+ export striptracks_arr_config="$2"
+ shift 2
+ else
+ echo "Error|Invalid option: $1 requires an argument." >&2
+ usage
+ exit 1
+ fi
+ ;;
-*) # Unknown option
echo "Error|Unknown option: $1" >&2
usage
@@ -897,18 +918,14 @@ if [ ! -w "$striptracks_log" ]; then
fi
# Check for required binaries
-if [ ! -f "/usr/bin/mkvmerge" ]; then
- striptracks_message="Error|/usr/bin/mkvmerge is required by this script"
- echo "$striptracks_message" | log
- echo "$striptracks_message" >&2
- end_script 4
-fi
-if [ ! -f "/usr/bin/mkvpropedit" ]; then
- striptracks_message="Error|/usr/bin/mkvpropedit is required by this script"
- echo "$striptracks_message" | log
- echo "$striptracks_message" >&2
- end_script 4
-fi
+for striptracks_file in "/usr/bin/mkvmerge" "/usr/bin/mkvpropedit" "/usr/bin/jq"; do
+ if [ ! -f "$striptracks_file" ]; then
+ striptracks_message="Error|$striptracks_file is required by this script"
+ echo "$striptracks_message" | log
+ echo "$striptracks_message" >&2
+ end_script 4
+ fi
+done
# Log Debug state
if [ $striptracks_debug -ge 1 ]; then
@@ -917,6 +934,12 @@ if [ $striptracks_debug -ge 1 ]; then
echo "$striptracks_message" >&2
fi
+# Log command line parameters
+if [ -n "$striptracks_prelogmessagedebug" ]; then
+ # striptracks_prelogmessagedebug is set above, before argument processing
+ [ $striptracks_debug -ge 1 ] && echo "$striptracks_prelogmessagedebug" | log
+fi
+
# Log STRIPTRACKS_ARGS usage
if [ -n "$striptracks_prelogmessage" ]; then
# striptracks_prelogmessage is set above, before argument processing
@@ -935,6 +958,16 @@ if [[ "${!striptracks_eventtype}" =~ Grab|Rename|MovieAdded|MovieDelete|MovieFil
end_script 20
fi
+# Check for WSL environment
+if [ -n "$WSL_DISTRO_NAME" ]; then
+ [ $striptracks_debug -ge 1 ] && echo "Debug|Running in virtual WSL $WSL_DISTRO_NAME distribution." | log
+ # Adjust config file location to WSL default
+ if [ ! -f "$striptracks_arr_config" ]; then
+ striptracks_arr_config="/mnt/c/ProgramData/${striptracks_type^}/config.xml"
+ [ $striptracks_debug -ge 1 ] && echo "Debug|Will try to use the default WSL configuration file '$striptracks_arr_config'" | log
+ fi
+fi
+
# Handle Test event
if [[ "${!striptracks_eventtype}" = "Test" ]]; then
echo "Info|${striptracks_type^} event: ${!striptracks_eventtype}" | log
@@ -978,6 +1011,11 @@ elif [ -f "$striptracks_arr_config" ]; then
striptracks_apikey_var="${striptracks_type^^}__AUTH__APIKEY"
[ -n "${!striptracks_apikey_var}" ] && striptracks_apikey="${!striptracks_apikey_var}"
+ # Check for WSL environment and adjust bindaddress if not otherwise specified
+ if [ -n "$WSL_DISTRO_NAME" -a "$striptracks_bindaddress" = "*" ]; then
+ striptracks_bindaddress=$(ip route show | grep -i default | awk '{ print $3}')
+ fi
+
# Check for localhost
[[ $striptracks_bindaddress = "*" ]] && striptracks_bindaddress=localhost
@@ -991,7 +1029,7 @@ elif [ -f "$striptracks_arr_config" ]; then
get_version
striptracks_return=$?; [ $striptracks_return -ne 0 ] && {
# curl errored out. API calls are really broken at this point.
- striptracks_message="Error|Unable to get ${striptracks_type^} version information. It is not safe to continue."
+ striptracks_message="Error|[$striptracks_return] Unable to get ${striptracks_type^} version information. It is not safe to continue."
echo "$striptracks_message" | log
echo "$striptracks_message" >&2
end_script 17