Release 2.13.1

This commit is contained in:
TheCaptain989
2025-04-16 18:52:51 +00:00
parent 40743247fc
commit 53bec57fb1
3 changed files with 102 additions and 41 deletions
+18 -3
View File
@@ -1,12 +1,20 @@
name: Build Image
on: [push, pull_request_target, workflow_dispatch]
on:
push:
pull_request_target:
workflow_dispatch:
inputs:
mod_version:
type: string
required: false
env:
GITHUB_REPO: "linuxserver/docker-mods" #don't modify
ENDPOINT: "linuxserver/mods" #don't modify
BASEIMAGE: "radarr" #replace
MODNAME: "striptracks" #replace
MOD_VERSION: ${{ inputs.mod_version }} #don't modify
MULTI_ARCH: "false" #set to true if needed
jobs:
@@ -21,8 +29,13 @@ jobs:
echo "BASEIMAGE=${{ env.BASEIMAGE }}" >> $GITHUB_OUTPUT
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.13.0"
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.13.1"
else
MOD_VERSION=${{ env.MOD_VERSION }}
echo "MOD_VERSION_OVERRIDE=true" >> $GITHUB_OUTPUT
fi
echo "MOD_VERSION=${MOD_VERSION}" >> $GITHUB_OUTPUT
outputs:
GITHUB_REPO: ${{ steps.outputs.outputs.GITHUB_REPO }}
@@ -31,6 +44,7 @@ jobs:
MODNAME: ${{ steps.outputs.outputs.MODNAME }}
MULTI_ARCH: ${{ steps.outputs.outputs.MULTI_ARCH }}
MOD_VERSION: ${{ steps.outputs.outputs.MOD_VERSION }}
MOD_VERSION_OVERRIDE: ${{ steps.outputs.outputs.MOD_VERSION_OVERRIDE }}
build:
uses: linuxserver/github-workflows/.github/workflows/docker-mod-builder.yml@v1
@@ -47,3 +61,4 @@ jobs:
MODNAME: ${{ needs.set-vars.outputs.MODNAME }}
MULTI_ARCH: ${{ needs.set-vars.outputs.MULTI_ARCH }}
MOD_VERSION: ${{ needs.set-vars.outputs.MOD_VERSION }}
MOD_VERSION_OVERRIDE: ${{ needs.set-vars.outputs.MOD_VERSION_OVERRIDE }}
+33 -2
View File
@@ -219,7 +219,7 @@ Option|Argument|Description
---|---|---
`-a`, `--audio`|`<audio_languages>`|Audio languages to keep<br/>ISO 639-2 code(s) prefixed with a colon (`:`)<br/>Each code may optionally be followed by a plus (`+`) and one or more [modifiers](#language-code-modifiers).
`-s`, `--subs`|`<subtitle_languages>`|Subtitle languages to keep<br/>ISO 639-2 code(s) prefixed with a colon (`:`)<br/>Each code may optionally be followed by a plus (`+`) and one or more modifiers.
`--reorder`| |Reorder audio and subtitles tracks to match the language code order specified in the `<audio_languages>` and `<subtitle_languages>` arguments.<br/>This is skipped if no tracks are removed.
`--reorder`| |Reorder audio and subtitles tracks to match the language code order specified in the `<audio_languages>` and `<subtitle_languages>` arguments.
`-f`, `--file`|`<video_file>`|If included, the script enters **[Batch Mode](#batch-mode)** and converts the specified video file.<br/>Requires the `--audio` option.<br/>![notes] **Do not** use this argument when called from Radarr or Sonarr!
`-l`, `--log`|`<log_file>`|The log filename<br/>Default is `/config/log/striptracks.txt`
`-c`, `--config`|`<config_file>`|Radarr/Sonarr XML configuration file<br/>Default is `/config/config.xml`
@@ -238,7 +238,7 @@ For example:
...etc.
Multiple codes may be concatenated, such as `:eng:spa` for both English and Spanish. Order is unimportant, unless the `--reorder` option is also specified.
Multiple codes may be concatenated, such as `:eng:spa` for both English and Spanish. Order is unimportant, unless the `--reorder` option is specified.
> [!WARNING]
> If no subtitle language is detected via Radarr/Sonarr configuration or specified on the command-line, all subtitles are removed.
@@ -280,6 +280,37 @@ The `:und` language code is a special code. When used, the script will match on
> [!TIP]
> It is common for M2TS and AVI files to have tracks with unknown languages! It is recommended to include `:und` in most instances unless you know exactly what you're doing.
### Reorder Option
The `--reorder` option uses the order the language codes are specified to re-order the tracks in the output MKV video file. Video tracks are always first, followed by audio tracks, and then subtitles. Track removals and preservations occur the way they normally would.
<details>
<summary>Reorder Example</summary>
For example, given a source video (w/original language of English) that has the following track order:
> Track ID:0 Type:video Name:null Lang:und Codec:AVC/H.264/MPEG-4p10 Default:true Forced:false
> Track ID:1 Type:audio Name:French Lang:fre Codec:E-AC-3 Default:true Forced:false
> Track ID:2 Type:audio Name:German Lang:deu Codec:AC-3 Default:false Forced:false
> Track ID:3 Type:audio Name:English Lang:eng Codec:AC-3 Default:false Forced:false
> Track ID:4 Type:subtitles Name:French Lang:fre Codec:SubRip/SRT Default:false Forced:false
> Track ID:5 Type:subtitles Name:English Lang:eng Codec:SubRip/SRT Default:false Forced:false
And using the command line:
```shell
/usr/local/bin/striptracks.sh --audio :org+1:eng+1:fre+1:und+1 --subs :eng+1:fre+1:spa+1 --reorder
```
Will create an MKV file with tracks:
> Track ID:0 Type:video Name:null Lang:und Codec:AVC/H.264/MPEG-4p10 Default:true Forced:false
> Track ID:1 Type:audio Name:English Lang:eng Codec:AC-3 Default:false Forced:false
> Track ID:2 Type:audio Name:French Lang:fre Codec:E-AC-3 Default:true Forced:false
> Track ID:3 Type:subtitles Name:English Lang:eng Codec:SubRip/SRT Default:false Forced:false
> Track ID:4 Type:subtitles Name:French Lang:fre Codec:SubRip/SRT Default:false Forced:false
</details>
## 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.
+51 -36
View File
@@ -96,8 +96,6 @@ Options and Arguments:
the language code order specified in the
<audio_languages> and <subtitle_languages>
arguments.
Track reorder is skipped if no tracks are
removed.
-f, --file <video_file> If included, the script enters batch mode
and converts the specified video file.
WARNING: Do not use this argument when called
@@ -1379,7 +1377,7 @@ get_mediainfo "$striptracks_video"
# Process JSON data from MKVmerge; track selection logic
striptracks_json_processed=$(echo "$striptracks_json" | jq -jcM --arg AudioKeep "$striptracks_audiokeep" \
--arg SubsKeep "$striptracks_subskeep" '
# Parse input string into JSON language rules
# Parse input string into JSON language rules function
def parse_language_codes(codes):
# Supports f, d, and number modifiers (see issues #82 and #86)
# -1 default value in language key means to keep unlimited tracks
@@ -1505,7 +1503,7 @@ else . end |
# Write messages to log
echo "$striptracks_json_processed" | jq -crM --argjson Debug $striptracks_debug '
# Join log messages into one line
# Join log messages into one line function
def log_removed_tracks($type):
if (.tracks | map(select(.type == $type and .striptracks_keep == false)) | length > 0) then
"Info|Removing \($type) tracks: " +
@@ -1532,42 +1530,23 @@ log_removed_tracks("subtitles"),
"subtitles: \(.tracks | map(select(.type == "subtitles" and .striptracks_keep)) | length))"
' | log
# Check for no audio or subtitle tracks
if [ "$(echo "$striptracks_json_processed" | jq -crM '.tracks|map(select(.type=="audio" and .striptracks_keep))')" = "" ]; then
striptracks_message="Warn|Script encountered an error when determining audio tracks to keep and must close."
# Check for no audio tracks
if [ "$(echo "$striptracks_json_processed" | jq -crM '.tracks|map(select(.type=="audio" and .striptracks_keep))')" = "[]" ]; then
striptracks_message="Error|Unable to determine any audio tracks to keep. Exiting."
echo "$striptracks_message" | log
echo "$striptracks_message" >&2
end_script 11
fi
# All tracks matched/no tracks removed (see issues #49 and #89)
if [ "$(echo "$striptracks_json" | jq -crM '.tracks|map(select(.type=="audio" or .type=="subtitles"))|length')" = "$(echo "$striptracks_json_processed" | jq -crM '.tracks|map(select((.type=="audio" or .type=="subtitles") and .striptracks_keep))|length')" ]; then
[ $striptracks_debug -ge 1 ] && echo "Debug|No tracks will be removed from video \"$striptracks_video\"" | log
# Check if already MKV
if [[ $striptracks_video == *.mkv ]]; then
# Remuxing not performed
striptracks_message="Info|No tracks would be removed from video. Setting Title only and exiting."
echo "$striptracks_message" | log
striptracks_mkvcommand="/usr/bin/mkvpropedit -q --edit info --set \"title=$striptracks_title\" \"$striptracks_video\""
[ $striptracks_debug -ge 1 ] && echo "Debug|Executing: $striptracks_mkvcommand" | log
striptracks_result=$(eval $striptracks_mkvcommand)
striptracks_return=$?; [ $striptracks_return -ne 0 ] && {
striptracks_message=$(echo -e "[$striptracks_return] Error when setting video title: \"$striptracks_tempvideo\"\nmkvpropedit returned: $striptracks_result" | awk '{print "Error|"$0}')
echo "$striptracks_message" | log
echo "$striptracks_message" >&2
striptracks_exitstatus=13
}
end_script
else
[ $striptracks_debug -ge 1 ] && echo "Debug|Source video is not MKV. Remuxing anyway." | log
fi
fi
# Map current track order
striptracks_order=$(echo "$striptracks_json_processed" | jq -jcM '.tracks | map(.id | "0:" + tostring) | join(",")')
[ $striptracks_debug -ge 1 ] && echo "Debug|Current mkvmerge track order: $striptracks_order" | log
# Prepare to reorder tracks if option is enabled
# Prepare to reorder tracks if option is enabled (see issue #92)
if [ "$striptracks_reorder" = "true" ]; then
striptracks_neworder=$(echo "$striptracks_json_processed" | jq -jcM --arg AudioKeep "$striptracks_audiokeep" \
--arg SubsKeep "$striptracks_subskeep" '
# Reorder tracks
# Reorder tracks function
def order_tracks(tracks; rules; tracktype):
rules | split(":")[1:] | map(split("+") | {lang: .[0], mods: .[1]}) |
reduce .[] as $rule (
@@ -1589,19 +1568,50 @@ def order_tracks(tracks; rules; tracktype):
)]
) | flatten;
# Reorder audio and subtitles according to language rules
# Reorder audio and subtitles according to language code order
.tracks as $tracks |
order_tracks($tracks; $AudioKeep; "audio") as $audioOrder |
order_tracks($tracks; $SubsKeep; "subtitles") as $subsOrder |
# Output ordered track string compatible with the mkvmerge --track-order option
# Video tracks are always first, followed by audio tracks, then subtitles
# NOTE: Other track types are still preserved as mkvmerge will automatically place any missing tracks after those listed per https://mkvtoolnix.download/doc/mkvmerge.html#d4e544
$tracks | map(select(.type == "video") | .id) + $audioOrder + $subsOrder | map("0:" + tostring) | join(",")
')
striptracks_neworder="--track-order $striptracks_neworder"
striptracks_message="Info|Reordering tracks using language rules."
[ $striptracks_debug -ge 1 ] && echo "Debug|New mkvmerge track order: $striptracks_neworder" | log
striptracks_message="Info|Reordering tracks using language code order."
echo "$striptracks_message" | log
[ $striptracks_debug -ge 1 ] && echo "Debug|Using track reorder string: $striptracks_neworder" | log
fi
# All tracks matched/no tracks removed (see issues #49 and #89)
if [ "$(echo "$striptracks_json" | jq -crM '.tracks|map(select(.type=="audio" or .type=="subtitles"))|length')" = "$(echo "$striptracks_json_processed" | jq -crM '.tracks|map(select((.type=="audio" or .type=="subtitles") and .striptracks_keep))|length')" ]; then
[ $striptracks_debug -ge 1 ] && echo "Debug|No tracks will be removed from video \"$striptracks_video\"" | log
# Check if already MKV
if [[ $striptracks_video == *.mkv ]]; then
# Check if reorder option is unset or if the order wouldn't change (see issue #92)
if [ "$striptracks_reorder" != "true" -o "$striptracks_order" = "$striptracks_neworder" ]; then
# Remuxing not performed
striptracks_message="Info|No tracks would be removed from video$( [ "$striptracks_reorder" = "true" ] && echo " or reordered"). Setting Title only and exiting."
echo "$striptracks_message" | log
striptracks_mkvcommand="/usr/bin/mkvpropedit -q --edit info --set \"title=$striptracks_title\" \"$striptracks_video\""
[ $striptracks_debug -ge 1 ] && echo "Debug|Executing: $striptracks_mkvcommand" | log
striptracks_result=$(eval $striptracks_mkvcommand)
striptracks_return=$?; [ $striptracks_return -ne 0 ] && {
striptracks_message=$(echo -e "[$striptracks_return] Error when setting video title: \"$striptracks_tempvideo\"\nmkvpropedit returned: $striptracks_result" | awk '{print "Error|"$0}')
echo "$striptracks_message" | log
echo "$striptracks_message" >&2
striptracks_exitstatus=13
}
end_script
else
# Reorder tracks anyway
striptracks_message="Info|No tracks will be removed from video, but they can be reordered. Remuxing anyway."
echo "$striptracks_message" | log
fi
else
# Not MKV
[ $striptracks_debug -ge 1 ] && echo "Debug|Source video is not MKV. Remuxing anyway." | log
fi
fi
# Test for hardlinked file (see issue #85)
@@ -1625,6 +1635,11 @@ else
striptracks_subsarg="-S"
fi
# Build argument for track reorder option for MKVmerge
if [ ${#striptracks_neworder} -ne 0 ]; then
striptracks_neworder="--track-order $striptracks_neworder"
fi
# Execute MKVmerge (remux then rename, see issue #46)
striptracks_mkvcommand="nice /usr/bin/mkvmerge --title \"$striptracks_title\" -q -o \"$striptracks_tempvideo\" $striptracks_audioarg $striptracks_subsarg $striptracks_neworder \"$striptracks_video\""
[ $striptracks_debug -ge 1 ] && echo "Debug|Executing: $striptracks_mkvcommand" | log
@@ -1722,7 +1737,7 @@ echo "$striptracks_message" | log
#### Call Radarr/Sonarr API to RescanMovie/RescanSeries
# Check for URL
if [ "$striptracks_type" = "batch" ]; then
[ $striptracks_debug -ge 1 ] && echo "Debug|Cannot use API in batch mode." | log
[ $striptracks_debug -ge 1 ] && echo "Debug|Not calling API while in batch mode." | log
elif [ -n "$striptracks_api_url" ]; then
# Check for video IDs
if [ "$striptracks_video_id" -a "$striptracks_videofile_id" ]; then