mirror of
https://github.com/TrezOne/docker-mods-uptime-kuma-timeout-fix.git
synced 2026-06-29 19:50:53 -04:00
Release 2.13.1
This commit is contained in:
Executable → Regular
+51
-36
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user