diff --git a/.assets/danger.png b/.assets/danger.png new file mode 100644 index 0000000..f9d46cc Binary files /dev/null and b/.assets/danger.png differ diff --git a/.assets/warning.png b/.assets/warning.png new file mode 100644 index 0000000..0fe039d Binary files /dev/null and b/.assets/warning.png differ diff --git a/.dockerignore b/.dockerignore index cdb1a82..58df2a2 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,9 @@ +# Docker ignore file .git .gitignore .github .gitattributes +.assets READMETEMPLATE.md README.md +SECURITY.md diff --git a/.github/workflows/BuildImage.yml b/.github/workflows/BuildImage.yml index 1eabef5..37835de 100644 --- a/.github/workflows/BuildImage.yml +++ b/.github/workflows/BuildImage.yml @@ -16,9 +16,14 @@ jobs: - name: Build image run: | # Build variables - VERSION=$(git describe --tags --always) + VERSION=${GITHUB_SHA:0:7} + cat <**NOTE:** This mod support Linux OSes only. +>**NOTE:** This mod supports Linux OSes only. Container info: -![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/linuxserver/mods/radarr-striptracks) +![Docker Image Size](https://img.shields.io/docker/image-size/thecaptain989/radarr-striptracks "Container Size") +![Docker Pulls](https://img.shields.io/docker/pulls/thecaptain989/radarr-striptracks "Container Pulls") +Production Container info: ![Docker Image Size](https://img.shields.io/docker/image-size/linuxserver/mods/radarr-striptracks "Container Size") # Installation ->**NOTE:** See the [Sonarr/Radarr v3 Builds](./README.md#sonarrradarr-v3-builds) section below for important differences to these instructions for v3 builds. +>**NOTE:** See the [Sonarr/Radarr v2 Builds](./README.md#sonarrradarr-v2-builds) section below for important differences to these instructions for v2 builds. 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 Docker Hub: `docker pull linuxserver/radarr:latest` OR @@ -17,47 +19,72 @@ Container info: 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. Add the **DOCKER_MODS** environment variable to the `docker create` command, as follows: - `-e DOCKER_MODS=linuxserver/mods:radarr-striptracks` + 1. Add the **DOCKER_MODS** environment variable to the `docker run` command, as follows: + + - Stable release: `-e DOCKER_MODS=linuxserver/mods:radarr-striptracks` + + *Example Docker CLI Configuration* + ```shell + docker run -d \ + --name=radarr \ + -e PUID=1000 \ + -e PGID=1000 \ + -e TZ=America/Chicago \ + -e DOCKER_MODS=linuxserver/mods:radarr-striptracks \ + -p 7878:7878 \ + -v /path/to/data:/config \ + -v /path/to/movies:/movies \ + -v /path/to/downloadclient-downloads:/downloads \ + --restart unless-stopped \ + ghcr.io/linuxserver/radarr + ``` *Example Synology Configuration* ![striptracks](.assets/striptracks-synology.png "Synology container settings") 2. Start the container. -3. After all of the above configuration is complete, to use mkvmerge: - 1. Configure a custom script from the Radarr/Sonnar Settings->Connect screen and type the following in the **Path** field: - `/usr/local/bin/striptracks.sh` +3. After the above configuration is complete, to use mkvmerge, 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-eng.sh` - 2. Add the codes for the audio and subtitle languages you want to keep as **Arguments** (details in the [Syntax](./README.md#syntax) section below): - Suggested Example - **`:eng:und :eng`** + *Example* + ![striptracks v3](.assets/striptracks-v3-custom-script.png "Radarr/Sonarr custom script settings") + + This is a wrapper script that calls striptracks.sh with the following arguments, which keep English audio and subtitles only! + `:eng:und :eng` + + *For any other combinations of audio and subtitles you **must** either use one of the [included wrapper scripts](./README.md#included-wrapper-scripts) or create a custom script with the codes for the languages you want to keep. See the [Syntax](./README.md#syntax) section below.* + *Do not put `striptracks.sh` in the **Path** field!* ## Usage ->**NOTE:** See the [Sonarr/Radarr v3 Builds](./README.md#sonarrradarr-v3-builds) section below for important differences to these instructions for v3 builds. +The source video can be any mkvtoolnix supported video format. The output is an MKV file with the same name. +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 source video can be any mkvtoolnix supported video format. The output is an MKV file with the same name. - -If you've configured the Radarr/Sonarr Recycle Bin path correctly, the original video will be moved there. -![warning24] **NOTE:** If you have *not* configured the Recycle Bin, the original video file will be deleted/overwritten and permanently lost. +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. ### Syntax -The script accepts two arguments and one option in the **Arguments** field: +>**NOTE:** The **Arguments** field for Custom Scripts was removed in Radarr and Sonarr v3 due to security concerns. To support options with these versions and later, +a wrapper script must be manually created that will call *striptracks.sh* with the required arguments. + +The script accepts two command line arguments and one option: `[-d] ` -The arguments are language codes in [ISO639-2](https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes "List of ISO 639-2 codes") format. -These are three letter abbreviations prefixed with a colon ':', such as: +The `` and `` arguments 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. +For example: * :eng * :fre * :spa -...etc. +...etc. Multiple codes may be concatenated, such as `:eng:spa` for both English and Spanish. +**These codes are mandatory.** There are no defaults. -It is suggested to use `:eng:und :eng` if you are unsure of what to choose. This will keep English and Undetermined audio and English subtitles, if they exist. +The wrapper script noted above uses `:eng:und :eng`, which will keep English and Undetermined audio and English subtitles. >**NOTE:** The script is smart enough to not remove the last audio track. This way you don't have to specify every possible language if you are importing a foreign film, for example. @@ -65,75 +92,21 @@ The `-d` option enables debug logging. ### Examples ``` -:eng:und :eng # keep English and Undetermined audio and English subtitles --d :eng "" # Enable debugging, keeping English audio and no subtitles -:eng:kor:jpn :eng:spa # Keep English, Korean, and Japanese audio, and English and - Spanish subtitles +:eng:und :eng # keep English and Undetermined audio and English subtitles +-d :eng "" # Enable debugging, keeping English audio and no subtitles +:eng:kor:jpn :eng:spa # Keep English, Korean, and Japanese audio, and English and + # Spanish subtitles ``` -## Triggers -The only events/notification triggers that have been tested are **On Download** and **On Upgrade** - -![striptracks](.assets/striptracks-v2-custom-script.png "Radarr/Sonarr custom script settings") - -## Logs -A log file is created for the script activity called: - -`/config/logs/striptracks.txt` - -This log can be inspected or downloaded from the Radarr/Sonarr GUI under System->Logs->Files - -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. ->![warning24] **NOTE:** If debug logging is enabled, the log file can grow very large very quickly. *Do not leave debug logging enabled permanently.* - -___ - -## Sonarr/Radarr v3 Builds ->![warning] **Warning: Unstable Releases** ![warning] ->The Sonarr/Radarr v3 Builds are the unstable releases (Aphrodite and Phantom) of Radarr and Sonarr. Though the mod works with all versions of the container, I cannot guarantee these releases are stable. - -Important differences for Sonarr/Radarr v3 Builds -### Mod installation -Substitute the following steps for those noted in the [Installation](./README.md#installation) section above. -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 Docker Hub: - `docker pull linuxserver/radarr:preview` OR - `docker pull linuxserver/sonarr:preview` - -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. Add the **DOCKER_MODS** environment variable to the `docker create` command, as follows: - `-e DOCKER_MODS=linuxserver/mods:radarr-striptracks` - - *Example Synology Configuration* - ![striptracks](.assets/striptracks-synology.png "Synology container settings") - - 2. Start the container. - -3. After the above configuration is complete, to use mkvmerge, configure a custom script from the Settings->Connect screen and type the following in the **Path** field: - - `/usr/local/bin/striptracks-eng.sh` - - This is a wrapper script that calls striptracks.sh with the following arguments, which keep English audio and subtitles only! - `:eng:und :eng` - - *For any other combinations of audio and subtitles you **must** either use one of the [included wrapper scripts](./README.md#included-wrapper-scripts) or - create a custom script with the codes for the languages you want to keep. See the [Syntax](./README.md#syntax) section above. - Do not put `striptracks.sh` in the **Path** field!* - ### Included Wrapper Scripts ->**NOTE:** The **Arguments** field for Custom Scripts was removed in Radarr and Sonarr v3 due to security concerns. To support options with this version and later, -a wrapper script can be manually created that will call *striptracks.sh* with the required arguments. - For your convenience, several wrapper scripts are included in the `/usr/local/bin/` directory. -You may use any of these scripts in place of the `striptracks-eng.sh` mentioned in the [Mod installation](./README.md#mod-installation) section above. +You may use any of these scripts in place of the `striptracks-eng.sh` mentioned in the [Installation](./README.md#installation) section above. ``` striptracks-dut.sh # Keep Dutch audio and subtitles striptracks-eng.sh # Keep English and Undetermined audio and English subtitles striptracks-eng-debug.sh # Keep English and Undetermined audio and English subtitles, and enable debug logging +striptracks-eng-fre.sh # Keep English, French, and Undetermined audio and English subtitles striptracks-eng-jpn.sh # Keep English, Japanese, and Undetermined 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 @@ -142,24 +115,63 @@ striptracks-spa.sh # Keep Spanish audio and subtitles ``` ### Example Wrapper Script -To configure the last entry from the [Examples](./README.md#examples) section above, create and save a file called `wrapper.sh` to `/usr/local/bin` containing the following text: -``` +To configure the last entry from the [Examples](./README.md#examples) section above, create and save a file called `striptracks-custom.sh` to `/config` containing the following text: +```shell #!/bin/bash . /usr/local/bin/striptracks.sh :eng:kor:jpn :eng:spa ``` -Then put `/usr/local/bin/wrapper.sh` in the **Path** field in place of `/usr/local/bin/striptracks-eng.sh` mentioned in the [Mod installation](./README.md#mod-installation) section above. +Make it executable: +```shell +chmod +x /config/striptracks-custom.sh +``` -### Preview Triggers +Then put `/config/striptracks-custom.sh` in the **Path** field in place of `/usr/local/bin/striptracks-eng.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. + +### Triggers The only events/notification triggers that have been tested are **On Import** and **On Upgrade** -![striptracks](.assets/striptracks-v3-custom-script.png "Radarr/Sonarr custom script settings") +### Logs +A log file is created for the script activity called: -### Preview Logs -The log can be inspected or downloaded from the Radarr/Sonarr GUI under System->Log Files +`/config/logs/striptracks.txt` + +This log can be inspected or downloaded from Radarr/Sonarr under *System* > *Logs* > *Files* + +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, the log file can grow very large very quickly. *Do not leave debug logging enabled permanently.* ___ +## Sonarr/Radarr v2 Builds +>![warning] **Warning: Legacy Releases** +>The Sonarr/Radarr v2 Builds of Radarr and Sonarr are no longer being developed and are considered legacy. However, this mod works with all versions of the container. + +Important differences for Sonarr/Radarr v2 Builds +### Legacy Installation +Substitute the following step for step #3 noted in the [Installation](./README.md#installation) section above. +3. After all of the above configuration is complete, to use mkvmerge: + 1. Configure a custom script from the Radarr/Sonnar *Settings* > *Connect* screen and type the following in the **Path** field: + `/usr/local/bin/striptracks.sh` + + 2. Add the codes for the audio and subtitle languages you want to keep as **Arguments** (details in the [Syntax](./README.md#syntax) section above): + Suggested Example + `:eng:und :eng` + + *Example* + ![striptracks v2](.assets/striptracks-v2-custom-script.png "Radarr/Sonarr custom script settings") + +### Legacy Triggers +The only events/notification triggers that have been tested are **On Download** and **On Upgrade** + +### Legacy Logs +The log can be inspected or downloaded from Radarr/Sonarr under *System* > *Log Files* + +___ # Credits This would not be possible without the following: @@ -170,7 +182,8 @@ This would not be possible without the following: [LinuxServer.io Sonarr](https://hub.docker.com/r/linuxserver/sonarr "Sonarr Docker container") container [LinuxServer.io Docker Mods](https://hub.docker.com/r/linuxserver/mods "Docker Mods containers") project [MKVToolNix](https://mkvtoolnix.download/ "MKVToolNix homepage") by Moritz Bunkus -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). +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). +Icons made by [Freepik](https://www.freepik.com) from [Flaticon](https://www.flaticon.com/) -[warning]: http://files.softicons.com/download/application-icons/32x32-free-design-icons-by-aha-soft/png/32/Warning.png "Warning" -[warning24]: http://files.softicons.com/download/toolbar-icons/24x24-free-pixel-icons-by-aha-soft/png/24x24/Warning.png "Warning" +[warning]: .assets/warning.png "Warning" +[danger]: .assets/danger.png "Danger" diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..b8a7d50 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,18 @@ +# Security Policy + +## Supported Versions + +Only the latest major and minor version are supported. + +| Version | Supported | +| ------- | ------------------ | +| 1.3.x | :heavy_check_mark: | +| < 1.3 | :x: | + +## Reporting a Vulnerability + +Vulnerability reports or security concerns may be submitted as a new issue in GitHub, or emailed to: + +>thecaptain989@protonmail.com + +Please allow 48-hours for an initial response. An issue will be entered if accepted. diff --git a/root/etc/cont-init.d/98-striptracks b/root/etc/cont-init.d/98-striptracks index 8aa9ba1..cbaf6f7 100644 --- a/root/etc/cont-init.d/98-striptracks +++ b/root/etc/cont-init.d/98-striptracks @@ -3,7 +3,9 @@ cat <>> Striptracks Mod by TheCaptain989 <<< -Repo: https://github.com/linuxserver/docker-mods/tree/radarr-striptracks +Repos: + Dev/test: https://github.com/TheCaptain989/radarr-striptracks + Prod: https://github.com/linuxserver/docker-mods/tree/radarr-striptracks Version: $(cat /etc/version.tc989) ---------------- diff --git a/root/usr/local/bin/striptracks.sh b/root/usr/local/bin/striptracks.sh index 9d9034b..373d003 100644 --- a/root/usr/local/bin/striptracks.sh +++ b/root/usr/local/bin/striptracks.sh @@ -2,7 +2,8 @@ # Video remuxing script designed for use with Radarr and Sonarr # Automatically strips out unwanted audio and subtitle streams, keeping only the desired languages. -# https://github.com/linuxserver/docker-mods/tree/radarr-striptracks +# Prod: https://github.com/linuxserver/docker-mods/tree/radarr-striptracks +# Dev/test: https://github.com/TheCaptain989/radarr-striptracks # Adapted and corrected from Endoro's post 1/5/2014: # https://forum.videohelp.com/threads/343271-BULK-remove-non-English-tracks-from-MKV-container#post2292889 @@ -26,6 +27,7 @@ # 4 - mkvmerge not found # 5 - specified video file not found # 6 - unable to rename video to temp video +# 7 - unknown environment # 10 - remuxing completed, but no output file found # 20 - general error @@ -44,14 +46,15 @@ if [[ "${striptracks_type,,}" = "radarr" ]]; then export striptracks_json_quality_root=".movieFile" export striptracks_video_type="movie" export striptracks_title="$radarr_movie_title ($radarr_movie_year)" +elif [[ "${striptracks_type,,}" = "sonarr" ]]; then + export striptracks_video="$sonarr_episodefile_path" + export striptracks_api_endpoint="episodefile" + export striptracks_json_quality_root="" + export striptracks_video_type="series" + export striptracks_title="$sonarr_series_title $(numfmt --format "%02f" ${sonarr_episodefile_seasonnumber:-0})x$(numfmt --format "%02f" ${sonarr_episodefile_episodenumbers:-0}) - $sonarr_episodefile_episodetitles" else - if [[ "${striptracks_type,,}" = "sonarr" ]]; then - export striptracks_video="$sonarr_episodefile_path" - export striptracks_api_endpoint="episodefile" - export striptracks_json_quality_root="" - export striptracks_video_type="series" - export striptracks_title="$sonarr_series_title $(numfmt --format "%02f" $sonarr_episodefile_seasonnumber)x$(numfmt --format "%02f" $sonarr_episodefile_episodenumbers) - $sonarr_episodefile_episodetitles" - fi + echo "Unknown environment: ${striptracks_type}" + exit 7 fi export striptracks_api="Rescan${striptracks_video_type^}" export striptracks_json_key="${striptracks_video_type}Id" @@ -80,22 +83,20 @@ Source: https://github.com/TheCaptain989/radarr-striptracks Usage: $0 [-d] -Arguments: - audio_languages # ISO639-2 code(s) prefixed with a colon \`:\` - Multiple codes may be concatenated. - subtitle_languages # ISO639-2 code(s) prefixed with a colon \`:\` - Multiple codes may be concatenated. - -Options: - -d # enable debug logging +Options and Arguments: + -d enable debug logging + ISO639-2 code(s) prefixed with a colon \`:\` + Multiple codes may be concatenated. + ISO639-2 code(s) prefixed with a colon \`:\` + Multiple codes may be concatenated. Examples: $striptracks_script :eng:und :eng # keep English and Undetermined audio and - English subtitles + # English subtitles $striptracks_script :eng \"\" # keep English audio and no subtitles $striptracks_script -d :eng:kor:jpn :eng:spa # Enable debugging, keeping English, Korean, - and Japanese audio, and English and - Spanish subtitles + # and Japanese audio, and English and + # Spanish subtitles " >&2 echo "$usage" } @@ -188,6 +189,7 @@ while getopts ":d" opt; do done shift $((OPTIND -1)) +# Check for required command line options if [ -z "$1" ]; then MSG="Error|No audio languages specified!" echo "$MSG" | log @@ -204,6 +206,7 @@ if [ -z "$2" ]; then exit 3 fi +# Check for required binaries if [ ! -f "/usr/bin/mkvmerge" ]; then MSG="Error|/usr/bin/mkvmerge is required by this script" echo "$MSG" | log @@ -211,12 +214,14 @@ if [ ! -f "/usr/bin/mkvmerge" ]; then exit 4 fi +# Handle Test event if [[ "${!striptracks_eventtype}" = "Test" ]]; then echo "Info|${striptracks_type^} event: ${!striptracks_eventtype}" | log echo "Info|Script was test executed successfully." | log exit 0 fi +# Check if called from within Radarr/Sonarr if [ -z "$striptracks_video" ]; then MSG="Error|No video file specified! Not called from Radarr/Sonarr?" echo "$MSG" | log @@ -225,6 +230,7 @@ if [ -z "$striptracks_video" ]; then exit 1 fi +# Check if source video exists if [ ! -f "$striptracks_video" ]; then MSG="Error|Input file not found: \"$striptracks_video\"" echo "$MSG" | log @@ -395,7 +401,7 @@ FILESIZE=$(numfmt --to iec --format "%.3f" $(stat -c %s "$striptracks_newvideo") MSG="Info|New size: $FILESIZE" echo "$MSG" | log -# Call *arr API to RescanMovie/RescanSeries +# Call Radarr/Sonarr API to RescanMovie/RescanSeries if [ -f "$striptracks_arr_config" ]; then # Read *arr config.xml while read_xml; do