Merge pull request #558 from TheCaptain989/radarr-striptracks

radarr: striptracks Release 2.3.2
This commit is contained in:
aptalca 2023-01-24 20:38:29 -05:00 committed by GitHub
commit ab57c411eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 35 deletions

View File

@ -84,9 +84,7 @@ Both audio and subtitles that match the selected language(s) are kept.
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 [OPTIONS] [<audio_languages> [<subtitle_languages>]]`
OR
`striptracks.sh [OPTIONS] {-f|--file} <video_file> {-a|--audio} <audio_languages> {-s|--subs} <subtitle_languages>`
`striptracks.sh [{-d|--debug} [<level>]] [[{-f|--file} <video_file>] {-a|--audio} <audio_languages> [{-s|--subs} <subtitle_languages>]]`
Where:
@ -95,8 +93,9 @@ Option|Argument|Description
-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
-a, --audio|<audio_languages>|Audio languages to keep<br/>ISO639-2 code(s) prefixed with a colon (`:`)
-s, --subs|<subtitle_languages>|Subtitle languages to keep<br/>IISO639-2 code(s) prefixed with a colon (`:`)
-f, --file|<video_file>|If included, the script enters **[Batch Mode](./README.md#batch-mode)** and converts the specified video file.<br/>![danger] **WARNING:** Do not use this argument when called from Radarr or Sonarr!
--help| |Display help and exit
-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!
--help| |Display help and exit.
--version| |Display version and exit.
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.
For example:
@ -112,6 +111,8 @@ Multiple codes may be concatenated, such as `:eng:spa` for both English and Span
>**NOTE:** 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.
>![warning] **NOTE:** If no subtitle language is detected in the profile or specified on the command line, all subtitles are removed.
#### Original language code
The `:org` language code is a special code. When used, instead of retaining a specific language, the script substitutes the original movie language as specified in its [The Movie Database](https://www.themoviedb.org/ "TMDB") entry.
As an example, when importing "_Amores Perros (2000)_" with options `--audio :org:eng`, the Spanish and English audio tracks are preserved.
@ -129,7 +130,7 @@ The `:und` language code is a special code. When used, the script will match on
# languages detected from Radarr/Sonarr
-a :eng:und -s :eng # Keep English and Unknown audio, and English subtitles
-a :org:eng -s :eng # Keep English and Original audio, and English subtitles
:eng "" # Keep English audio and no subtitles
:eng "" # Keep English audio and remove all subtitles
-d :eng:kor:jpn :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

View File

@ -6,7 +6,8 @@ Only the latest major and minor version are supported.
| Version | Supported |
| ------- | ------------------ |
| 2.x | :heavy_check_mark: |
| 2.3.x | :heavy_check_mark: |
| < 2.3 | :x: |
## Reporting a Vulnerability

View File

@ -58,13 +58,13 @@ function usage {
usage="
$striptracks_script Version: $striptracks_ver
Video remuxing script that only keeps tracks with the specified languages.
Designed for use with Radarr and Sonarr, but may be used standalone in batch mode.
Designed for use with Radarr and Sonarr, but may be used standalone in batch
mode.
Source: https://github.com/TheCaptain989/radarr-striptracks
Usage:
$0 [OPTIONS] [<audio_languages> [<subtitle_languages>]]
$0 [OPTIONS] {-f|--file} <video_file> {-a|--audio} <audio_languages> {-s|--subs} <subtitle_languages>
$0 [{-d|--debug} [<level>]] [[{-f|--file} <video_file>] {-a|--audio} <audio_languages> [{-s|--subs} <subtitle_languages>]]
Options and Arguments:
-d, --debug [<level>] enable debug logging
@ -82,10 +82,10 @@ Options and Arguments:
--help display this help and exit
--version display script version and exit
When audio_languages and subtitle_languages are omitted the script detects the audio
or subtitle languages configured in the Radarr or Sonarr profile. When used on the command
line, they override the detected codes. They are also accepted as positional parameters
for backwards compatibility.
When audio_languages and subtitle_languages are omitted the script detects the
audio or subtitle languages configured in the Radarr or Sonarr profile. When
used on the command line, they override the detected codes. They are also
accepted as positional parameters for backwards compatibility.
Batch Mode:
In batch mode the script acts as if it were not called from within Radarr
@ -94,21 +94,23 @@ Batch Mode:
attribute is set to the basename of the file minus the extension.
Examples:
$striptracks_script -d 2 # Enable debugging level 2, audio and subtitles
# languages detected from Radarr/Sonarr
$striptracks_script -a :eng:und -s :eng # keep English and Unknown audio and
# English subtitles
$striptracks_script -a :eng:org -s :eng # keep English and Original audio and
# English subtitles
$striptracks_script :eng \"\" # keep English audio and no subtitles
$striptracks_script -d :eng:kor:jpn :eng:spa # Enable debugging level 1, keeping English, Korean,
# and Japanese audio, and English and
# Spanish subtitles
$striptracks_script -f \"/path/to/movies/Finding Nemo (2003).mkv\" -a :eng:und -s :eng
# Batch Mode
# Keep English and Unknown audio and
# English subtitles, converting video specified
$striptracks_script -d 2 # Enable debugging level 2, audio and
# subtitles languages detected from
# Radarr/Sonarr
$striptracks_script -a :eng:und -s :eng # keep English and Unknown audio and
# English subtitles
$striptracks_script -a :eng:org -s :eng # keep English and Original audio and
# English subtitles
$striptracks_script :eng \"\" # keep English audio and no subtitles
$striptracks_script -d :eng:kor:jpn :eng:spa # Enable debugging level 1, keeping
# English, Korean, and Japanese
# audio, and English and Spanish
# subtitles
$striptracks_script -f \"/movies/path/Finding Nemo (2003).mkv\" -a :eng:und -s :eng
# Batch Mode
# Keep English and Unknown audio and
# English subtitles, converting video
# specified
"
echo "$usage" >&2
}
@ -181,10 +183,18 @@ eval set -- "$striptracks_pos_params"
# Check for and assign positional arguments
if [ -n "$1" ]; then
striptracks_audiokeep="$1"
if [ -n "$striptracks_audiokeep" ]; then
echo "Warning|Both positional and named arguments set for audio. Using $striptracks_audiokeep" >&2
else
striptracks_audiokeep="$1"
fi
fi
if [ -n "$2" ]; then
striptracks_subskeep="$2"
if [ -n "$striptracks_subskeep" ]; then
echo "Warning|Both positional and named arguments set for subtitles. Using $striptracks_subskeep" >&2
else
striptracks_subskeep="$2"
fi
fi
## Mode specific variables
@ -606,11 +616,9 @@ if [ -n "$striptracks_subskeep" ]; then
elif [ -n "$striptracks_proflangCodes" ]; then
striptracks_subskeep="$striptracks_proflangCodes"
else
striptracks_message="Error|No subtitles languages specified or detected!"
striptracks_message="Info|No subtitles languages specified or detected. Removing all subtitles found."
echo "$striptracks_message" | log
echo "$striptracks_message" >&2
usage
exit 3
striptracks_subskeep="null"
fi
#### BEGIN MAIN