├── .assets ├── add-custom-format.png ├── add-language-condition.png ├── custom-format-conditions.png ├── notes.png ├── radarr-enable-hardlinks.png ├── radarr-quality-profile.png ├── striptracks-synology-2.png ├── striptracks-synology.png ├── striptracks-v2-custom-script.png ├── striptracks-v3-custom-script.png └── warning.png ├── .dockerignore ├── .gitattributes ├── .github ├── develop │ ├── e.json │ ├── e.sh │ ├── s.sh │ ├── t.sh │ ├── test.sh │ └── x.sh ├── linters │ ├── .gitleaks.toml │ ├── .hadolint.yaml │ ├── .markdown-lint.yml │ ├── .powershell-psscriptanalyzer.psd1 │ └── .shellcheckrc ├── tests │ ├── Racism_is_evil.json │ ├── test5.json │ ├── test_01_cmd_line.sh │ ├── test_02_logs.sh │ ├── test_03_required_binaries.sh │ ├── test_04_eventtype.sh │ ├── test_05_config.sh │ ├── test_06_video.sh │ ├── test_07_miscellaneous.sh │ ├── test_08_remux_video.sh │ ├── test_09_radarr.sh │ └── vsshort-vorbis-subs.json └── workflows │ └── BuildImage.yml ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── SECURITY.md ├── hotio ├── 99-striptracks.sh ├── README.md └── hotio-striptracks-synology.png ├── root ├── etc │ └── s6-overlay │ │ └── s6-rc.d │ │ ├── init-mod-radarr-striptracks-add-package │ │ ├── dependencies.d │ │ │ └── init-mods │ │ ├── run │ │ ├── type │ │ └── up │ │ ├── init-mods-package-install │ │ └── dependencies.d │ │ │ └── init-mod-radarr-striptracks-add-package │ │ └── user │ │ └── contents.d │ │ └── init-mod-radarr-striptracks-add-package └── usr │ └── local │ └── bin │ ├── striptracks-debug-2.sh │ ├── striptracks-debug-max.sh │ ├── striptracks-debug.sh │ ├── striptracks-dut.sh │ ├── striptracks-eng-debug.sh │ ├── striptracks-eng-fre.sh │ ├── striptracks-eng-jpn.sh │ ├── striptracks-eng.sh │ ├── striptracks-fre.sh │ ├── striptracks-ger.sh │ ├── striptracks-org-eng.sh │ ├── striptracks-org-ger.sh │ ├── striptracks-org-spa.sh │ ├── striptracks-spa.sh │ └── striptracks.sh └── wsl ├── README.md ├── wsl-custom-script.png ├── wsl-install-striptracks.ps1 ├── wsl-striptracks-debug.cmd └── wsl-striptracks.cmd /.assets/add-custom-format.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/b398bd22a77f14498955257342fa03445c59e84b/.assets/add-custom-format.png -------------------------------------------------------------------------------- /.assets/add-language-condition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/b398bd22a77f14498955257342fa03445c59e84b/.assets/add-language-condition.png -------------------------------------------------------------------------------- /.assets/custom-format-conditions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/b398bd22a77f14498955257342fa03445c59e84b/.assets/custom-format-conditions.png -------------------------------------------------------------------------------- /.assets/notes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/b398bd22a77f14498955257342fa03445c59e84b/.assets/notes.png -------------------------------------------------------------------------------- /.assets/radarr-enable-hardlinks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/b398bd22a77f14498955257342fa03445c59e84b/.assets/radarr-enable-hardlinks.png -------------------------------------------------------------------------------- /.assets/radarr-quality-profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/b398bd22a77f14498955257342fa03445c59e84b/.assets/radarr-quality-profile.png -------------------------------------------------------------------------------- /.assets/striptracks-synology-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/b398bd22a77f14498955257342fa03445c59e84b/.assets/striptracks-synology-2.png -------------------------------------------------------------------------------- /.assets/striptracks-synology.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/b398bd22a77f14498955257342fa03445c59e84b/.assets/striptracks-synology.png -------------------------------------------------------------------------------- /.assets/striptracks-v2-custom-script.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/b398bd22a77f14498955257342fa03445c59e84b/.assets/striptracks-v2-custom-script.png -------------------------------------------------------------------------------- /.assets/striptracks-v3-custom-script.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/b398bd22a77f14498955257342fa03445c59e84b/.assets/striptracks-v3-custom-script.png -------------------------------------------------------------------------------- /.assets/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/b398bd22a77f14498955257342fa03445c59e84b/.assets/warning.png -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | # Docker ignore file 2 | .git 3 | .gitignore 4 | .github 5 | .gitattributes 6 | .vscode 7 | .assets 8 | hotio 9 | wsl 10 | READMETEMPLATE.md 11 | README.md 12 | SECURITY.md 13 | bash_unit 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.github/develop/e.json: -------------------------------------------------------------------------------- 1 | { 2 | "things": [ 3 | {"name": "thing1", "type": "a"}, 4 | {"name": "thing2", "type": "a"}, 5 | {"name": "thing3", "type": "b"}, 6 | {"name":"thing4","type":"c"} 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /.github/develop/e.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # shellcheck disable=all 4 | jq -c --argjson rules '{"rules":{"a":1,"b":-1}}' ' 5 | reduce .things[] as $thing ( 6 | {"things": [], "counts": {}}; 7 | .counts[$thing.type] = (.counts[$thing.type] // 0) | 8 | .things += [ 9 | $thing + { 10 | "keep": ( 11 | ($rules.rules[$thing.type] == -1) or 12 | (.counts[$thing.type] < $rules.rules[$thing.type]) 13 | ) 14 | } 15 | ] | 16 | .counts[$thing.type] += if ($rules.rules[$thing.type] == -1) then 0 else (.things[-1].keep | if . then 1 else 0 end) end 17 | ) 18 | | .things 19 | ' .github/tests/e.json 20 | -------------------------------------------------------------------------------- /.github/develop/s.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # shellcheck disable=all 4 | json='{"tracks":[{"properties":{"language":"eng"}},{"properties":{"language":"eng"}},{"properties":{"language":"fre"}}]}' 5 | 6 | echo "$json" | jq -c --argjson rules_raw '{"languages":{"eng":1,"fre":-1,"mis":-1,"zxx":-1}}' ' 7 | # Parse input JSON and rules, then apply logic 8 | reduce .tracks[] as $track ( 9 | {"tracks": [], "counts": {}}; 10 | .counts[$track.properties.language] = (.counts[$track.properties.language] // 0) | 11 | .tracks += [ 12 | $track + { 13 | "keep": ( 14 | ($rules_raw.languages[$track.properties.language] == -1) or 15 | (.counts[$track.properties.language] < $rules_raw.languages[$track.properties.language]) 16 | ) 17 | } 18 | ] | 19 | .counts[$track.properties.language] += 20 | if ($rules_raw.languages[$track.properties.language] == -1 or (.tracks[-1].keep | not)) then 21 | 0 22 | else 23 | 1 24 | end 25 | ) 26 | | .tracks 27 | 28 | ' -------------------------------------------------------------------------------- /.github/develop/t.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # shellcheck disable=all 4 | #json='{"attachments":[],"chapters":[],"container":{"properties":{"container_type":25,"is_providing_timestamps":true},"recognized":true,"supported":true,"type":"QuickTime/MP4"},"errors":[],"file_name":"ElephantsDream.mp4","global_tags":[],"identification_format_version":12,"track_tags":[],"tracks":[{"codec":"MPEG-4p10/AVC/H.264","id":0,"properties":{"language":"","number":1,"packetizer":"mpeg4_p10_video","pixel_dimensions":"1280x720"},"type":"video"},{"codec":"MPEG-4p10/AVC/H.264","id":10,"properties":{"language":"","number":10,"packetizer":"mpeg4_p10_video","pixel_dimensions":"1280x720"},"type":"video"},{"codec":"AAC","id":1,"properties":{"audio_bits_per_sample":16,"audio_channels":2,"audio_sampling_frequency":44100,"number":2},"type":"audio"},{"codec":"TheCaptain989-forced","id":2,"properties":{"audio_bits_per_sample":16,"audio_channels":2,"audio_sampling_frequency":44100,"track_name":"Should include","language":"ger","number":5,"forced_track":true},"type":"audio"},{"codec":"TheCaptain989-default","id":3,"properties":{"audio_bits_per_sample":16,"audio_channels":2,"audio_sampling_frequency":44100,"track_name":"Should include","language":"ger","number":6,"default_track":true},"type":"audio"},{"codec":"TheCaptain989","id":4,"properties":{"audio_bits_per_sample":16,"audio_channels":2,"audio_sampling_frequency":44100,"track_name":"Should include","language":"eng","number":3},"type":"audio"},{"codec":"TheCaptain989-2","id":5,"properties":{"audio_bits_per_sample":16,"audio_channels":2,"audio_sampling_frequency":44100,"language":"eng","track_name":"Should exclude","number":4},"type":"audio"}],"warnings":[]}' 5 | json='{"attachments":[],"chapters":[],"container":{"properties":{"container_type":25,"is_providing_timestamps":true},"recognized":true,"supported":true,"type":"QuickTime/MP4"},"errors":[],"file_name":"ElephantsDream.mp4","global_tags":[],"identification_format_version":12,"track_tags":[],"tracks":[{"codec":"MPEG-4p10/AVC/H.264","id":0,"properties":{"language":"","number":1,"packetizer":"mpeg4_p10_video","pixel_dimensions":"1280x720"},"type":"video"},{"codec":"MPEG-4p10/AVC/H.264","id":10,"properties":{"language":"","number":10,"packetizer":"mpeg4_p10_video","pixel_dimensions":"1280x720"},"type":"video"},{"codec":"AAC","id":1,"properties":{"audio_bits_per_sample":16,"audio_channels":2,"audio_sampling_frequency":44100,"number":2},"type":"audio"},{"codec":"TheCaptain989-forced","id":2,"properties":{"audio_bits_per_sample":16,"audio_channels":2,"audio_sampling_frequency":44100,"track_name":"Should include","language":"ger","number":5,"forced_track":true},"type":"audio"},{"codec":"TheCaptain989-default","id":3,"properties":{"audio_bits_per_sample":16,"audio_channels":2,"audio_sampling_frequency":44100,"track_name":"Should include","language":"ger","number":6,"default_track":true},"type":"audio"},{"codec":"SubsAlpha","id":4,"properties":{"track_name":"Should include","language":"eng","forced_track":true},"type":"subtitles"},{"codec":"TheCaptain989","id":5,"properties":{"audio_bits_per_sample":16,"audio_channels":2,"audio_sampling_frequency":44100,"track_name":"Should include","language":"eng","number":3},"type":"audio"},{"codec":"TheCaptain989-2","id":6,"properties":{"audio_bits_per_sample":16,"audio_channels":2,"audio_sampling_frequency":44100,"language":"eng","track_name":"Should exclude","number":4},"type":"audio"}],"warnings":[]}' 6 | 7 | echo $json | jq -c '.tracks | map(.properties.language)' 8 | 9 | json_processed=$(echo "$json" | jq -c --argjson AudioRules '{"languages":{"eng":1,"fre":-1},"forced_languages":{"any":-1},"default_languages":{"ger":-1}}' \ 10 | --argjson SubsRules '{"languages":null,"forced_languages":{"any":-1},"default_languages":null}' ' 11 | # Process tracks 12 | reduce .tracks[] as $track ( 13 | # Create object to hold tracks and counters for each reduce iteration 14 | # This is what will be output at the end of the reduce loop 15 | {"tracks": [], "counters": {"audio": {"normal": {}, "forced": {}, "default": {}}, "subtitles": {"normal": {}, "forced": {}, "default": {}}}}; 16 | 17 | # Set track language to "und" if null or empty 18 | # NOTE: The // operator cannot be used here because it checks for null or empty values, not blank strings 19 | (if ($track.properties.language == "" or $track.properties.language == null) then "und" else $track.properties.language end) as $track_lang | 20 | 21 | # Initialize counters for each track type and language 22 | (.counters[$track.type].normal[$track_lang] //= 0) | 23 | if $track.properties.forced_track then (.counters[$track.type].forced[$track_lang] //= 0) else . end | 24 | if $track.properties.default_track then (.counters[$track.type].default[$track_lang] //= 0) else . end | 25 | .counters[$track.type] as $track_counters | 26 | 27 | # Add tracks one at a time to output object above 28 | .tracks += [ 29 | $track | 30 | .striptracks_debug_log = "Debug|Parsing track ID:\(.id) Type:\(.type) Name:\(.properties.track_name) Lang:\($track_lang) Codec:\(.codec) Default:\(.properties.default_track) Forced:\(.properties.forced_track)" | 31 | # Use track language evaluation above 32 | .properties.language = $track_lang | 33 | 34 | # Determine keep logic based on type and rules 35 | if .type == "video" then 36 | .striptracks_keep = true 37 | elif .type == "audio" or .type == "subtitles" then 38 | .striptracks_log = "\(.id): \($track_lang) (\(.codec))\(if .properties.track_name then " \"" + .properties.track_name + "\"" else "" end)" | 39 | # Same logic for both audio and subtitles 40 | (if .type == "audio" then $AudioRules else $SubsRules end) as $currentRules | 41 | if ($currentRules.languages["any"] == -1 or ($track_counters.normal | add) < $currentRules.languages["any"] or 42 | $currentRules.languages[$track_lang] == -1 or $track_counters.normal[$track_lang] < $currentRules.languages[$track_lang]) then 43 | .striptracks_keep = true 44 | elif (.properties.forced_track and 45 | ($currentRules.forced_languages["any"] == -1 or ($track_counters.forced | add) < $currentRules.forced_languages["any"] or 46 | $currentRules.forced_languages[$track_lang] == -1 or $track_counters.forced[$track_lang] < $currentRules.forced_languages[$track_lang])) then 47 | .striptracks_keep = true | 48 | .striptracks_rule = "forced" 49 | elif (.properties.default_track and 50 | ($currentRules.default_languages["any"] == -1 or ($track_counters.default | add) < $currentRules.default_languages["any"] or 51 | $currentRules.default_languages[$track_lang] == -1 or $track_counters.default[$track_lang] < $currentRules.default_languages[$track_lang])) then 52 | .striptracks_keep = true | 53 | .striptracks_rule = "default" 54 | else . end | 55 | if .striptracks_keep then 56 | .striptracks_log = "Info|Keeping \(if .striptracks_rule then .striptracks_rule + " " else "" end)\(.type) track " + .striptracks_log 57 | else 58 | .striptracks_keep = false 59 | end 60 | else . end 61 | ] | 62 | 63 | # Increment counters for each track type and language 64 | .counters[$track.type].normal[$track_lang] += 65 | if .tracks[-1].striptracks_keep then 66 | 1 67 | else 0 end | 68 | .counters[$track.type].forced[$track_lang] += 69 | if ($track.properties.forced_track and .tracks[-1].striptracks_keep) then 70 | 1 71 | else 0 end | 72 | .counters[$track.type].default[$track_lang] += 73 | if ($track.properties.default_track and .tracks[-1].striptracks_keep) then 74 | 1 75 | else 0 end 76 | ) | 77 | 78 | # Output simplified dataset 79 | { striptracks_log, tracks: .tracks | map({ id, type, language: .properties.language, forced: .properties.forced_track, default: .properties.default_track, striptracks_debug_log, striptracks_log, striptracks_rule, striptracks_keep }) } 80 | ') 81 | 82 | echo $json_processed | jq -c '.tracks | map({id, language, striptracks_rule, striptracks_keep})' 83 | 84 | striptracks_audiokeep=":any+f:ger:eng+1" 85 | striptracks_subskeep=":any+f" 86 | 87 | # Reorder tracks 88 | echo "$json_processed" | jq -c --arg AudioKeep "$striptracks_audiokeep" \ 89 | --arg SubsKeep "$striptracks_subskeep" ' 90 | # Reorder tracks 91 | def order_tracks(tracks; rules; tracktype): 92 | rules | split(":")[1:] | map(split("+") | {lang: .[0], mods: .[1]}) | 93 | reduce .[] as $rule ( 94 | []; 95 | . as $orderedTracks | 96 | . += [tracks | 97 | map(. as $track | 98 | select(.type == tracktype and .striptracks_keep and 99 | ($rule.lang | in({"any":0,($track.language):0})) and 100 | ($rule.mods == null or 101 | ($rule.mods | test("[fd]") | not) or 102 | ($rule.mods | contains("f") and $track.forced) or 103 | ($rule.mods | contains("d") and $track.default) 104 | ) 105 | ) | 106 | .id as $id | 107 | # Remove track id from orderedTracks if it already exists 108 | if ([$id] | flatten | inside($orderedTracks | flatten)) then empty else $id end 109 | )] 110 | ) | flatten; 111 | 112 | # Reorder audio and subtitles according to language rules 113 | .tracks as $tracks | 114 | order_tracks($tracks; $AudioKeep; "audio") as $audioOrder | 115 | order_tracks($tracks; $SubsKeep; "subtitles") as $subsOrder | 116 | 117 | # Output ordered track string compatible with the mkvmerge --track-order option 118 | # Video tracks are always first, followed by audio tracks, then subtitles 119 | $tracks | map(select(.type == "video") | .id) + $audioOrder + $subsOrder | map("0:" + tostring) | join(",") 120 | ' 121 | -------------------------------------------------------------------------------- /.github/develop/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | striptracks_pid=$$ 4 | 5 | function log {( 6 | while read -r 7 | do 8 | # shellcheck disable=2046 9 | echo $(date +"%Y-%m-%d %H:%M:%S.%1N")"|[$striptracks_pid]$REPLY" 10 | done 11 | )} 12 | 13 | striptracks_json='{ 14 | "attachments": [], 15 | "chapters": [], 16 | "container": { 17 | "properties": { 18 | "container_type": 25, 19 | "is_providing_timestamps": true 20 | }, 21 | "recognized": true, 22 | "supported": true, 23 | "type": "QuickTime/MP4" 24 | }, 25 | "errors": [], 26 | "file_name": "ElephantsDream.mp4", 27 | "global_tags": [], 28 | "identification_format_version": 12, 29 | "track_tags": [], 30 | "tracks": [ 31 | { 32 | "codec": "MPEG-4p10/AVC/H.264", 33 | "id": 0, 34 | "properties": { 35 | "language": "", 36 | "number": 1, 37 | "packetizer": "mpeg4_p10_video", 38 | "pixel_dimensions": "1280x720" 39 | }, 40 | "type": "video" 41 | }, 42 | { 43 | "codec": "AAC", 44 | "id": 1, 45 | "properties": { 46 | "audio_bits_per_sample": 16, 47 | "audio_channels": 2, 48 | "audio_sampling_frequency": 44100, 49 | "number": 2 50 | }, 51 | "type": "audio" 52 | }, 53 | { 54 | "codec": "TheCaptain989-forced", 55 | "id": 4, 56 | "properties": { 57 | "audio_bits_per_sample": 16, 58 | "audio_channels": 2, 59 | "audio_sampling_frequency": 44100, 60 | "track_name": "Should include", 61 | "language": "ger", 62 | "number": 5, 63 | "forced_track": true 64 | }, 65 | "type": "audio" 66 | }, 67 | { 68 | "codec": "TheCaptain989-default", 69 | "id": 5, 70 | "properties": { 71 | "audio_bits_per_sample": 16, 72 | "audio_channels": 2, 73 | "audio_sampling_frequency": 44100, 74 | "track_name": "Should include", 75 | "language": "ger", 76 | "number": 6, 77 | "default_track": true 78 | }, 79 | "type": "audio" 80 | }, 81 | { 82 | "codec": "TheCaptain989-subs", 83 | "id": 27, 84 | "properties": { 85 | "track_name": "Subs forced", 86 | "language": "fre", 87 | "number": 3, 88 | "forced_track": true 89 | }, 90 | "type": "subtitles" 91 | }, 92 | { 93 | "codec": "TheCaptain989", 94 | "id": 2, 95 | "properties": { 96 | "audio_bits_per_sample": 16, 97 | "audio_channels": 2, 98 | "audio_sampling_frequency": 44100, 99 | "track_name": "Should include", 100 | "language": "eng", 101 | "number": 3 102 | }, 103 | "type": "audio" 104 | }, 105 | { 106 | "codec": "TheCaptain989-2", 107 | "id": 3, 108 | "properties": { 109 | "audio_bits_per_sample": 16, 110 | "audio_channels": 2, 111 | "audio_sampling_frequency": 44100, 112 | "language": "eng", 113 | "track_name": "Should exclude", 114 | "number": 4 115 | }, 116 | "type": "audio" 117 | } 118 | ], 119 | "warnings": [] 120 | }' 121 | 122 | striptracks_audiokeep=":eng+1:fre:ger+d:any+f" 123 | striptracks_subskeep=":any+f" 124 | 125 | echo "Keeping Audio $striptracks_audiokeep Subtitles $striptracks_subskeep" 126 | 127 | striptracks_json_processed=$(echo "$striptracks_json" | jq -c --arg AudioKeep "$striptracks_audiokeep" \ 128 | --arg SubsKeep "$striptracks_subskeep" ' 129 | # Parse input string into JSON language rules 130 | def parse_language_codes(codes): 131 | # Supports f, d, and number modifiers (see issues #82 and #86) 132 | # -1 default value in language key means to keep unlimited tracks 133 | # NOTE: Logic can result in duplicate keys, but jq just uses the last defined key 134 | codes | split(":")[1:] | map(split("+") | {lang: .[0], mods: .[1]}) | 135 | {languages: map( 136 | # Select tracks with no modifiers or only numeric modifiers 137 | (select(.mods == null) | {(.lang): -1}), 138 | (select(.mods | test("^[0-9]+$")?) | {(.lang): .mods | tonumber}) 139 | ) | add, 140 | forced_languages: map( 141 | # Select tracks with f modifier 142 | select(.mods | contains("f")?) | {(.lang): ((.mods | scan("[0-9]+") | tonumber) // -1)} 143 | ) | add, 144 | default_languages: map( 145 | # Select tracks with d modifier 146 | select(.mods | contains("d")?) | {(.lang): ((.mods | scan("[0-9]+") | tonumber) // -1)} 147 | ) | add 148 | }; 149 | 150 | # Language rules for audio and subtitles, adding required audio tracks (see issue #54) 151 | (parse_language_codes($AudioKeep) | .languages += {"mis":-1,"zxx":-1}) as $AudioRules | 152 | parse_language_codes($SubsKeep) as $SubsRules | 153 | 154 | # Log chapter information 155 | if (.chapters[0].num_entries) then 156 | .striptracks_log = "Info|Chapters: \(.chapters[].num_entries)" 157 | else . end | 158 | 159 | # Process tracks 160 | reduce .tracks[] as $track ( 161 | # Create object to hold tracks and counters for each reduce iteration 162 | # This is what will be output at the end of the reduce loop 163 | {"tracks": [], "counters": {"audio": {"normal": {}, "forced": {}, "default": {}}, "subtitles": {"normal": {}, "forced": {}, "default": {}}}}; 164 | 165 | # Set track language to "und" if null or empty 166 | # NOTE: The // operator cannot be used here because it checks for null or empty values, not blank strings 167 | (if ($track.properties.language == "" or $track.properties.language == null) then "und" else $track.properties.language end) as $track_lang | 168 | 169 | # Initialize counters for each track type and language 170 | (.counters[$track.type].normal[$track_lang] //= 0) | 171 | if $track.properties.forced_track then (.counters[$track.type].forced[$track_lang] //= 0) else . end | 172 | if $track.properties.default_track then (.counters[$track.type].default[$track_lang] //= 0) else . end | 173 | .counters[$track.type] as $track_counters | 174 | 175 | # Add tracks one at a time to output object above 176 | .tracks += [ 177 | $track | 178 | .striptracks_debug_log = "Debug|Parsing track ID:\(.id) Type:\(.type) Name:\(.properties.track_name) Lang:\($track_lang) Codec:\(.codec) Default:\(.properties.default_track) Forced:\(.properties.forced_track)" | 179 | # Use track language evaluation above 180 | .properties.language = $track_lang | 181 | 182 | # Determine keep logic based on type and rules 183 | if .type == "video" then 184 | .striptracks_keep = true 185 | elif .type == "audio" or .type == "subtitles" then 186 | .striptracks_log = "\(.id): \($track_lang) (\(.codec))\(if .properties.track_name then " \"" + .properties.track_name + "\"" else "" end)" | 187 | # Same logic for both audio and subtitles 188 | (if .type == "audio" then $AudioRules else $SubsRules end) as $currentRules | 189 | if ($currentRules.languages["any"] == -1 or ($track_counters.normal | add) < $currentRules.languages["any"] or 190 | $currentRules.languages[$track_lang] == -1 or $track_counters.normal[$track_lang] < $currentRules.languages[$track_lang]) then 191 | .striptracks_keep = true 192 | elif (.properties.forced_track and 193 | ($currentRules.forced_languages["any"] == -1 or ($track_counters.forced | add) < $currentRules.forced_languages["any"] or 194 | $currentRules.forced_languages[$track_lang] == -1 or $track_counters.forced[$track_lang] < $currentRules.forced_languages[$track_lang])) then 195 | .striptracks_keep = true | 196 | .striptracks_rule = "forced" 197 | elif (.properties.default_track and 198 | ($currentRules.default_languages["any"] == -1 or ($track_counters.default | add) < $currentRules.default_languages["any"] or 199 | $currentRules.default_languages[$track_lang] == -1 or $track_counters.default[$track_lang] < $currentRules.default_languages[$track_lang])) then 200 | .striptracks_keep = true | 201 | .striptracks_rule = "default" 202 | else . end | 203 | if .striptracks_keep then 204 | .striptracks_log = "Info|Keeping \(if .striptracks_rule then .striptracks_rule + " " else "" end)\(.type) track " + .striptracks_log 205 | else 206 | .striptracks_keep = false 207 | end 208 | else . end 209 | ] | 210 | 211 | # Increment counters for each track type and language 212 | .counters[$track.type].normal[$track_lang] += 213 | if .tracks[-1].striptracks_keep then 214 | 1 215 | else 0 end | 216 | .counters[$track.type].forced[$track_lang] += 217 | if ($track.properties.forced_track and .tracks[-1].striptracks_keep) then 218 | 1 219 | else 0 end | 220 | .counters[$track.type].default[$track_lang] += 221 | if ($track.properties.default_track and .tracks[-1].striptracks_keep) then 222 | 1 223 | else 0 end 224 | ) | 225 | 226 | # Ensure at least one audio track is kept 227 | if ((.tracks | map(select(.type == "audio")) | length == 1) and (.tracks | map(select(.type == "audio" and .striptracks_keep)) | length == 0)) then 228 | # If there is only one audio track and none are kept, keep the only audio track 229 | .tracks |= map(if .type == "audio" then 230 | .striptracks_log = "Warn|No audio tracks matched! Keeping only audio track " + .striptracks_log | 231 | .striptracks_keep = true 232 | else . end) 233 | elif (.tracks | map(select(.type == "audio" and .striptracks_keep)) | length == 0) then 234 | # If no audio tracks are kept, first try to keep the default audio track 235 | .tracks |= map(if .type == "audio" and .properties.default_track then 236 | .striptracks_log = "Warn|No audio tracks matched! Keeping default audio track " + .striptracks_log | 237 | .striptracks_keep = true 238 | else . end) | 239 | # If still no audio tracks are kept, keep the first audio track 240 | if (.tracks | map(select(.type == "audio" and .striptracks_keep)) | length == 0) then 241 | (first(.tracks[] | select(.type == "audio"))) |= . + 242 | {striptracks_log: ("Warn|No audio tracks matched! Keeping first audio track " + .striptracks_log), 243 | striptracks_keep: true} 244 | else . end 245 | else . end | 246 | 247 | # Output simplified dataset 248 | { striptracks_log, tracks: .tracks | map({ id, type, language: .properties.language, forced: .properties.forced_track, default: .properties.default_track, striptracks_debug_log, striptracks_log, striptracks_keep }) } 249 | ') 250 | 251 | echo "$striptracks_json_processed" | jq -c . 252 | 253 | # Reorder tracks 254 | echo "$striptracks_json_processed" | jq -c --arg AudioKeep "$striptracks_audiokeep" \ 255 | --arg SubsKeep "$striptracks_subskeep" ' 256 | # Reorder tracks 257 | def order_tracks(tracks; rules; tracktype): 258 | rules | split(":")[1:] | map(split("+") | {lang: .[0], mods: .[1]}) | 259 | reduce .[] as $rule ( 260 | []; 261 | . as $orderedTracks | 262 | . += [tracks | 263 | map(. as $track | 264 | select(.type == tracktype and .striptracks_keep and 265 | ($rule.lang | in({"any":0,($track.language):0})) and 266 | ($rule.mods == null or 267 | ($rule.mods | test("[fd]") | not) or 268 | ($rule.mods | contains("f") and $track.forced) or 269 | ($rule.mods | contains("d") and $track.default) 270 | ) 271 | ) | 272 | .id as $id | 273 | # Remove track id from orderedTracks if it already exists 274 | if ([$id] | flatten | inside($orderedTracks | flatten)) then empty else $id end 275 | )] 276 | ) | flatten; 277 | 278 | # Reorder audio and subtitles according to language rules 279 | .tracks as $tracks | 280 | order_tracks($tracks; $AudioKeep; "audio") as $audioOrder | 281 | order_tracks($tracks; $SubsKeep; "subtitles") as $subsOrder | 282 | 283 | # Output ordered track string compatible with the mkvmerge --track-order option 284 | # Video tracks are always first, followed by audio tracks, then subtitles 285 | $tracks | map(select(.type == "video") | .id) + $audioOrder + $subsOrder | map("0:" + tostring) | join(",") 286 | ' 287 | -------------------------------------------------------------------------------- /.github/develop/x.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | striptracks_audiokeep=":org+1:eng+1:fre+1:und+1" 4 | striptracks_subskeep=":eng+1:fre+1:spa+1" 5 | 6 | json='{"attachments":[],"chapters":[],"container":{"properties":{"container_type":25,"is_providing_timestamps":true},"recognized":true,"supported":true,"type":"QuickTime/MP4"},"errors":[],"file_name":"ElephantsDream.mp4","global_tags":[],"identification_format_version":12,"track_tags":[],"tracks":[{"codec":"MPEG-4p10/AVC/H.264","id":0,"properties":{"language":"","number":1,"packetizer":"mpeg4_p10_video","pixel_dimensions":"1280x720"},"type":"video"},{"codec":"MPEG-4p10/AVC/H.264","id":10,"properties":{"language":"","number":10,"packetizer":"mpeg4_p10_video","pixel_dimensions":"1280x720"},"type":"video"},{"codec":"AAC","id":1,"properties":{"audio_bits_per_sample":16,"audio_channels":2,"audio_sampling_frequency":44100,"number":2},"type":"audio"},{"codec":"TheCaptain989-forced","id":2,"properties":{"audio_bits_per_sample":16,"audio_channels":2,"audio_sampling_frequency":44100,"track_name":"Should include","language":"ger","number":5,"forced_track":true},"type":"audio"},{"codec":"TheCaptain989-default","id":3,"properties":{"audio_bits_per_sample":16,"audio_channels":2,"audio_sampling_frequency":44100,"track_name":"Should include","language":"ger","number":6,"default_track":true},"type":"audio"},{"codec":"SubsAlpha","id":4,"properties":{"track_name":"Should include","language":"eng","forced_track":true},"type":"subtitles"},{"codec":"TheCaptain989","id":5,"properties":{"audio_bits_per_sample":16,"audio_channels":2,"audio_sampling_frequency":44100,"track_name":"Should include","language":"eng","number":3},"type":"audio"},{"codec":"TheCaptain989-2","id":6,"properties":{"audio_bits_per_sample":16,"audio_channels":2,"audio_sampling_frequency":44100,"language":"eng","track_name":"Should exclude","number":4},"type":"audio"}],"warnings":[]}' 7 | 8 | json_processed='{"striptracks_log":null,"tracks":[{"id":0,"type":"video","language":"und","forced":false,"default":true,"striptracks_debug_log":"Debug|Parsing track ID:0 Type:video Name:null Lang:und Codec:MPEG-4p10/AVC/H.264 Default:true Forced:false","striptracks_log":null,"striptracks_keep":true},{"id":1,"type":"audio","language":"und","forced":false,"default":true,"striptracks_debug_log":"Debug|Parsing track ID:1 Type:audio Name:null Lang:und Codec:AAC Default:true Forced:false","striptracks_log":"Info|Keeping audio track 1: und (AAC)","striptracks_keep":true}]}' 9 | 10 | json_processed=$(echo "$json" | jq -jcM --arg AudioKeep "$striptracks_audiokeep" \ 11 | --arg SubsKeep "$striptracks_subskeep" ' 12 | # Parse input string into JSON language rules 13 | def parse_language_codes(codes): 14 | # Supports f, d, and number modifiers (see issues #82 and #86) 15 | # -1 default value in language key means to keep unlimited tracks 16 | # NOTE: Logic can result in duplicate keys, but jq just uses the last defined key 17 | codes | split(":")[1:] | map(split("+") | {lang: .[0], mods: .[1]}) | 18 | {languages: map( 19 | # Select tracks with no modifiers or only numeric modifiers 20 | (select(.mods == null) | {(.lang): -1}), 21 | (select(.mods | test("^[0-9]+$")?) | {(.lang): .mods | tonumber}) 22 | ) | add, 23 | forced_languages: map( 24 | # Select tracks with f modifier 25 | select(.mods | contains("f")?) | {(.lang): ((.mods | scan("[0-9]+") | tonumber) // -1)} 26 | ) | add, 27 | default_languages: map( 28 | # Select tracks with d modifier 29 | select(.mods | contains("d")?) | {(.lang): ((.mods | scan("[0-9]+") | tonumber) // -1)} 30 | ) | add 31 | }; 32 | 33 | # Language rules for audio and subtitles, adding required audio tracks (see issue #54) 34 | (parse_language_codes($AudioKeep) | .languages += {"mis":-1,"zxx":-1}) as $AudioRules | 35 | parse_language_codes($SubsKeep) as $SubsRules | 36 | 37 | # Log chapter information 38 | if (.chapters[0].num_entries) then 39 | .striptracks_log = "Info|Chapters: \(.chapters[].num_entries)" 40 | else . end | 41 | 42 | # Process tracks 43 | reduce .tracks[] as $track ( 44 | # Create object to hold tracks and counters for each reduce iteration 45 | # This is what will be output at the end of the reduce loop 46 | {"tracks": [], "counters": {"audio": {"normal": {}, "forced": {}, "default": {}}, "subtitles": {"normal": {}, "forced": {}, "default": {}}}}; 47 | 48 | # Set track language to "und" if null or empty 49 | # NOTE: The // operator cannot be used here because it checks for null or empty values, not blank strings 50 | (if ($track.properties.language == "" or $track.properties.language == null) then "und" else $track.properties.language end) as $track_lang | 51 | 52 | # Initialize counters for each track type and language 53 | (.counters[$track.type].normal[$track_lang] //= 0) | 54 | if $track.properties.forced_track then (.counters[$track.type].forced[$track_lang] //= 0) else . end | 55 | if $track.properties.default_track then (.counters[$track.type].default[$track_lang] //= 0) else . end | 56 | .counters[$track.type] as $track_counters | 57 | 58 | # Add tracks one at a time to output object above 59 | .tracks += [ 60 | $track | 61 | .striptracks_debug_log = "Debug|Parsing track ID:\(.id) Type:\(.type) Name:\(.properties.track_name) Lang:\($track_lang) Codec:\(.codec) Default:\(.properties.default_track) Forced:\(.properties.forced_track)" | 62 | # Use track language evaluation above 63 | .properties.language = $track_lang | 64 | 65 | # Determine keep logic based on type and rules 66 | if .type == "video" then 67 | .striptracks_keep = true 68 | elif .type == "audio" or .type == "subtitles" then 69 | .striptracks_log = "\(.id): \($track_lang) (\(.codec))\(if .properties.track_name then " \"" + .properties.track_name + "\"" else "" end)" | 70 | # Same logic for both audio and subtitles 71 | (if .type == "audio" then $AudioRules else $SubsRules end) as $currentRules | 72 | if ($currentRules.languages["any"] == -1 or ($track_counters.normal | add) < $currentRules.languages["any"] or 73 | $currentRules.languages[$track_lang] == -1 or $track_counters.normal[$track_lang] < $currentRules.languages[$track_lang]) then 74 | .striptracks_keep = true 75 | elif (.properties.forced_track and 76 | ($currentRules.forced_languages["any"] == -1 or ($track_counters.forced | add) < $currentRules.forced_languages["any"] or 77 | $currentRules.forced_languages[$track_lang] == -1 or $track_counters.forced[$track_lang] < $currentRules.forced_languages[$track_lang])) then 78 | .striptracks_keep = true | 79 | .striptracks_rule = "forced" 80 | elif (.properties.default_track and 81 | ($currentRules.default_languages["any"] == -1 or ($track_counters.default | add) < $currentRules.default_languages["any"] or 82 | $currentRules.default_languages[$track_lang] == -1 or $track_counters.default[$track_lang] < $currentRules.default_languages[$track_lang])) then 83 | .striptracks_keep = true | 84 | .striptracks_rule = "default" 85 | else . end | 86 | if .striptracks_keep then 87 | .striptracks_log = "Info|Keeping \(if .striptracks_rule then .striptracks_rule + " " else "" end)\(.type) track " + .striptracks_log 88 | else 89 | .striptracks_keep = false 90 | end 91 | else . end 92 | ] | 93 | 94 | # Increment counters for each track type and language 95 | .counters[$track.type].normal[$track_lang] += 96 | if .tracks[-1].striptracks_keep then 97 | 1 98 | else 0 end | 99 | .counters[$track.type].forced[$track_lang] += 100 | if ($track.properties.forced_track and .tracks[-1].striptracks_keep) then 101 | 1 102 | else 0 end | 103 | .counters[$track.type].default[$track_lang] += 104 | if ($track.properties.default_track and .tracks[-1].striptracks_keep) then 105 | 1 106 | else 0 end 107 | ) | 108 | 109 | # Ensure at least one audio track is kept 110 | if ((.tracks | map(select(.type == "audio")) | length == 1) and (.tracks | map(select(.type == "audio" and .striptracks_keep)) | length == 0)) then 111 | # If there is only one audio track and none are kept, keep the only audio track 112 | .tracks |= map(if .type == "audio" then 113 | .striptracks_log = "Warn|No audio tracks matched! Keeping only audio track " + .striptracks_log | 114 | .striptracks_keep = true 115 | else . end) 116 | elif (.tracks | map(select(.type == "audio" and .striptracks_keep)) | length == 0) then 117 | # If no audio tracks are kept, first try to keep the default audio track 118 | .tracks |= map(if .type == "audio" and .properties.default_track then 119 | .striptracks_log = "Warn|No audio tracks matched! Keeping default audio track " + .striptracks_log | 120 | .striptracks_keep = true 121 | else . end) | 122 | # If still no audio tracks are kept, keep the first audio track 123 | if (.tracks | map(select(.type == "audio" and .striptracks_keep)) | length == 0) then 124 | (first(.tracks[] | select(.type == "audio"))) |= . + 125 | {striptracks_log: ("Warn|No audio tracks matched! Keeping first audio track " + .striptracks_log), 126 | striptracks_keep: true} 127 | else . end 128 | else . end | 129 | 130 | # Output simplified dataset 131 | { striptracks_log, tracks: .tracks | map({ id, type, language: .properties.language, forced: .properties.forced_track, default: .properties.default_track, striptracks_debug_log, striptracks_log, striptracks_keep }) } 132 | ') 133 | 134 | order=$(echo "$json_processed" | jq -jcM ' 135 | .tracks | map(.id | "0:" + tostring) | join(",") 136 | ') 137 | 138 | neworder=$(echo "$json_processed" | jq -jcM --arg AudioKeep "$striptracks_audiokeep" \ 139 | --arg SubsKeep "$striptracks_subskeep" ' 140 | # Reorder tracks 141 | def order_tracks(tracks; rules; tracktype): 142 | rules | split(":")[1:] | map(split("+") | {lang: .[0], mods: .[1]}) | 143 | reduce .[] as $rule ( 144 | []; 145 | . as $orderedTracks | 146 | . += [tracks | 147 | map(. as $track | 148 | select(.type == tracktype and .striptracks_keep and 149 | ($rule.lang | in({"any":0,($track.language):0})) and 150 | ($rule.mods == null or 151 | ($rule.mods | test("[fd]") | not) or 152 | ($rule.mods | contains("f") and $track.forced) or 153 | ($rule.mods | contains("d") and $track.default) 154 | ) 155 | ) | 156 | .id as $id | 157 | # Remove track id from orderedTracks if it already exists 158 | if ([$id] | flatten | inside($orderedTracks | flatten)) then empty else $id end 159 | )] 160 | ) | flatten; 161 | 162 | # Reorder audio and subtitles according to language rules 163 | .tracks as $tracks | 164 | order_tracks($tracks; $AudioKeep; "audio") as $audioOrder | 165 | order_tracks($tracks; $SubsKeep; "subtitles") as $subsOrder | 166 | 167 | # Output ordered track string compatible with the mkvmerge --track-order option 168 | # Video tracks are always first, followed by audio tracks, then subtitles 169 | $tracks | map(select(.type == "video") | .id) + $audioOrder + $subsOrder | map("0:" + tostring) | join(",") 170 | ') 171 | 172 | echo $order 173 | echo $neworder 174 | 175 | if [ "$order" = "$neworder" ]; then 176 | echo "Success" 177 | else 178 | echo "Failure" 179 | fi -------------------------------------------------------------------------------- /.github/linters/.gitleaks.toml: -------------------------------------------------------------------------------- 1 | 2 | title = "gitleaks config" 3 | 4 | [extend] 5 | # useDefault will extend the base configuration with the default gitleaks config: 6 | # https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml 7 | useDefault = true -------------------------------------------------------------------------------- /.github/linters/.hadolint.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | ########################## 3 | ## Hadolint config file ## 4 | ########################## 5 | 6 | failure-threshold: warning 7 | 8 | ignored: -------------------------------------------------------------------------------- /.github/linters/.markdown-lint.yml: -------------------------------------------------------------------------------- 1 | --- 2 | ########################### 3 | ########################### 4 | ## Markdown Linter rules ## 5 | ########################### 6 | ########################### 7 | 8 | # Linter rules doc: 9 | # - https://github.com/DavidAnson/markdownlint 10 | # 11 | # Note: 12 | # To comment out a single error: 13 | # 14 | # any violations you want 15 | # 16 | # 17 | 18 | ############### 19 | # Rules by id # 20 | ############### 21 | MD004: false # Unordered list style 22 | MD007: 23 | indent: 2 # Unordered list indentation 24 | MD013: 25 | line_length: 400 # Line length 80 is far too short 26 | MD022: 27 | lines_below: 0 # Headings only need a blank line before 28 | MD025: false # Allow multiple top level headings 29 | MD026: 30 | punctuation: ".,;:!。,;:" # List of not allowed 31 | MD028: false # Allow block quotes to be separated by blank lines 32 | MD029: false # Ordered list item prefix 33 | MD032: false # Lists don't need blank lines 34 | MD033: false # Allow inline HTML 35 | MD036: false # Emphasis used instead of a heading 36 | 37 | ################# 38 | # Rules by tags # 39 | ################# -------------------------------------------------------------------------------- /.github/linters/.powershell-psscriptanalyzer.psd1: -------------------------------------------------------------------------------- 1 | #Documentation: https://github.com/PowerShell/PSScriptAnalyzer/blob/master/docs/Cmdlets/Invoke-ScriptAnalyzer.md#-settings 2 | @{ 3 | #CustomRulePath='path\to\CustomRuleModule.psm1' 4 | #RecurseCustomRulePath='path\of\customrules' 5 | #Severity = @( 6 | # 'Error' 7 | # 'Warning' 8 | #) 9 | IncludeDefaultRules=${true} 10 | ExcludeRules = @( 11 | 'PSUseSingularNouns', 12 | 'PSReviewUnusedParameter' 13 | ) 14 | #IncludeRules = @( 15 | # 'PSAvoidUsingWriteHost', 16 | # 'MyCustomRuleName' 17 | #) 18 | } -------------------------------------------------------------------------------- /.github/linters/.shellcheckrc: -------------------------------------------------------------------------------- 1 | # ShellCheck global configuration 2 | source-path=SCRIPTDIR 3 | 4 | # Invalid source location 5 | disable=SC1090,SC1091 6 | 7 | # Double quote to prevent globbing and word splitting 8 | disable=SC2086 9 | 10 | # Declare and assign separately to avoid masking return values 11 | disable=SC2155 12 | 13 | # Prefer [ p ] && [ q ] as [ p -a q ] is not well defined 14 | disable=SC2166 15 | -------------------------------------------------------------------------------- /.github/tests/Racism_is_evil.json: -------------------------------------------------------------------------------- 1 | { 2 | "attachments": [], 3 | "chapters": [], 4 | "container": { 5 | "properties": { 6 | "container_type": 17, 7 | "duration": 35454000000, 8 | "is_providing_timestamps": true, 9 | "muxing_application": "Lavf57.56.101", 10 | "writing_application": "Lavf57.56.101" 11 | }, 12 | "recognized": true, 13 | "supported": true, 14 | "type": "Matroska" 15 | }, 16 | "errors": [], 17 | "file_name": "Racism_is_evil.webm", 18 | "global_tags": [], 19 | "identification_format_version": 12, 20 | "track_tags": [], 21 | "tracks": [ 22 | { 23 | "codec": "VP9", 24 | "id": 0, 25 | "properties": { 26 | "codec_id": "V_VP9", 27 | "codec_private_length": 0, 28 | "default_duration": 40000000, 29 | "default_track": true, 30 | "display_dimensions": "426x240", 31 | "display_unit": 0, 32 | "enabled_track": true, 33 | "forced_track": false, 34 | "language": "eng", 35 | "minimum_timestamp": 44000000, 36 | "number": 1, 37 | "pixel_dimensions": "426x240", 38 | "uid": 1 39 | }, 40 | "type": "video" 41 | }, 42 | { 43 | "codec": "Opus", 44 | "id": 1, 45 | "properties": { 46 | "audio_bits_per_sample": 32, 47 | "audio_channels": 2, 48 | "audio_sampling_frequency": 48000, 49 | "codec_delay": 6500000, 50 | "codec_id": "A_OPUS", 51 | "codec_private_data": "4f707573486561640102380180bb0000000000", 52 | "codec_private_length": 19, 53 | "default_track": true, 54 | "enabled_track": true, 55 | "forced_track": false, 56 | "language": "eng", 57 | "minimum_timestamp": 0, 58 | "number": 2, 59 | "uid": 2 60 | }, 61 | "type": "audio" 62 | } 63 | ], 64 | "warnings": [] 65 | } 66 | -------------------------------------------------------------------------------- /.github/tests/test5.json: -------------------------------------------------------------------------------- 1 | { 2 | "attachments": [], 3 | "chapters": [], 4 | "container": { 5 | "properties": { 6 | "container_type": 17, 7 | "date_local": "2010-08-21T18:06:43+00:00", 8 | "date_utc": "2010-08-21T18:06:43Z", 9 | "duration": 46665000000, 10 | "is_providing_timestamps": true, 11 | "muxing_application": "libebml v1.0.0 + libmatroska v1.0.0", 12 | "segment_uid": "9d516a0f927a12d286e1502d23d0fdb0", 13 | "writing_application": "mkvmerge v4.0.0 ('The Stars were mine') built on Jun 6 2010 16:18:42" 14 | }, 15 | "recognized": true, 16 | "supported": true, 17 | "type": "Matroska" 18 | }, 19 | "errors": [], 20 | "file_name": "test5.mkv", 21 | "global_tags": [ 22 | { 23 | "num_entries": 3 24 | } 25 | ], 26 | "identification_format_version": 12, 27 | "track_tags": [], 28 | "tracks": [ 29 | { 30 | "codec": "MPEG-4p10/AVC/H.264", 31 | "id": 0, 32 | "properties": { 33 | "codec_id": "V_MPEG4/ISO/AVC", 34 | "codec_private_data": "014d401fffe10014274d401fa918080093600d418041adb0ad7bdf0101000428ce09c8", 35 | "codec_private_length": 35, 36 | "default_duration": 41666665, 37 | "default_track": true, 38 | "display_dimensions": "1024x576", 39 | "display_unit": 0, 40 | "enabled_track": true, 41 | "forced_track": false, 42 | "language": "und", 43 | "minimum_timestamp": 0, 44 | "number": 1, 45 | "packetizer": "mpeg4_p10_video", 46 | "pixel_dimensions": "1024x576", 47 | "uid": 1258329745 48 | }, 49 | "type": "video" 50 | }, 51 | { 52 | "codec": "AAC", 53 | "id": 1, 54 | "properties": { 55 | "audio_channels": 2, 56 | "audio_sampling_frequency": 48000, 57 | "codec_id": "A_AAC", 58 | "codec_private_data": "1190", 59 | "codec_private_length": 2, 60 | "default_duration": 21333333, 61 | "default_track": true, 62 | "enabled_track": true, 63 | "forced_track": false, 64 | "language": "und", 65 | "minimum_timestamp": 12000000, 66 | "number": 2, 67 | "uid": 3452711582 68 | }, 69 | "type": "audio" 70 | }, 71 | { 72 | "codec": "SubRip/SRT", 73 | "id": 2, 74 | "properties": { 75 | "codec_id": "S_TEXT/UTF8", 76 | "codec_private_length": 0, 77 | "default_track": true, 78 | "enabled_track": true, 79 | "encoding": "UTF-8", 80 | "forced_track": false, 81 | "language": "eng", 82 | "minimum_timestamp": 3549000000, 83 | "number": 3, 84 | "text_subtitles": true, 85 | "uid": 368310685 86 | }, 87 | "type": "subtitles" 88 | }, 89 | { 90 | "codec": "SubRip/SRT", 91 | "id": 3, 92 | "properties": { 93 | "codec_id": "S_TEXT/UTF8", 94 | "codec_private_length": 0, 95 | "default_track": false, 96 | "enabled_track": true, 97 | "encoding": "UTF-8", 98 | "forced_track": false, 99 | "language": "hun", 100 | "minimum_timestamp": 42000000, 101 | "number": 4, 102 | "text_subtitles": true, 103 | "uid": 77489046 104 | }, 105 | "type": "subtitles" 106 | }, 107 | { 108 | "codec": "SubRip/SRT", 109 | "id": 4, 110 | "properties": { 111 | "codec_id": "S_TEXT/UTF8", 112 | "codec_private_length": 0, 113 | "default_track": false, 114 | "enabled_track": true, 115 | "encoding": "UTF-8", 116 | "forced_track": false, 117 | "language": "ger", 118 | "minimum_timestamp": 42000000, 119 | "number": 5, 120 | "text_subtitles": true, 121 | "uid": 3554194305 122 | }, 123 | "type": "subtitles" 124 | }, 125 | { 126 | "codec": "SubRip/SRT", 127 | "id": 5, 128 | "properties": { 129 | "codec_id": "S_TEXT/UTF8", 130 | "codec_private_length": 0, 131 | "default_track": false, 132 | "enabled_track": true, 133 | "encoding": "UTF-8", 134 | "forced_track": false, 135 | "language": "fre", 136 | "minimum_timestamp": 42000000, 137 | "number": 6, 138 | "text_subtitles": true, 139 | "uid": 3601783439 140 | }, 141 | "type": "subtitles" 142 | }, 143 | { 144 | "codec": "SubRip/SRT", 145 | "id": 6, 146 | "properties": { 147 | "codec_id": "S_TEXT/UTF8", 148 | "codec_private_length": 0, 149 | "default_track": false, 150 | "enabled_track": true, 151 | "encoding": "UTF-8", 152 | "forced_track": false, 153 | "language": "spa", 154 | "minimum_timestamp": 42000000, 155 | "number": 8, 156 | "text_subtitles": true, 157 | "uid": 637820071 158 | }, 159 | "type": "subtitles" 160 | }, 161 | { 162 | "codec": "SubRip/SRT", 163 | "id": 7, 164 | "properties": { 165 | "codec_id": "S_TEXT/UTF8", 166 | "codec_private_length": 0, 167 | "default_track": false, 168 | "enabled_track": true, 169 | "encoding": "UTF-8", 170 | "forced_track": false, 171 | "language": "ita", 172 | "minimum_timestamp": 42000000, 173 | "number": 9, 174 | "text_subtitles": true, 175 | "uid": 2328328329 176 | }, 177 | "type": "subtitles" 178 | }, 179 | { 180 | "codec": "AAC", 181 | "id": 8, 182 | "properties": { 183 | "audio_channels": 1, 184 | "audio_sampling_frequency": 22050, 185 | "codec_id": "A_AAC", 186 | "codec_private_data": "1388", 187 | "codec_private_length": 2, 188 | "default_duration": 46439909, 189 | "default_track": false, 190 | "enabled_track": true, 191 | "forced_track": false, 192 | "language": "eng", 193 | "minimum_timestamp": 9000000, 194 | "number": 10, 195 | "track_name": "Commentary", 196 | "uid": 215750297 197 | }, 198 | "type": "audio" 199 | }, 200 | { 201 | "codec": "SubRip/SRT", 202 | "id": 9, 203 | "properties": { 204 | "codec_id": "S_TEXT/UTF8", 205 | "codec_private_length": 0, 206 | "default_track": false, 207 | "enabled_track": true, 208 | "encoding": "UTF-8", 209 | "forced_track": false, 210 | "language": "jpn", 211 | "minimum_timestamp": 42000000, 212 | "number": 11, 213 | "text_subtitles": true, 214 | "uid": 652628868 215 | }, 216 | "type": "subtitles" 217 | }, 218 | { 219 | "codec": "SubRip/SRT", 220 | "id": 10, 221 | "properties": { 222 | "codec_id": "S_TEXT/UTF8", 223 | "codec_private_length": 0, 224 | "default_track": false, 225 | "enabled_track": true, 226 | "encoding": "UTF-8", 227 | "forced_track": false, 228 | "language": "und", 229 | "minimum_timestamp": 42000000, 230 | "number": 7, 231 | "text_subtitles": true, 232 | "uid": 131186099 233 | }, 234 | "type": "subtitles" 235 | } 236 | ], 237 | "warnings": [] 238 | } 239 | -------------------------------------------------------------------------------- /.github/tests/test_01_cmd_line.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # bash_unit tests 4 | # Command line options 5 | 6 | setup_suite() { 7 | source ../../root/usr/local/bin/striptracks.sh 8 | initialize_variables 9 | } 10 | 11 | test_cmd_options_require_argument() { 12 | assert_status_code 1 "process_command_line --log" && \ 13 | assert_status_code 1 "process_command_line --file" && \ 14 | assert_status_code 1 "process_command_line --config" 15 | } 16 | 17 | test_cmd_unknown_option() { 18 | assert_status_code 20 "process_command_line --will-fail 2>&1" 19 | } 20 | 21 | test_cmd_invalid_audio_option() { 22 | assert_status_code 2 "process_command_line --audio eng 2>&1" 23 | } 24 | 25 | test_cmd_invalid_subs_option() { 26 | assert_status_code 3 "process_command_line --subtitles eng 2>&1" 27 | } 28 | 29 | test_cmd_dup_options_audio() { 30 | assert_matches "^Warning\|Both positional.*audio" "$(process_command_line :eng -a :org 2>&1)" 31 | } 32 | 33 | test_cmd_dup_options_subs() { 34 | assert_matches "^Warning\|Both positional.*subtitles" "$(process_command_line :fre :eng -s :org 2>&1)" 35 | } 36 | 37 | test_env_usage_with_cmd() { 38 | local STRIPTRACKS_ARGS="-a :org" 39 | process_command_line -a :eng 40 | assert_matches "^Warning\|STRIPTRACKS_ARGS environment.*" "$striptracks_prelogmessage" 41 | } 42 | 43 | test_env_usage() { 44 | local STRIPTRACKS_ARGS="-a :org" 45 | process_command_line 46 | assert_equals "Info|Using settings from environment variable." "$striptracks_prelogmessage" 47 | } 48 | 49 | teardown() { 50 | unset STRIPTRACKS_ARGS striptracks_prelogmessage 51 | } -------------------------------------------------------------------------------- /.github/tests/test_02_logs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # bash_unit tests 4 | # Logs 5 | 6 | setup_suite() { 7 | source ../../root/usr/local/bin/striptracks.sh 8 | initialize_variables 9 | } 10 | 11 | test_create_log() { 12 | check_log >/dev/null 13 | assert_equals "/config/logs/striptracks.txt" "$striptracks_log" && \ 14 | assert "test -f $striptracks_log" 15 | } 16 | 17 | todo_log_not_writable() { 18 | # Doesn't work properly in a container 19 | local striptracks_log="./striptracks.txt" 20 | touch "$striptracks_log" 21 | chmod -f a-w "$striptracks_log" 22 | check_log 2>/dev/null 23 | assert_equals 12 $striptracks_exitstatus 24 | } 25 | 26 | teardown() { 27 | rm -f "./striptracks.txt" 28 | unset striptracks_log striptracks_exitstatus 29 | } 30 | -------------------------------------------------------------------------------- /.github/tests/test_03_required_binaries.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # bash_unit tests 4 | # Required binaries 5 | # mkvtoolnix installed from BuildImage.yml 6 | 7 | setup_suite() { 8 | source ../../root/usr/local/bin/striptracks.sh 9 | initialize_variables 10 | fake log : 11 | } 12 | 13 | test_binaries_present() { 14 | assert check_required_binaries 15 | } 16 | test_missing_mkvmerge() { 17 | mv /usr/bin/mkvmerge /usr/bin/mkvmerge.bak 18 | assert_status_code 4 "check_required_binaries 2>/dev/null" && \ 19 | assert_matches "^Error\|/usr/bin/mkvmerge is required" "$(check_required_binaries 2>&1)" 20 | mv /usr/bin/mkvmerge.bak /usr/bin/mkvmerge 21 | } 22 | 23 | test_missing_mkvpropedit() { 24 | mv /usr/bin/mkvpropedit /usr/bin/mkvpropedit.bak 25 | assert_status_code 4 "check_required_binaries 2>/dev/null" && \ 26 | assert_matches "^Error\|/usr/bin/mkvpropedit is required" "$(check_required_binaries 2>&1)" 27 | mv /usr/bin/mkvpropedit.bak /usr/bin/mkvpropedit 28 | } 29 | -------------------------------------------------------------------------------- /.github/tests/test_04_eventtype.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # bash_unit tests 4 | # Eventtype 5 | 6 | setup_suite() { 7 | source ../../root/usr/local/bin/striptracks.sh 8 | initialize_variables 9 | process_command_line -a :eng 10 | fake log : 11 | } 12 | 13 | test_unknown_eventtype() { 14 | assert_status_code 7 "initialize_mode_variables" 15 | } 16 | 17 | test_radarr_eventtype() { 18 | export radarr_eventtype="Import" 19 | initialize_variables 20 | initialize_mode_variables 21 | assert_equals "movie" "$striptracks_video_type" 22 | } 23 | 24 | test_sonarr_eventtype() { 25 | export sonarr_eventtype="Import" 26 | initialize_variables 27 | initialize_mode_variables 28 | assert_equals "series" "$striptracks_video_type" 29 | } 30 | 31 | test_unsupported_eventtype() { 32 | export radarr_eventtype="Grab" 33 | initialize_variables 34 | initialize_mode_variables 35 | assert_status_code 20 "check_eventtype 2>/dev/null" 36 | } 37 | 38 | test_test_event() { 39 | export radarr_eventtype="Test" 40 | initialize_variables 41 | initialize_mode_variables 42 | assert_equals "Info|Script was test executed successfully." "$(check_eventtype)" 43 | } 44 | 45 | teardown() { 46 | unset radarr_eventtype sonarr_eventtype striptracks_video_type 47 | } 48 | -------------------------------------------------------------------------------- /.github/tests/test_05_config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # bash_unit tests 4 | # Configuration file 5 | 6 | setup_suite() { 7 | source ../../root/usr/local/bin/striptracks.sh 8 | export radarr_eventtype="Import" 9 | initialize_variables 10 | initialize_mode_variables 11 | fake log : 12 | } 13 | 14 | test_api_url() { 15 | fake get_version : 16 | fake check_compat : 17 | check_config 18 | assert_equals "http://localhost:7878/api/v3" "$striptracks_api_url" 19 | } 20 | 21 | test_api_curl_failure() { 22 | fake get_version return 1 23 | assert_status_code 17 "check_config 2>/dev/null" 24 | } 25 | 26 | test_api_bad_version() { 27 | fake get_version : 28 | fake check_compat return 1 29 | assert_status_code 8 "check_config 2>/dev/null" 30 | } 31 | 32 | teardown_suite() { 33 | unset radarr_eventtype striptracks_arr_config 34 | } 35 | -------------------------------------------------------------------------------- /.github/tests/test_06_video.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # bash_unit tests 4 | # Video checks 5 | 6 | setup_suite() { 7 | source ../../root/usr/local/bin/striptracks.sh 8 | initialize_variables 9 | export striptracks_video="test_video.mp4" 10 | fake log : 11 | } 12 | 13 | test_video_var_not_set() { 14 | unset striptracks_video 15 | assert_status_code 1 "check_video 2>/dev/null" 16 | } 17 | 18 | test_video_not_exist() { 19 | rm -f "$striptracks_video" 20 | assert_status_code 5 "check_video 2>/dev/null" 21 | } 22 | 23 | test_set_temp_video() { 24 | touch "$striptracks_video" 25 | check_video 26 | assert_matches "^\./test_\.tmp\..{6}$" "$striptracks_tempvideo" 27 | } 28 | 29 | teardown_suite() { 30 | rm -f "$striptracks_video" 31 | unset striptracks_video striptracks_tempvideo 32 | } 33 | -------------------------------------------------------------------------------- /.github/tests/test_07_miscellaneous.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # bash_unit tests 4 | # Miscellaneous checks 5 | 6 | setup_suite() { 7 | source ../../root/usr/local/bin/striptracks.sh 8 | initialize_variables 9 | fake log : 10 | } 11 | 12 | test_org_code() { 13 | fake check_compat : 14 | striptracks_type="radarr" 15 | striptracks_audiokeep=":eng:org" 16 | striptracks_originalLangCode=":eng" 17 | process_org_code audio striptracks_audiokeep 18 | assert_equals ":eng:eng" "$striptracks_audiokeep" 19 | } 20 | -------------------------------------------------------------------------------- /.github/tests/test_08_remux_video.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # bash_unit tests 4 | # Remux video file 5 | # mkvtoolnix installed from BuildImage.yml 6 | 7 | setup_suite() { 8 | which mkvmerge >/dev/null || { printf "\t\e[0;91mmkvmerge not found\e[0m\n"; exit 1; } 9 | source ../../root/usr/local/bin/striptracks.sh 10 | initialize_variables 11 | check_log >/dev/null 12 | export test_video1="Racism_is_evil.webm" 13 | export test_video2="vsshort-vorbis-subs.mkv" 14 | export test_video3="test5.mkv" 15 | fake log : 16 | } 17 | 18 | setup() { 19 | [ -f "$test_video1" ] || wget -q "https://upload.wikimedia.org/wikipedia/commons/transcoded/e/e4/%27Racism_is_evil%2C%27_Trump_says.webm/%27Racism_is_evil%2C%27_Trump_says.webm.240p.vp9.webm?download" -O "$test_video1" 20 | [ -f "$test_video2" ] || wget -q "https://mkvtoolnix.download/samples/vsshort-vorbis-subs.mkv" 21 | [ -f "$test_video3" ] || wget -q "https://github.com/ietf-wg-cellar/matroska-test-files/raw/refs/heads/master/test_files/test5.mkv" 22 | } 23 | 24 | test_get_media_info() { 25 | process_command_line -a :eng -f "$test_video1" 26 | get_mediainfo "$test_video1" 27 | assert_equals "true" "$(echo "$striptracks_json" | jq -crM '.container.supported')" 28 | } 29 | 30 | test_remux_video() { 31 | process_command_line -a :eng -f "$test_video1" 32 | check_video 33 | get_mediainfo "$striptracks_video" 34 | process_mkvmerge_json 35 | remux_video 36 | assert "test -f \"$striptracks_tempvideo\" && rm -f \"$striptracks_tempvideo\"" 37 | } 38 | 39 | test_remux_video_replace() { 40 | process_command_line -a :eng -f "$test_video1" 41 | initialize_mode_variables 42 | check_video 43 | get_mediainfo "$striptracks_video" 44 | process_mkvmerge_json 45 | remux_video 46 | replace_original_video 47 | assert "test -f \"$striptracks_newvideo\"" 48 | } 49 | 50 | test_remove_all_subtitles() { 51 | process_command_line -a :eng -f "$test_video2" 52 | initialize_mode_variables 53 | check_video 54 | get_mediainfo "$striptracks_video" 55 | process_mkvmerge_json 56 | remux_video 57 | assert_equals "" "$(mkvmerge -J "$striptracks_tempvideo" | jq -crM '.tracks[] | select(.type == "subtitles")')" 58 | } 59 | 60 | test_set_title_only() { 61 | fake end_script : 62 | process_command_line -a :und -s :und -f "$test_video2" 63 | initialize_mode_variables 64 | check_video 65 | get_mediainfo "$striptracks_video" 66 | process_mkvmerge_json 67 | set_title_and_exit_if_nothing_removed 68 | assert_equals "vsshort-vorbis-subs" "$(mkvmerge -J "$striptracks_video" | jq -crM '.container.properties.title')" 69 | } 70 | 71 | todo_mkvmerge_error() { 72 | process_command_line -a :eng -f "bear-1280x720-a_frag-cenc.mp4" 73 | initialize_mode_variables 74 | check_video 75 | get_mediainfo "$striptracks_video" 76 | process_mkvmerge_json 77 | assert_status_code 13 "remux_video 2>/dev/null" 78 | } 79 | 80 | test_temp_file_deleted() { 81 | process_command_line -a :eng -f "$test_video3" 82 | initialize_mode_variables 83 | check_video 84 | get_mediainfo "$striptracks_video" 85 | process_mkvmerge_json 86 | remux_video 87 | rm -f "$striptracks_tempvideo" 88 | assert_status_code 10 "replace_original_video 2>/dev/null" 89 | } 90 | 91 | teardown_suite() { 92 | rm -f "${test_video1%.webm}.mkv" "$test_video1" "$test_video2" "$test_video3" "./striptracks.txt" 93 | unset striptracks_video test_video1 test_video2 test_video3 94 | } 95 | -------------------------------------------------------------------------------- /.github/tests/test_09_radarr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # bash_unit tests 4 | # Radarr API 5 | 6 | setup_suite() { 7 | source ../../root/usr/local/bin/striptracks.sh 8 | fake log : 9 | } 10 | 11 | setup() { 12 | export radarr_eventtype="Import" 13 | initialize_variables 14 | initialize_mode_variables 15 | check_log >/dev/null 16 | check_required_binaries 17 | } 18 | 19 | test_radarr_test_event() { 20 | export radarr_eventtype="Test" 21 | initialize_mode_variables 22 | assert_equals "Info|Script was test executed successfully." "$(check_eventtype)" 23 | } 24 | 25 | test_radarr_version() { 26 | check_eventtype 27 | check_config 28 | assert_within_delta 5 ${striptracks_arr_version/.*/} 1 29 | } 30 | 31 | teardown_suite() { 32 | unset radarr_eventtype striptracks_arr_config 33 | } 34 | -------------------------------------------------------------------------------- /.github/tests/vsshort-vorbis-subs.json: -------------------------------------------------------------------------------- 1 | { 2 | "attachments": [], 3 | "chapters": [], 4 | "container": { 5 | "properties": { 6 | "container_type": 17, 7 | "date_local": "2004-08-10T09:29:39+00:00", 8 | "date_utc": "2004-08-10T09:29:39Z", 9 | "duration": 71255000000, 10 | "is_providing_timestamps": true, 11 | "muxing_application": "libebml v0.7.1 + libmatroska v0.7.2", 12 | "segment_uid": "280b1b3ab09d12197d606869e6153c38", 13 | "writing_application": "mkvmerge v0.9.4 built on Aug 10 2004 11:21:23" 14 | }, 15 | "recognized": true, 16 | "supported": true, 17 | "type": "Matroska" 18 | }, 19 | "errors": [], 20 | "file_name": "vsshort-vorbis-subs.mkv", 21 | "global_tags": [], 22 | "identification_format_version": 12, 23 | "track_tags": [], 24 | "tracks": [ 25 | { 26 | "codec": "0x44495633 \"DIV3\"", 27 | "id": 0, 28 | "properties": { 29 | "codec_id": "V_MS/VFW/FOURCC", 30 | "codec_private_data": "280000008002000060010000010018004449563300500a0000000000000000000000000000000000", 31 | "codec_private_length": 40, 32 | "default_duration": 41708375, 33 | "default_track": true, 34 | "display_dimensions": "640x352", 35 | "display_unit": 0, 36 | "enabled_track": true, 37 | "forced_track": false, 38 | "language": "und", 39 | "minimum_timestamp": 0, 40 | "number": 1, 41 | "pixel_dimensions": "640x352", 42 | "uid": 3059093025 43 | }, 44 | "type": "video" 45 | }, 46 | { 47 | "codec": "Vorbis", 48 | "id": 1, 49 | "properties": { 50 | "audio_channels": 2, 51 | "audio_sampling_frequency": 48000, 52 | "codec_id": "A_VORBIS", 53 | "codec_private_data": "021e2d01766f72626973000000000280bb0000000000000177010000000000b80103766f726269731d000000586970682e4f7267206c6962566f726269732049203230303230373137000000000105766f7262697325424356010040000024735a3266a973d87bef1d429219e31c42d07bef99414c11a21c42cc6bec21639219c3a0428a63aa81d09055000040000067bd97da7bcbbdf7de7b46b967d47b69bdf7de7bc8bd87d67bcabdf7de7befbdf7de7befbdf7de7b25b167927b48bdf7de7be3b0478e7b06b9f7de7b65bd57927b28b5f7de7bedbdb7da7beebdf7de7b03a947107b06b9f7de7bc1a8278a7ac4acf7de7b03b5370c7be5b0f7de7baabd975e7beabdf7de7b86bd87987b8abdf7de7b24b557927b28bdf7de7b86bd57d27b68bdf7de7beabd97de7becbdf7de7b2034641500900000a0a2288aa2280a101ab20a00c800001040511cc5711cc9911cc9b11c0b080d590500000100080000a0488aa4588ee5588e255992255992254992a579a6ebbaaeebbaaeebba2e101ab20a00480000505114c5701407080d59050064000008a0488aa5688aa7888aa9a88e0a8486ac0200800000040000105c43544cc7955ccb355dd5755dd7755d55555555555555555555555515080d59050040000010d06986a906883023990542435601000800000011c830c580d0905500004000008014494e92283929a594c320594c924a3929a59447317954938c4129a594524a29a594524a29a594c220598e924a3929a594c428598c922a3529a59447397952938c3d29a594524a29a594524a29a594052979d292ae4129a594e42869d0924d3d29a5942845899293ed4929a594524a29a594524a29a5940f4af92094524a29a594ab3db9d693524a29a594314a099f94524a29a594524a29a594524a29a58c20346415000004000018678d72283a89ce176728679a82a4426942f726394a9e93dc4acbcde9269c73ba39e59c4fce3927080d590500000200400821851452482185145248218518628821879c720a2aa8a0924a2aaaa8a2ca2acb2cb3cc32cb2cb3cc32cb2cb3ce3aeaa8b390422829b4d05a8db1c6185bedcd495b7394d24929a594524ae99c73ce094243560100200000044206196490514621851862ca29a79c824a2aa980d0905500002000800000000051321dd3111d51111dd1111dd1111dd1f11ccff12451122dcf1235d33345d3345d55766559976dd9767559b775d9b77d5bb76ddbd78dddf88de3388ee3388ee3388ee3388ee338862034641500000200002084104248218514524829a618730e3a08219412080d59050000020008000000501447711cc9912449b224cbd22c4dd3344df3444ff44c4ff55c51166dd1f65ccf166dcff5544ff554513555d3355dd5755dd7555d555665d7b66ddbb66ddbb66ddbb66ddbb66d5b0642435601001200003a92232992222992e3389223494068c82a004006004000008aa2288ee3488e25599226899269a996abc99eeee9a22eea4068c82a000010004000000000000086688886e88896a889a2288aa2288aa2288aa2288aa2288aa2288aa2288aa2288aa2288aa2288aa2288aa2288aa2288aa2e8799ee7799ee7799e078486ac0200240000742447722cc5522445522cc77280d0905500800c008000001cc3312445722ccbb2344df33ccff3444f144551344dd55481d0905500002000800000000000001445b11ccb9124cdf124d1112551122d51123551134551144551144551144551144551144551144551144551144551144551144551144551144511080d59090090010080d0524aadb558096898729483cb1c6450620eaab10622473db88a29a51ce5a0228814529273cb28638a49ecb1a3d02926adc7103a8414b4da4b0815528e6a2034648500109a01e0701c40d22c40b2340000000000000090340dd03c0fd03c0f00000000000000244d0334cf0334cf0300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0d13440f33c40f33c00000000000000d03c0ff04413f04411000000000000002ccf033cd1033cd10400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0d13440f33c40f33c00000000000000b03c0ff04c11f03c110000000000000034cf033c51043c5304000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000010e00000106021141ab2220088130030380e340d9a064d03389605cf83e74114018e65c113e17910450000000000000000000034cf836a4255a1aa00cdf360aa5055a82a000000000000000000009ae74155a1aa505580e6795055a82a5415000000000000000000004d14a1ba505db82a401345b82a5415aa0a00000000000000000000000000000000000000000000080000187000000830a10c141ab2220088130070388a65010080e338960500008e23591600005896a5690000605996a60100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000187000000830a10c141ab2120088020030288a6501cbb22c605996052c4bd3009a06d03c80a6014411000800002870000008b0415362718042435602005100000645b12ccbf23c9aa6699e278a344dd33c4f14699aa7799e69c2f33ccf34e179a2689af03c51344d98a628aa2a10455515000050e00000106083a6c4e2008586ac04004202000c8e63599ae6799e278aa6a9aa344dd33c4f1445d1344d5355699aa6799e288aa2699aa6aad2344df33c511445d354555585a6799e288aa269aaaaebc2f344511445d13455d575e179a2288aa268aaaaeaba104551344dd35455d5755d208aa6699aaaeabaae0b4451144d53555dd77581288aa269aaaaebba32304dd3345555755d590698a669aaaaebca32405555d5755d579601aaaaaaaeeabab20c505555755dd9b56500aaeabaae2cdb0200000e1c0000028ca0938c2a8bb0d1840b0f40a1212b0280280000c018a51453ca302621941022c62484124225a194924aa920945252081584524a0a2193924a49a954104a08a9940a42092595520000d8810300d881855068c84a00200f0080304629c618634c2aa514638e390795528a31c618938c31c69873ce49089562cc39e7a4948c39e79c73524ac69c73ce3929a573ce39e79c945242e79c734e4a09a573ce3927a594d039e79c13000054e000001060a3c8e60423418586ac04005201000c8e63599ae679a2689a9624699ae7899e289aa626499ae6799e688aaacaf33c4f1445d1345595e7799e288aa669aa2ad71545d3344d55755db22b8aa6689aaaaaba304dd3545555755d98a628aaaaebba3264d93455d5756519b66d9aaaeabab20c5c57755dd79681ebbaaeebdab20000f0040700a0021b564738291a0b2c34642500900100401863904208218510420a2184945208090000187000000830a10c141ab212004805000090911242082184103106218410420821820a42082184104208218410420821841042082184104208218410420821841042082184104208218410420821841042082184104208218410420821841042082184104208218410420821841042082184104208218410420805002e553800e83ed8b03ac249d15860a1212b0180540000c018a5188390526b15428c3927a5a5182b8418730e424a2df68c3907a194187bed19730e422931e6d84be99c94945acbb5a7d4392929b55663efbda4525aab31c6de7b0925c316638cbdf79a536a2dc65c7befbda6d0428eb1f6de7b8fb1b59a7bee3df71e5b4b39d65c00006683030044820dab239c148d05161ab212000809002010528a31c69c73ce390825638c31e69c73104208a1648c31c69c730e420821948c31e69c731042082184524ac69c830e420821845052e99c731042082184104a2999730e42082184104249a9730e42082184104228a594d23908218410422829955442082184104208a194924a082184104209a59452520a21841042282184544a2a2585504a08a584504a4925951242092184104a292595124a08219410422925a5524a09a184104a28a59454522a21841042280500001c3800000418412719551661a309171e80424356020064000010b2924a2929460022c79cc4d842479983147388ac824e5aae2d530e29262d96cc31a518b4563a0899524c520925854e2947a5c59c4ac71ca5d87b8d298412000000410080809000000304053300c0e000e17310740204471b00802044668844c3427078500910115301406282422e0054585ca45d5c4097012ee8e2ae0321042108412c0ea080041c9c70c3136f78c20d4ed0292a752000000000000b00f00000905c001111d1cc6164686c7074787c8084888c9008000000000016007c00002425404444347318191a1b1c1d1e1f20212223240100800002000000002080000404040000000000020000000404", 54 | "codec_private_length": 3874, 55 | "default_track": true, 56 | "enabled_track": true, 57 | "forced_track": false, 58 | "language": "und", 59 | "minimum_timestamp": 0, 60 | "number": 2, 61 | "uid": 3212545613 62 | }, 63 | "type": "audio" 64 | }, 65 | { 66 | "codec": "SubRip/SRT", 67 | "id": 2, 68 | "properties": { 69 | "codec_id": "S_TEXT/UTF8", 70 | "codec_private_length": 0, 71 | "default_track": true, 72 | "enabled_track": true, 73 | "encoding": "UTF-8", 74 | "forced_track": false, 75 | "language": "und", 76 | "minimum_timestamp": 4700000000, 77 | "number": 3, 78 | "text_subtitles": true, 79 | "uid": 2706199548 80 | }, 81 | "type": "subtitles" 82 | }, 83 | { 84 | "codec": "SubRip/SRT", 85 | "id": 3, 86 | "properties": { 87 | "codec_id": "S_TEXT/UTF8", 88 | "codec_private_length": 0, 89 | "default_track": false, 90 | "enabled_track": true, 91 | "encoding": "UTF-8", 92 | "forced_track": false, 93 | "language": "und", 94 | "minimum_timestamp": 4700000000, 95 | "number": 4, 96 | "text_subtitles": true, 97 | "uid": 3529758976 98 | }, 99 | "type": "subtitles" 100 | } 101 | ], 102 | "warnings": [] 103 | } 104 | -------------------------------------------------------------------------------- /.github/workflows/BuildImage.yml: -------------------------------------------------------------------------------- 1 | name: Build Image 2 | 3 | on: [push, workflow_dispatch] 4 | 5 | env: 6 | ENDPOINT: "thecaptain989/radarr-striptracks" 7 | 8 | jobs: 9 | unit_test: 10 | name: Unit Test Job 11 | runs-on: ubuntu-latest 12 | defaults: 13 | run: 14 | shell: bash -e {0} 15 | container: 16 | image: linuxserver/radarr:latest 17 | options: --user root 18 | env: 19 | TZ: America/Chicago 20 | 21 | steps: 22 | - name: Checkout code 23 | uses: actions/checkout@v4 24 | 25 | - name: Start Radarr 26 | run: | 27 | # Start Radarr in the background 28 | /app/radarr/bin/Radarr -nobrowser -data=/config & 29 | sleep 1 # Wait for Radarr to start 30 | 31 | - name: Create temp directory 32 | run: | 33 | # Not sure why this is needed in a runner container, but it is 34 | mkdir -p $TMPDIR 35 | 36 | - name: Install dependencies 37 | run: | 38 | apk add --no-cache mkvtoolnix 39 | 40 | - name: Unit testing with bash_unit 41 | run: | 42 | curl -s https://raw.githubusercontent.com/bash-unit/bash_unit/main/install.sh | bash 43 | FORCE_COLOR=true ./bash_unit .github/tests/test_* 44 | 45 | - name: Print GitHub summary 46 | run: echo "All Unit Tests PASSED" >> $GITHUB_STEP_SUMMARY 47 | 48 | lint: 49 | name: Lint Job 50 | needs: unit_test 51 | runs-on: ubuntu-latest 52 | permissions: 53 | contents: read 54 | packages: read 55 | statuses: write 56 | steps: 57 | - name: Checkout code 58 | uses: actions/checkout@v4 59 | with: 60 | # Full git history is needed to get a proper list of changed files within `super-linter` 61 | fetch-depth: 0 62 | 63 | - name: Lint Code Base 64 | uses: super-linter/super-linter@v7 65 | env: 66 | VALIDATE_BASH: true 67 | BASH_SEVERITY: style 68 | BASH_FILE_NAME: .shellcheckrc 69 | # Adding this here for now becaue the config file does not work 70 | # SHELLCHECK_OPTS: '--exclude SC1090,SC1091,SC2086,SC2155,SC2166' 71 | VALIDATE_BASH_EXEC: true 72 | VALIDATE_DOCKERFILE_HADOLINT: true 73 | VALIDATE_GITLEAKS: true 74 | VALIDATE_MARKDOWN: true 75 | VALIDATE_NATURAL_LANGUAGE: true 76 | VALIDATE_POWERSHELL: true 77 | CREATE_LOG_FILE: true 78 | SUPPRESS_POSSUM: false 79 | VALIDATE_ALL_CODEBASE: true 80 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 81 | 82 | build: 83 | name: Build Job 84 | needs: lint 85 | runs-on: ubuntu-latest 86 | steps: 87 | - name: Checkout code 88 | uses: actions/checkout@v4 89 | with: 90 | fetch-depth: 0 # Needed for semantic_version to work correctly 91 | 92 | - name: Incrementing version 93 | id: semantic_version 94 | uses: paulhatch/semantic-version@v5.4.0 95 | with: 96 | search_commit_body: true 97 | 98 | - name: Set Vars 99 | run: | 100 | echo "ENDPOINT=${ENDPOINT}" >> $GITHUB_STEP_SUMMARY 101 | # **** If the mod needs to be versioned, set the versioning logic below. Otherwise leave as is. **** 102 | MOD_VERSION="${{ steps.semantic_version.outputs.version }}+${GITHUB_SHA:0:7}" 103 | echo "MOD_VERSION=${MOD_VERSION}" >> $GITHUB_ENV 104 | echo "MOD_VERSION=${MOD_VERSION}" >> $GITHUB_STEP_SUMMARY 105 | 106 | - name: Build image 107 | run: | 108 | docker buildx build --no-cache --build-arg MOD_VERSION="${MOD_VERSION}" --tag ${ENDPOINT}:${{ github.sha }} . 109 | 110 | - name: Tag image 111 | run: | 112 | if [[ "${{ github.ref_name }}" == 'master' ]]; then 113 | IMAGETAG=${ENDPOINT}:latest 114 | else 115 | IMAGETAG="${ENDPOINT}:${{ github.ref_name }}" 116 | fi 117 | IMAGEVERTAG="${ENDPOINT}:${{ steps.semantic_version.outputs.version_tag }}" 118 | echo "IMAGETAG=${IMAGETAG}" >> $GITHUB_ENV 119 | echo "IMAGEVERTAG=${IMAGEVERTAG}" >> $GITHUB_ENV 120 | docker tag ${ENDPOINT}:${{ github.sha }} "${IMAGETAG}" 121 | docker tag ${ENDPOINT}:${{ github.sha }} "${IMAGEVERTAG}" 122 | docker tag ${ENDPOINT}:${{ github.sha }} ghcr.io/${ENDPOINT}:${{ github.sha }} 123 | docker tag ${ENDPOINT}:${{ github.sha }} ghcr.io/"${IMAGEVERTAG}" 124 | docker tag ${ENDPOINT}:${{ github.sha }} ghcr.io/"${IMAGETAG}" 125 | 126 | - name: Credential check 127 | run: | 128 | echo "CR_USER=${{ vars.CR_USER }}" >> $GITHUB_ENV 129 | echo "CR_PAT=${{ secrets.CR_PAT }}" >> $GITHUB_ENV 130 | echo "DOCKERUSER=${{ vars.DOCKERUSER }}" >> $GITHUB_ENV 131 | echo "DOCKERPASS=${{ secrets.DOCKERPASS }}" >> $GITHUB_ENV 132 | if [[ "${{ vars.CR_USER }}" == "" && "${{ secrets.CR_PAT }}" == "" && "${{ vars.DOCKERUSER }}" == "" && "${{ secrets.DOCKERPASS }}" == "" ]]; then 133 | echo "::error::Push credential secrets missing." 134 | echo "::error::You must set either CR_USER & CR_PAT or DOCKERUSER & DOCKERPASS as secrets in your repo settings." 135 | echo "::error::See https://github.com/linuxserver/docker-mods/blob/master/README.md for more information/instructions." 136 | exit 1 137 | fi 138 | 139 | - name: Login to GitHub Container Registry 140 | if: ${{ env.CR_USER && env.CR_PAT }} 141 | run: | 142 | echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ vars.CR_USER }} --password-stdin 143 | 144 | - name: Push tags to GitHub Container Registry 145 | if: ${{ env.CR_USER && env.CR_PAT }} 146 | run: | 147 | docker push ghcr.io/${ENDPOINT}:${{ github.sha }} 148 | docker push ghcr.io/"${IMAGETAG}" 149 | docker push ghcr.io/"${IMAGEVERTAG}" 150 | echo "Pushed the following images/tags to GHCR:" >> $GITHUB_STEP_SUMMARY 151 | echo "ghcr.io/${ENDPOINT}:${{ github.sha }}" >> $GITHUB_STEP_SUMMARY 152 | echo "ghcr.io/${IMAGETAG}" >> $GITHUB_STEP_SUMMARY 153 | echo "ghcr.io/${IMAGEVERTAG}" >> $GITHUB_STEP_SUMMARY 154 | 155 | - name: Login to DockerHub 156 | if: ${{ env.DOCKERUSER && env.DOCKERPASS }} 157 | run: | 158 | echo "${{ secrets.DOCKERPASS }}" | docker login -u "${{ vars.DOCKERUSER }}" --password-stdin 159 | 160 | - name: Push tags to DockerHub 161 | if: ${{ env.DOCKERUSER && env.DOCKERPASS }} 162 | run: | 163 | docker push ${ENDPOINT}:${{ github.sha }} 164 | docker push "${IMAGEVERTAG}" 165 | docker push "${IMAGETAG}" 166 | echo "Pushed the following images/tags to Docker Hub:" >> $GITHUB_STEP_SUMMARY 167 | echo "${ENDPOINT}:${{ github.sha }}" >> $GITHUB_STEP_SUMMARY 168 | echo "${IMAGETAG}" >> $GITHUB_STEP_SUMMARY 169 | echo "${IMAGEVERTAG}" >> $GITHUB_STEP_SUMMARY 170 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | 45 | # Miscellaneous 46 | bash_unit 47 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1 2 | 3 | ## Buildstage ## 4 | FROM ghcr.io/linuxserver/baseimage-alpine:3.20 AS buildstage 5 | ARG MOD_VERSION 6 | 7 | # copy local files 8 | COPY root/ /root-layer/ 9 | 10 | # Add version to script 11 | RUN \ 12 | MOD_VERSION="${MOD_VERSION:-unknown}" && \ 13 | sed -i -e "s/{{VERSION}}/$MOD_VERSION/" \ 14 | /root-layer/usr/local/bin/striptracks.sh \ 15 | /root-layer/etc/s6-overlay/s6-rc.d/init-mod-radarr-striptracks-add-package/run 16 | 17 | ## Single layer deployed image ## 18 | FROM scratch 19 | ARG MOD_VERSION 20 | 21 | LABEL org.opencontainers.image.title=radarr-striptracks 22 | LABEL org.opencontainers.image.description="A Docker Mod to Radarr/Sonarr to automatically strip out unwanted audio and subtitle streams" 23 | LABEL org.opencontainers.image.version="${MOD_VERSION}" 24 | LABEL org.opencontainers.image.source="https://github.com/TheCaptain989/radarr-striptracks" 25 | LABEL org.opencontainers.image.authors="TheCaptain989 " 26 | LABEL org.opencontainers.image.licenses=GPL-3.0-only 27 | 28 | # Add files from buildstage 29 | COPY --from=buildstage /root-layer/ / 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Development Repository 2 | This is a development and test repository. Visit the [production repository and branch](https://github.com/linuxserver/docker-mods/tree/radarr-striptracks) for stable/production releases. 3 | 4 | # About 5 | 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. A [Batch Mode](#batch-mode) is also supported that allows usage outside of Radarr/Sonarr. 6 | 7 | **This unified script works in both Radarr and Sonarr. Use this mod in either container!** 8 | 9 | > [!NOTE] 10 | > This mod supports Linux OSes only. 11 | 12 | 13 | Production Container info: [![Docker Image Size](https://img.shields.io/docker/image-size/linuxserver/mods/radarr-striptracks)](https://hub.docker.com/r/linuxserver/mods/tags?name=radarr-striptracks "Docker image size") 14 | [![linuxserver/docker-mods/mods/radarr-striptracks](https://img.shields.io/badge/dynamic/json?logo=github&url=https%3A%2F%2Fthecaptain989.github.io%2Fghcr-pulls%2Fradarr-striptracks.json&query=%24.pulls&label=ghcr%20pulls&color=1572A4)](https://github.com/linuxserver/docker-mods/pkgs/container/mods "GitHub package pulls") 15 | Development Container info: 16 | [![Docker Image Size](https://img.shields.io/docker/image-size/thecaptain989/radarr-striptracks)](https://hub.docker.com/r/thecaptain989/radarr-striptracks "Docker image size") 17 | [![Docker Pulls](https://img.shields.io/docker/pulls/thecaptain989/radarr-striptracks?logo=docker)](https://hub.docker.com/r/thecaptain989/radarr-striptracks "Docker container pulls") 18 | [![Build Image](https://github.com/TheCaptain989/radarr-striptracks/actions/workflows/BuildImage.yml/badge.svg)](https://github.com/TheCaptain989/radarr-striptracks/actions/workflows/BuildImage.yml "BuildImage job") 19 | 20 | 21 | ## Features Only Available In This Repository 22 | The following features are only available from this repository. These are either not related to Linuxserver.io's images or not related to Docker at all, so they are not published as part of the official Linuxserver.io Docker Mod package. 23 | 24 | - Works in [hotio](https://hotio.dev/) containers. See the [hotio](hotio) directory for more details. 25 | - Works in Windows by using [WSL](https://learn.microsoft.com/en-us/windows/wsl/). See the the [wsl](wsl) directory for more details. 26 | 27 | # Installation 28 | 1. Configure your selected Docker container with all the port, volume, and environment settings from the *original container documentation* here: 29 | **[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")** 30 | 1. Add the **DOCKER_MODS** environment variable to your `compose.yml` file or `docker run` command, as follows: 31 | - Stable/Production release: `DOCKER_MODS=linuxserver/mods:radarr-striptracks` 32 | - Dev/test release: `DOCKER_MODS=thecaptain989/radarr-striptracks:latest` 33 | 34 | *Example Docker Compose YAML Configuration* 35 | 36 | ```yaml 37 | version: "2.1" 38 | services: 39 | radarr: 40 | image: lscr.io/linuxserver/radarr 41 | container_name: radarr 42 | environment: 43 | - PUID=1000 44 | - PGID=1000 45 | - TZ=America/Chicago 46 | - DOCKER_MODS=linuxserver/mods:radarr-striptracks 47 | volumes: 48 | - /path/to/data:/config 49 | - /path/to/movies:/movies 50 | - /path/to/downloadclient-downloads:/downloads 51 | ports: 52 | - 7878:7878 53 | restart: unless-stopped 54 | ``` 55 | 56 |
57 | Example Docker Run Command 58 | 59 | ```shell 60 | docker run -d \ 61 | --name=radarr \ 62 | -e PUID=1000 \ 63 | -e PGID=1000 \ 64 | -e TZ=America/Chicago \ 65 | -e DOCKER_MODS=linuxserver/mods:radarr-striptracks \ 66 | -p 7878:7878 \ 67 | -v /path/to/data:/config \ 68 | -v /path/to/movies:/movies \ 69 | -v /path/to/downloadclient-downloads:/downloads \ 70 | --restart unless-stopped \ 71 | lscr.io/linuxserver/radarr 72 | ``` 73 | 74 |
75 |
76 | Synology Screenshot 77 | 78 | *Example Synology Configuration* 79 | ![striptracks](.assets/striptracks-synology.png "Synology container settings") 80 | 81 |
82 | 83 | 2. Start the container. 84 | 85 | 2. Configure a custom script from Radarr's or Sonarr's *Settings* > *Connect* screen and type the following in the **Path** field: 86 | `/usr/local/bin/striptracks.sh` 87 | 88 |
89 | Screenshot 90 | 91 | *Example Custom Script* 92 | ![striptracks custom script](.assets/striptracks-v3-custom-script.png "Radarr/Sonarr custom script settings") 93 | 94 |
95 | 96 | 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. 97 | Alternatively, a wrapper script or an environment variable may be used to more granularly define which tracks to keep. See [Wrapper Scripts](#wrapper-scripts) or [Environment Variable](#environment-variable) for more details. 98 | 99 | > [!IMPORTANT] 100 | > 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. 101 | 102 | ## Radarr Configuration Example 103 | The following is a simplified example and steps to configure Radarr so the script will keep Original and English languages of an imported movie. 104 | 105 | 1. Create a new *Custom Format* called "***My Languages***": 106 | 107 |
108 | Screenshot 109 | 110 | *New Custom Format Example* 111 | ![add custom format](.assets/add-custom-format.png "New Custom Format") 112 | 113 |
114 | 115 | 2. Add two *Language Conditions* to the format, one for English, and one for Original: 116 | 117 |
118 | Screenshots 119 | 120 | *New Language Conditions Example* 121 | ![add language](.assets/add-language-condition.png "Add Language Condition") 122 | 123 | *Custom Format Conditions Example* 124 | ![custom format](.assets/custom-format-conditions.png "Multiple Language Conditions") 125 | 126 |
127 | 128 | 3. Edit the 'Any' Quality Profile, changing the Language to "***Any***" and the *Score* to "***10***": 129 | 130 |
131 | Screenshot 132 | 133 | *Radarr Quality Profile Example* 134 | ![quality profile](.assets/radarr-quality-profile.png "Radarr Quality Profile Language scoring") 135 | 136 |
137 | 138 | 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. 139 | See [Automatic Language Detection](#automatic-language-detection) for more details. 140 | 141 | # Usage Details 142 | 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. 143 | Chapters, if they exist, are preserved. The Title attribute in the MKV is set to the movie title plus year 144 | (ex: `The Sting (1973)`) or the series title plus episode information (ex: `Happy! 01x01 - What Smiles Are For`). 145 | 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.) 146 | 147 | If the resulting video file would contain the same tracks as the original, and it's already an MKV, the remux step is skipped. 148 | 149 | > [!TIP] 150 | > If you've configured the Radarr/Sonarr **Recycle Bin** path correctly, the original video will be moved there unless disabled with the `--disable-recycle` option. 151 | 152 | > [!CAUTION] 153 | > If you have ***not*** configured the Recycle Bin, the original video file will be deleted/overwritten and permanently lost. 154 | 155 | ## Automatic Language Detection 156 | When the script is called with no arguments, it will attempt to detect the language(s) configured within Radarr/Sonarr on the particular movie or TV show. 157 | Language selection(s) may be configured in: 158 | - ***Custom Formats*** (in Radarr v3 and higher and Sonarr v4 and higher), 159 | - ***Quality Profiles*** (only in Radarr), or 160 | - ***Language Profiles*** (Sonarr v3) 161 | 162 | Both audio **and** subtitle tracks that match the configured language(s) are kept. 163 | 164 | > [!TIP] 165 | > 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. 166 | 167 | ### Special Language Selections 168 | 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. 169 | Selecting this language is functionally equivalent to calling the script with `--audio :org --subs :org` command-line arguments. See [Original language code](#original-language-code) below for more details. 170 | 171 | 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. 172 | See [Unknown language code](#unknown-language-code) below for more details. 173 | 174 | The language selection **'Any'** has two purposes: 175 | 1) In Radarr only, when set on a Quality Profile, it will trigger a search of languages in ***Custom Formats*** 176 | 2) If languages are not configured in a Custom Format, or if you're using Sonarr, 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. 177 | See [Any language code](#any-language-code) below for more details. 178 | 179 | > [!IMPORTANT] 180 | > When using *Custom Formats* language conditions and scoring you may not get the results you expect. 181 | > This can be non-intuitive configuration, especially when using negative scoring, the 'Negate' option, and the 'Except Language' option. 182 | > The script does not care what custom format is *applied* by Radarr/Sonarr on the video file, only what the custom format conditions are and the *scores* are in the corresponding *Quality Profile*. 183 | > 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. 184 | 185 | ### Language Detection Precedence 186 | 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. 187 | 188 | ```mermaid 189 | graph LR 190 | A[Command-Line] 191 | B["Environment 192 | Variable"] 193 | C["Quality 194 | Profile"] 195 | D["Custom 196 | Formats"] 197 | E["Language Profile 198 | (Sonarr only)"] 199 | A-->B 200 | B-->C 201 | C-- 'Any' -->D 202 | D-->E 203 | ``` 204 | 205 | Descriptively, these steps are: 206 | 1. Command-line arguments override all automatic language selection. 207 | 2. Environment variable is checked for arguments. 208 | 3. If there are no command-line or environment variable arguments, the video's *Quality Profile* is examined for a language configuration (only supported in Radarr). 209 | 4. 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. 210 | All language conditions with positive scores *and* Negated conditions with negative scores *and* non-Negated Except Language conditions with negative scores are selected. 211 | 5. 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) 212 | 213 | > [!NOTE] 214 | > For step 4 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"). 215 | 216 | ## Command-Line Syntax 217 | 218 | ### Options and Arguments 219 | 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). 220 | 221 | The syntax for the command-line is: 222 | `striptracks.sh [{-a|--audio} [{-s|--subs} ] [{-f|--file} ]] [--reorder] [--disable-recycle] [{-l|--log} ] [{-c|--config} ] [{-d|--debug} []]` 223 | 224 |
225 | Table of Command-Line Arguments 226 | 227 | Option|Argument|Description 228 | ---|---|--- 229 | `-a`, `--audio`|``|Audio languages to keep
ISO 639-2 code(s) prefixed with a colon (`:`)
Each code may optionally be followed by a plus (`+`) and one or more [modifiers](#language-code-modifiers). 230 | `-s`, `--subs`|``|Subtitle languages to keep
ISO 639-2 code(s) prefixed with a colon (`:`)
Each code may optionally be followed by a plus (`+`) and one or more modifiers. 231 | `-f`, `--file`|``|If included, the script enters **[Batch Mode](#batch-mode)** and converts the specified video file.
Requires the `--audio` option.
![notes] **Do not** use this argument when called from Radarr or Sonarr! 232 | `--reorder`| |Reorder audio and subtitles tracks to match the language code order specified in the `` and `` arguments. 233 | `--disable-recycle`| |Disable recycle bin use, even if configured in Radarr/Sonarr 234 | `-l`, `--log`|``|The log filename
Default is `/config/log/striptracks.txt` 235 | `-c`, `--config`|``|Radarr/Sonarr XML configuration file
Default is `/config/config.xml` 236 | `-d`, `--debug`|`[]`|Enables debug logging. Level is optional.
Default is `1` (low)
`2` includes JSON output
`3` contains even more JSON output 237 | `--help`| |Display help and exit. 238 | `--version`| |Display version and exit. 239 | 240 |
241 | 242 | The `` and `` arguments 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. 243 | For example: 244 | 245 | * `:eng` 246 | * `:fre` 247 | * `:spa` 248 | 249 | ...etc. 250 | 251 | Multiple codes may be concatenated, such as `:eng:spa` for both English and Spanish. Order is unimportant, unless the `--reorder` option is specified. 252 | 253 | > [!WARNING] 254 | > If no subtitle language is detected via Radarr/Sonarr configuration or specified on the command-line, all subtitles are removed. 255 | 256 | ### Language Code Modifiers 257 | Each language code can optionally be followed by a plus (`+`) and one or more modifier characters. Supported modifiers are: 258 | 259 | Modifier|Function 260 | ---|--- 261 | `f`|Selects only tracks with the forced flag set 262 | `d`|Selects only tracks with the default flag set 263 | `[0-9]`|Specifies the maximum number of tracks to select.
Based on the order of the tracks in the original source video. 264 | 265 | These modifiers must be applied to each language code you want to modify. They may be used with either audio or subtitles codes. 266 | For example, the following options, `--audio :org:any+d --subs :eng+1:any+f` would keep: 267 | - All original language audio tracks, and all Default audio tracks regardless of language 268 | - One English language subtitles track, and all Forced subtitles tracks regardless of language 269 | 270 | Modifiers may be combined, such as `:any+fd` to keep all forced and all default tracks, or `:eng+1d` to keep one default English track. 271 | 272 | > [!NOTE] 273 | > Note the exact phrasing of the previous sentence. There is nuance here that is not obvious. 274 | > `:any+fd` is equivalent to `:any+f:any+d`, but `:eng+1d` is **not** the same as `:eng+1:eng+d`. 275 | 276 | ### Any language code 277 | 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. 278 | 279 | ### Original language code 280 | The `:org` language code is a special code. When used, instead of retaining a specific language, the script substitutes the original movie or TV show language as specified in its [The Movie Database](https://www.themoviedb.org/ "TMDB") or [The TVDB](https://www.thetvdb.com/ "TVDB") entry. 281 | As an example, when importing "*Amores Perros (2000)*" with options `--audio :org:eng`, the Spanish and English audio tracks are preserved. 282 | Several [Included Wrapper Scripts](#included-wrapper-scripts) use this special code. 283 | 284 | > [!NOTE] 285 | > This feature relies on the 'originalLanguage' field in the Radarr/Sonarr database. The `:org` code is therefore invalid when used in Batch Mode. 286 | > The script will log a warning if it detects the use of `:org` in an invalid way, though it will continue to execute. 287 | 288 | ### Unknown language code 289 | 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. 290 | > [!TIP] 291 | > 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. 292 | 293 | ### Reorder Option 294 | 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. 295 | 296 |
297 | Reorder Example 298 | 299 | For example, given a source video (w/original language of English) that has the following track order: 300 | 301 | > Track ID:0 Type:video Name:null Lang:und Codec:AVC/H.264/MPEG-4p10 Default:true Forced:false 302 | > Track ID:1 Type:audio Name:French Lang:fre Codec:E-AC-3 Default:true Forced:false 303 | > Track ID:2 Type:audio Name:German Lang:deu Codec:AC-3 Default:false Forced:false 304 | > Track ID:3 Type:audio Name:English Lang:eng Codec:AC-3 Default:false Forced:false 305 | > Track ID:4 Type:subtitles Name:French Lang:fre Codec:SubRip/SRT Default:false Forced:false 306 | > Track ID:5 Type:subtitles Name:English Lang:eng Codec:SubRip/SRT Default:false Forced:false 307 | 308 | And using the command line: 309 | 310 | ```shell 311 | /usr/local/bin/striptracks.sh --audio :org+1:eng+1:fre+1:und+1 --subs :eng+1:fre+1:spa+1 --reorder 312 | ``` 313 | 314 | Will create an MKV file with tracks: 315 | 316 | > Track ID:0 Type:video Name:null Lang:und Codec:AVC/H.264/MPEG-4p10 Default:true Forced:false 317 | > Track ID:1 Type:audio Name:English Lang:eng Codec:AC-3 Default:false Forced:false 318 | > Track ID:2 Type:audio Name:French Lang:fre Codec:E-AC-3 Default:true Forced:false 319 | > Track ID:3 Type:subtitles Name:English Lang:eng Codec:SubRip/SRT Default:false Forced:false 320 | > Track ID:4 Type:subtitles Name:French Lang:fre Codec:SubRip/SRT Default:false Forced:false 321 | 322 |
323 | 324 | ## Special Handling of Audio 325 | 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. 326 | 327 | Additionally, two ISO 639-2 language codes are handled specially: the "*Uncoded languages*" code of `mis` and the "*No linguistic content*" code of `zxx`. 328 | Tracks with either of these codes are always retained as they are often used for instrumental tracks in silent films. 329 | There is no way to force the script to remove audio tracks with these codes. 330 | 331 | ## Examples 332 | 333 |
334 | Command-line Examples 335 | 336 | ```shell 337 | -d 2 # Enable debugging level 2, audio and subtitles 338 | # languages detected from Radarr/Sonarr 339 | -a :eng:und -s :eng # Keep English and Unknown audio, and English subtitles 340 | -a :org:eng -s :any+f:eng # Keep English and Original audio, and all forced or English subtitles 341 | -a :eng -s "" # Keep English audio and remove all subtitles 342 | -a :any -s "" # Keep all audio and remove all subtitles 343 | -d -a :eng:kor:jpn -s :eng:spa # Enable debugging level 1, keeping English, Korean, and Japanese audio, 344 | # and English and Spanish subtitles 345 | -f "/movies/Finding Nemo (2003).mkv" -a :eng:und -s :eng 346 | # Batch Mode 347 | # Keep English and Unknown audio and English subtitles, converting 348 | # video specified 349 | --audio :org:any+d1 --subs :eng+1:any+f2 350 | # Keep Original audio and one default audio track regardless of language 351 | # (first audio track flagged as Default as it appears in the source file), 352 | # one English subtitles track and two forced subtitles regardless of 353 | # language (as they appear in the source file) 354 | ``` 355 | 356 |
357 | 358 | ## Wrapper Scripts 359 | 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](#environment-variable). 360 | 361 | > [!TIP] 362 | > If you followed the Linuxserver.io recommendations when configuring your container, the `/config` directory will be mapped to an external storage location. 363 | > 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. 364 | 365 | ### Included Wrapper Scripts 366 | For your convenience, several wrapper scripts are included in the `/usr/local/bin/` directory. 367 | You may use any of these in place of `striptracks.sh` mentioned in the [Installation](#installation) section above. 368 | 369 |
370 | List of scripts 371 | 372 | ```shell 373 | striptracks-debug.sh # Use detected languages, but enable debug logging 374 | striptracks-debug-2.sh # Use detected languages, enable debug logging level 2 375 | striptracks-debug-max.sh # Use detected languages, enable highest debug logging 376 | striptracks-dut.sh # Keep Dutch and Unknown audio, and Dutch subtitles 377 | striptracks-eng.sh # Keep English and Unknown audio, and English subtitles 378 | striptracks-eng-debug.sh # Keep English and Unknown audio, and English subtitles, and enable debug logging 379 | striptracks-eng-fre.sh # Keep English, French, and Unknown audio, and English and French subtitles 380 | striptracks-eng-jpn.sh # Keep English, Japanese, and Unknown audio and English subtitles 381 | striptracks-fre.sh # Keep French and Unknown audio, and French subtitles 382 | striptracks-ger.sh # Keep German and Unknown audio, and German subtitles 383 | striptracks-spa.sh # Keep Spanish and Unknown audio, and Spanish subtitles 384 | striptracks-org-eng.sh # Keep Original, English, Unknown, and forced audio, and Original, English, and forced subtitles 385 | striptracks-org-ger.sh # Keep Original, German, and Unknown audio, and Original and German subtitles 386 | striptracks-org-spa.sh # Keep Original, Spanish, and Unknown audio, and Original and Spanish subtitles 387 | ``` 388 | 389 |
390 | 391 | ### Example Wrapper Script 392 |
393 | Example Script 394 | 395 | To configure an entry from the [Examples](#examples) section above, create and save a file called `striptracks-custom.sh` to `/config` containing the following text: 396 | 397 | ```shell 398 | #!/bin/bash 399 | 400 | . /usr/local/bin/striptracks.sh -d -a :eng:kor:jpn -s :eng:spa 401 | ``` 402 | 403 | Make it executable: 404 | 405 | ```shell 406 | chmod +x /config/striptracks-custom.sh 407 | ``` 408 | 409 | Then put `/config/striptracks-custom.sh` in the **Path** field in place of `/usr/local/bin/striptracks.sh` mentioned in the [Installation](#installation) section above. 410 | 411 |
412 | 413 | ## Environment Variable 414 | The script can also read arguments from the `STRIPTRACKS_ARGS` environment variable. This allows advanced use cases without having to provide a custom wrapper script. 415 | 416 | > [!NOTE] 417 | > The environment variable is *only* used when **no** command-line arguments are present. **Any** command-line argument will disable the use of the environment variable. 418 | 419 |
420 | Example Docker Compose 421 | 422 | For example, the following lines in your `compose.yml` file would keep English, Japanese, and Unknown audio and English subtitles: 423 | 424 | ```yaml 425 | environment: 426 | - STRIPTRACKS_ARGS=--audio :eng:jpn:und --subs :eng 427 | ``` 428 | 429 |
430 |
431 | Example Docker Run Command 432 | 433 | In a `docker run` command, it would be: 434 | 435 | ```shell 436 | -e STRIPTRACKS_ARGS='--audio :eng:jpn:und --subs :eng' 437 | ``` 438 | 439 |
440 | 441 |
442 | Synology Screenshot 443 | 444 | *Example Synology Configuration* 445 | ![synology striptracks_args](.assets/striptracks-synology-2.png "Synology container settings") 446 | 447 |
448 | 449 | ## Triggers 450 | 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. 451 | 452 | ## Batch Mode 453 | 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. 454 | 455 | Using this function, you can easily process all of your video files in any subdirectory at once. See the [Batch Example](#batch-example) below. 456 | 457 | ### Script Execution Differences in Batch Mode 458 | 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: 459 | * *The filename must be specified on the command-line.*
The `-f` option places the script in Batch Mode 460 | * *No audio or subtitles language detection occurs.*
Both the audio and subtitles languages must be specified on the command-line. 461 | * *The `:org` language code is meaningless.*
The original video language cannot be determined. 462 | * *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. 463 | * *Radarr or Sonarr APIs are not called and their database is not updated.*
This may require a manual rescan of converted videos. 464 | * *Original video files are deleted.*
The Recycle Bin function is not available. 465 | 466 | ### Batch Example 467 |
468 | Batch Mode Example 469 | 470 | To keep English and Unknown audio and English subtitles on all video files ending in .MKV, .AVI, or .MP4 in the `/movies` directory, enter the following at the Linux command-line: 471 | 472 | ```shell 473 | 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 474 | ``` 475 | 476 | Here's another example to keep English, Danish, Unknown languages, and all forced subtitles on all video files in your `./videos` directory (requires the `file` program; testable with `file -v`): 477 | 478 | ```shell 479 | 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:any+f; fi; done 480 | ``` 481 | 482 |
483 | 484 | ## Logs 485 | By default, a log file is created for the script activity called: 486 | 487 | `/config/logs/striptracks.txt` 488 | 489 | This log can be inspected or downloaded from Radarr/Sonarr under *System* > *Logs* > *Files*. The log filename can be modified with the `--log` command-line option. 490 | 491 | Script errors will show up in both the script log and the native Radarr/Sonarr log. 492 | 493 | Log rotation is performed with 5 log files of 512KB each being kept. 494 | > [!CAUTION] 495 | > 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.* 496 | 497 | # Limitations 498 | It should be noted that this script's core functionality nulifies some of the benefits of [hardlinks](https://trash-guides.info/hardlinks/). 499 | However, configuring hardlinks is still recommended. 500 | 501 |
502 | Hardlink Limitations 503 | 504 | *Radarr Hardlinks Configuration Screenshot* 505 | ![radarr-enable-hardlinks](.assets/radarr-enable-hardlinks.png "Radarr hardlinks screenshot") 506 | 507 | Hardlinks are essentially multiple references to the *same file*. 508 | The purpose of a hardlink is to: 509 | - Allow instant file moves from the download client to Radarr or Sonarr 510 | - Reduce duplicate storage space 511 | - Allow torrent seeding after download 512 | 513 | Because the script creates a brand-new video file that includes only the selected streams and deletes the original, a hardlink cannot be preserved. 514 | Instant file moves from your download client will continue to work, but the new file will consume additional space, and the original file will be deleted (or unlinked) by 515 | the script which could prevent torrent seeding. 516 | 517 | The script will log a warning if it detects the input video is a hardlink. 518 | 519 | Note that the script does not *always* create a new file. If there are no streams removed, the original video file is not deleted and any hardlinks are preserved. 520 | It is therefore still recommended to enable and use hardlinks in Radarr and Sonarr. 521 | 522 |
523 | 524 | # Uninstall 525 | To completely remove the mod: 526 | 1. Delete the custom script from Radarr's or Sonarr's *Settings* > *Connect* screen that you created in the [Installation](#installation) section above. 527 | 2. Stop and delete the Radarr/Sonarr container. 528 | 3. Remove the **DOCKER_MODS** environment variable from your `compose.yaml` file or exclude it from the `docker run` command when re-creating the Radarr/Sonarr container. 529 | 530 | ___ 531 | 532 | # Credits 533 | 534 | This would not be possible without the following: 535 | 536 | [Radarr](http://radarr.video/ "Radarr homepage") 537 | [Sonarr](http://sonarr.tv/ "Sonarr homepage") 538 | [LinuxServer.io Radarr](https://hub.docker.com/r/linuxserver/radarr "Radarr Docker container") container 539 | [LinuxServer.io Sonarr](https://hub.docker.com/r/linuxserver/sonarr "Sonarr Docker container") container 540 | [LinuxServer.io Docker Mods](https://hub.docker.com/r/linuxserver/mods "Docker Mods containers") project 541 | [MKVToolNix](https://mkvtoolnix.download/ "MKVToolNix homepage") by Moritz Bunkus 542 | Inspired by Endoro's post on [VideoHelp](https://forum.videohelp.com/threads/343271-BULK-remove-non-English-tracks-from-MKV-container#post2292889). 543 | Icons made by [Freepik](https://www.freepik.com) from [Flaticon](https://www.flaticon.com/) 544 | 545 | ## Legacy Change Notes 546 | 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. 547 | Version 2.0 of this mod introduced automatic language detection. 548 | 549 | [notes]: .assets/notes.png "Note" 550 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Only the latest major and minor version are supported. 6 | 7 | | Version | Supported | 8 | | ------- | ------------------ | 9 | | 2.15.x | :heavy_check_mark: | 10 | | < 2.15 | :x: | 11 | 12 | ## Reporting a Vulnerability 13 | 14 | Vulnerability reports or security concerns may be submitted as a new issue in GitHub, or emailed to: 15 | 16 | > 17 | 18 | Please allow 48-hours for an initial response. An issue will be entered if accepted. 19 | -------------------------------------------------------------------------------- /hotio/99-striptracks.sh: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv bash 2 | # shellcheck shell=bash 3 | 4 | # Custom script to install Striptracks Mod meant for Radarr or Sonarr Docker containers 5 | # WARNING: Minimal error handling! 6 | 7 | # Pre-set LSIO Docker Mod variables 8 | DOCKER_MODS=linuxserver/mods:radarr-striptracks 9 | #DOCKER_MODS_DEBUG=true 10 | export DOCKER_MODS 11 | export DOCKER_MODS_DEBUG 12 | [ "$DOCKER_MODS_DEBUG" = "true" ] && echo "[mod-install] DOCKER_MODS: $DOCKER_MODS" && echo "[mod-install] DOCKER_MODS_DEBUG: $DOCKER_MODS_DEBUG" 13 | echo "[mod-install] installing $DOCKER_MODS mod" 14 | 15 | # Steal the current docker-mods version from the source 16 | MODS_VERSION=$(curl -s --fail-with-body "https://raw.githubusercontent.com/linuxserver/docker-baseimage-alpine/master/Dockerfile" | sed -nr 's/^ARG MODS_VERSION="?([^"]+)"?/\1/p') 17 | [ "$DOCKER_MODS_DEBUG" = "true" ] && echo "[mod-install] MODS_VERSION: $MODS_VERSION" 18 | 19 | # Download and execute the main docker-mods script to install the mod 20 | # Very well thought out code, this. Why reinvent? 21 | curl -s --fail-with-body -o /docker-mods "https://raw.githubusercontent.com/linuxserver/docker-mods/mod-scripts/docker-mods.${MODS_VERSION}" 22 | ret=$? 23 | [ $ret -ne 0 ] && echo "[mod-install] unable to download docker-mods: Exit code: $ret. Exiting." && exit 1 24 | 25 | chmod +x /docker-mods 26 | 27 | . /docker-mods 28 | [ $ret -ne 0 ] && echo "[mod-install] docker-mods installation error: $ret. Exiting." && exit 1 29 | 30 | # Get script version from installed mod 31 | VERSION=$(sed -nr 's/^export striptracks_ver="?([^"]+)"?/\1/p' /usr/local/bin/striptracks.sh) 32 | [ "$DOCKER_MODS_DEBUG" = "true" ] && echo "[mod-install] striptracks.sh version: $VERSION" 33 | 34 | # Remaining setup that is normally done with s6-overlay init scripts, but that rely on a lot of Docker Mods dependencies 35 | cat <>> Striptracks Mod by TheCaptain989 <<< 38 | Repos: 39 | Dev/test: https://github.com/TheCaptain989/radarr-striptracks 40 | Prod: https://github.com/linuxserver/docker-mods/tree/radarr-striptracks 41 | 42 | Version: ${VERSION} 43 | ---------------- 44 | EOF 45 | 46 | # Determine if setup is needed 47 | if [ ! -f /usr/bin/mkvmerge ]; then 48 | echo "[mod-install] Running first time setup." 49 | 50 | if [ -f /usr/bin/apt ]; then 51 | # Ubuntu 52 | echo "[mod-install] Installing MKVToolNix using apt-get" 53 | apt-get update && \ 54 | apt-get -y install mkvtoolnix && \ 55 | rm -rf /var/lib/apt/lists/* 56 | elif [ -f /sbin/apk ]; then 57 | # Alpine 58 | echo "[mod-install] Installing MKVToolNix using apk" 59 | apk upgrade --no-cache && \ 60 | apk add --no-cache mkvtoolnix && \ 61 | rm -rf /var/lib/apt/lists/* 62 | else 63 | # Unknown 64 | echo "[mod-install] Unknown package manager. Attempting to install MKVToolNix using apt-get" 65 | apt-get update && \ 66 | apt-get -y install mkvtoolnix && \ 67 | rm -rf /var/lib/apt/lists/* 68 | fi 69 | fi 70 | 71 | # Check ownership and attributes on each script file 72 | [ -z "$PUID" ] && owner_user="root" || owner_user="$PUID" 73 | [ -z "$PGID" ] && owner_group="root" || owner_group="$PGID" 74 | for file in /usr/local/bin/striptracks*.sh 75 | do 76 | # Change ownership 77 | if [ "$(stat -c '%G' "$file")" != "$owner_group" ]; then 78 | echo "[mod-install] Changing ownership on $file script to $owner_user:$owner_group." 79 | chown "$owner_user":"$owner_group" "$file" 80 | fi 81 | 82 | # Make executable 83 | if [ ! -x "$file" ]; then 84 | echo "[mod-install] Making $file script executable." 85 | chmod +x "$file" 86 | fi 87 | done 88 | -------------------------------------------------------------------------------- /hotio/README.md: -------------------------------------------------------------------------------- 1 | # About 2 | This mod can now be used with [hotio](https://hotio.dev/) containers by using the method described in the hotio [FAQ](https://hotio.dev/faq/#:~:text=I%20would%20like%20to%20execute%20my%20own%20scripts%20on%20startup%2C%20how%20would%20I%20do%20this%3F) to install it. 3 | (This method relies on s6-overlay v2 behavior still working, though v3 is the current version.) 4 | 5 | > [!NOTE] 6 | > This is a quick and dirty script with minimal testing or error checking. Note that it only runs *inside* the hotio container and should **not** be executed manually. 7 | 8 | # Installation 9 | 1. Download the **[99-striptracks.sh](99-striptracks.sh)** install script and save it somewhere that can be mounted by your container. 10 | 11 | *Example location:* `/volume1/docker/99-striptracks.sh` 12 | 13 | *Example curl line to download the installation script:* 14 | 15 | ```shell 16 | curl -s https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/master/hotio/99-striptracks.sh >/volume1/docker/99-striptracks.sh 17 | ``` 18 | 19 | 2. Make it executable: 20 | 21 | ```shell 22 | chmod +x /volume1/docker/99-striptracks.sh 23 | ``` 24 | 25 | 3. Configure your selected Docker container with all the port, volume, and environment settings from the *original container documentation* here: 26 | **[hotio/radarr](https://hotio.dev/containers/radarr/ "Radarr Docker container")** OR **[hotio/sonarr](https://hotio.dev/containers/sonarr/ "Sonarr Docker container")** 27 | 28 | > [!IMPORTANT] 29 | > Notice that the DOCKER_MODS environment variable is ***not*** used in this setup. That is a specific feature of LSIO containers and is not applicable to hotio containers. 30 | 31 | 4. Add the **99-striptracks.sh** file path as a mount point in your `compose.yml` file or `docker run` command. 32 | 33 | > [!WARNING] 34 | > The `/etc/cont-init.d/99-striptracks` path in the `volumes` section below is important; don't change it! 35 | 36 | *Example Docker Compose YAML Configuration* 37 | 38 | ```yaml 39 | services: 40 | sonarr: 41 | container_name: sonarr 42 | image: ghcr.io/hotio/sonarr 43 | ports: 44 | - "8989:8989" 45 | environment: 46 | - PUID=1000 47 | - PGID=1000 48 | - UMASK=002 49 | - TZ=Etc/UTC 50 | volumes: 51 | - /:/config 52 | - /:/data 53 | - /volume1/docker/99-striptracks.sh:/etc/cont-init.d/99-striptracks 54 | ``` 55 | 56 |
57 | Example Docker Run Command 58 | 59 | ```shell 60 | docker run --rm \ 61 | --name sonarr \ 62 | -p 8989:8989 \ 63 | -e PUID=1000 \ 64 | -e PGID=1000 \ 65 | -e UMASK=002 \ 66 | -e TZ="Etc/UTC" \ 67 | -v /:/config \ 68 | -v /:/data \ 69 | -v /volume1/docker/99-striptracks.sh:/etc/cont-init.d/99-striptracks \ 70 | ghcr.io/hotio/sonarr 71 | ``` 72 | 73 |
74 |
75 | Synology Screenshot 76 | 77 | *Example Synology Configuration* 78 | ![striptracks hotio](hotio-striptracks-synology.png "Synology container ettings") 79 | 80 |
81 | 82 | > [!CAUTION] 83 | > Please be sure that your mount points for `/config` and `/data` above do not overlap with the newly added mount point! 84 | 85 | 5. Start the container. 86 | 87 | 6. After the container has fully started, continue with Installation step 2 in the main [Readme](../#installation) to configure `striptracks.sh` as a custom script from Radarr's or Sonarr's *Settings* > *Connect* screen. 88 | 89 | # Requirements 90 | You must have the **bash** shell available in your host path. You *might* attempt editing the [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) in the `99-striptracks.sh` script to get around this, but that is beyond the scope of this document. 91 | 92 | # Known Issues 93 | On at least *some* Synology hosts that use the ash shell, this script will cause the container to abort and not start. If this happens, ***check your container logs*** for hints as to what may be wrong. 94 | -------------------------------------------------------------------------------- /hotio/hotio-striptracks-synology.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/b398bd22a77f14498955257342fa03445c59e84b/hotio/hotio-striptracks-synology.png -------------------------------------------------------------------------------- /root/etc/s6-overlay/s6-rc.d/init-mod-radarr-striptracks-add-package/dependencies.d/init-mods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/b398bd22a77f14498955257342fa03445c59e84b/root/etc/s6-overlay/s6-rc.d/init-mod-radarr-striptracks-add-package/dependencies.d/init-mods -------------------------------------------------------------------------------- /root/etc/s6-overlay/s6-rc.d/init-mod-radarr-striptracks-add-package/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/with-contenv bash 2 | 3 | cat <>> Striptracks Mod by TheCaptain989 <<< 6 | Repos: 7 | Dev/test: https://github.com/TheCaptain989/radarr-striptracks 8 | Prod: https://github.com/linuxserver/docker-mods/tree/radarr-striptracks 9 | 10 | Version: {{VERSION}} 11 | ---------------- 12 | EOF 13 | 14 | # Determine if setup is needed 15 | if [ ! -f /usr/bin/mkvmerge ]; then 16 | echo "**** Adding striptracks deps to package install list ****" 17 | echo "mkvtoolnix" >> /mod-repo-packages-to-install.list 18 | else 19 | echo "**** striptracks deps already installed, skipping ****" 20 | fi 21 | 22 | # Check ownership and attributes on each script file 23 | for file in /usr/local/bin/striptracks*.sh 24 | do 25 | # Change ownership 26 | if [ $(stat -c '%G' $file) != "abc" ]; then 27 | echo "Changing ownership on $file script." 28 | lsiown abc:abc $file 29 | fi 30 | 31 | # Make executable 32 | if [ ! -x $file ]; then 33 | echo "Making $file script executable." 34 | chmod +x $file 35 | fi 36 | done 37 | -------------------------------------------------------------------------------- /root/etc/s6-overlay/s6-rc.d/init-mod-radarr-striptracks-add-package/type: -------------------------------------------------------------------------------- 1 | oneshot -------------------------------------------------------------------------------- /root/etc/s6-overlay/s6-rc.d/init-mod-radarr-striptracks-add-package/up: -------------------------------------------------------------------------------- 1 | /etc/s6-overlay/s6-rc.d/init-mod-radarr-striptracks-add-package/run -------------------------------------------------------------------------------- /root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mod-radarr-striptracks-add-package: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/b398bd22a77f14498955257342fa03445c59e84b/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mod-radarr-striptracks-add-package -------------------------------------------------------------------------------- /root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mod-radarr-striptracks-add-package: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/b398bd22a77f14498955257342fa03445c59e84b/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mod-radarr-striptracks-add-package -------------------------------------------------------------------------------- /root/usr/local/bin/striptracks-debug-2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /usr/local/bin/striptracks.sh -d 2 4 | -------------------------------------------------------------------------------- /root/usr/local/bin/striptracks-debug-max.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /usr/local/bin/striptracks.sh -d 9 4 | -------------------------------------------------------------------------------- /root/usr/local/bin/striptracks-debug.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /usr/local/bin/striptracks.sh -d 4 | -------------------------------------------------------------------------------- /root/usr/local/bin/striptracks-dut.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /usr/local/bin/striptracks.sh --audio :nld:dut:und --subs :nld:dut 4 | -------------------------------------------------------------------------------- /root/usr/local/bin/striptracks-eng-debug.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /usr/local/bin/striptracks.sh -d --audio :eng:und:any+d --subs :eng:any+f 4 | -------------------------------------------------------------------------------- /root/usr/local/bin/striptracks-eng-fre.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /usr/local/bin/striptracks.sh --audio :eng:fre:und --subs :eng:fre 4 | -------------------------------------------------------------------------------- /root/usr/local/bin/striptracks-eng-jpn.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /usr/local/bin/striptracks.sh --audio :eng:jpn:und --subs :eng 4 | -------------------------------------------------------------------------------- /root/usr/local/bin/striptracks-eng.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /usr/local/bin/striptracks.sh --audio :eng:und --subs :eng 4 | -------------------------------------------------------------------------------- /root/usr/local/bin/striptracks-fre.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /usr/local/bin/striptracks.sh --audio :fre:fra:und --subs :fre:fra 4 | -------------------------------------------------------------------------------- /root/usr/local/bin/striptracks-ger.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /usr/local/bin/striptracks.sh --audio :ger:deu:und --subs :ger:deu 4 | -------------------------------------------------------------------------------- /root/usr/local/bin/striptracks-org-eng.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /usr/local/bin/striptracks.sh --audio :org:eng:und:any+d --subs :org:eng:any+f 4 | -------------------------------------------------------------------------------- /root/usr/local/bin/striptracks-org-ger.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /usr/local/bin/striptracks.sh --audio :org:ger:deu:und --subs :org:ger:deu 4 | -------------------------------------------------------------------------------- /root/usr/local/bin/striptracks-org-spa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /usr/local/bin/striptracks.sh --audio :org:spa:und --subs :org:spa 4 | -------------------------------------------------------------------------------- /root/usr/local/bin/striptracks-spa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /usr/local/bin/striptracks.sh --audio :spa:und --subs :spa 4 | -------------------------------------------------------------------------------- /wsl/README.md: -------------------------------------------------------------------------------- 1 | # About 2 | This mod is able to run on Windows versions of Radarr and Sonarr by using the [Windows Subsystem for Linux (WSL)](https://learn.microsoft.com/en-us/windows/wsl/). 3 | 4 | # Installation 5 | Below are highly simplified installation instructions assuming defaults on a basic system. Your specific system may require changing paths or other wrapper script alterations. 6 | 7 | 1. Install Radarr or Sonarr on Windows 8 | 2. Install WSL from PowerShell: 9 | 10 | ```powershell 11 | wsl --install 12 | ``` 13 | 14 | 3. Run the [wsl-install-striptracks.ps1](wsl-install-striptracks.ps1) 15 | installation script, entering your Linux user password when prompted: 16 | 17 | ```powershell 18 | iex (iwr "https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/refs/heads/master/wsl/wsl-install-striptracks.ps1").Content 19 | ``` 20 | 21 | > [!NOTE] 22 | > The password entered here is *only* used to execute sudo once to install required Linux packages. It is not stored or saved anywhere. 23 | 24 | The installation script supports optional command-line arguments to change the default branch, installation directory, etc. 25 | 26 |
27 | Command-Line Arguments 28 | 29 | Option|Argument|Description 30 | ---|---|--- 31 | `-Password`|``|Your WSL Linux user password.
Must be a PowerShell `[SecureString]` data type. 32 | `-Directory`|``|Directory to install striptracks to
Default: `C:\ProgramData\striptracks` 33 | `-Owner`|``|GitHub repository owner
Default: `TheCaptain989` 34 | `-Repository`|``|GitHub repository name
Default: `radarr-striptracks` 35 | `-Release`|``|GitHub branch of source code to download
Default: `latest` 36 | `-GhApiRoot`|``|GitHub API root URL
Default: `https://api.github.com` 37 | 38 | To pass command-line arguments to the script, you must download it and execute it in multiple separate steps. 39 | 40 | *Example Command-Line Argument Use* 41 | 42 | ```powershell 43 | # Step 1: Download the script 44 | Invoke-WebRequest "https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/refs/heads/master/wsl/wsl-install-striptracks.ps1" -OutFile wsl-install-striptracks.ps1 45 | # Step 2: Needed to run unsigned downloaded scripts 46 | Set-ExecutionPolicy RemoteSigned -Scope CurrentUser 47 | # Step 3: Execute installation script. Example option only. 48 | .\wsl-install-striptracks.ps1 -Directory "D:\striptracks" 49 | ``` 50 | 51 |
52 | 53 | 4. Configure a custom script from Radarr's or Sonarr's *Settings* > *Connect* screen and type the following in the **Path** field (or the directory you installed striptracks to): 54 | `C:\ProgramData\striptracks\wsl-striptracks.cmd` 55 | 56 |
57 | Screenshot 58 | 59 | *New Custom Script Example* 60 | ![wsl custom script](wsl-custom-script.png "New Custom Script") 61 | 62 | 63 | 64 | # Explanation 65 | WSL provides a way to run a virtual Linux machine on Windows. Radarr and/or Sonarr are running in Windows while the script and supporting MKVToolNix package are running in the virtual machine 66 | and WSL makes the magic possible to have them interoperate. 67 | 68 | # Requirements 69 | - This requires WSL v2. 70 | - This has only been tested on Windows 11 23H2. 71 | - Only one instance each of Radarr and Sonarr are supported. 72 | - The Radarr/Sonarr configurations must be stored under the `%ProgramData%` directory (by default, these are C:\ProgramData\Radarr or C:\ProgramData\Sonarr). 73 | -------------------------------------------------------------------------------- /wsl/wsl-custom-script.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/b398bd22a77f14498955257342fa03445c59e84b/wsl/wsl-custom-script.png -------------------------------------------------------------------------------- /wsl/wsl-install-striptracks.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | This script installs striptracks.sh in a Windows Subsystem for Linux (WSL) environment. 4 | .Description 5 | radarr-striptracks is a Docker Mod for the Linuxserver.io Radarr/Sonarr containers. 6 | This installation script makes it work outside of Docker in a virtual WSL environment 7 | on Windows. 8 | .Link 9 | https://github.com/TheCaptain989/radarr-striptracks 10 | .Example 11 | wsl-install-striptracks -Release "v2.9.0" 12 | 13 | This changes the default release. 14 | #> 15 | 16 | #requires -Version 3 17 | 18 | [CmdletBinding(PositionalBinding = $False)] 19 | #region Initialize parameters 20 | param ( 21 | # WSL user password (for sudo command) 22 | # This is not stored and only used to pass to sudo for required package installations 23 | [Parameter(Mandatory = $true, HelpMessage = "Enter your WSL user password (this will not be stored)")] 24 | [SecureString]$Password = (Read-Host -AsSecureString "Enter your WSL user password (this will not be stored)"), 25 | 26 | # Directory to install striptracks to 27 | [string]$Directory = "$env:ProgramData\striptracks", 28 | 29 | # GitHub repository owner 30 | [string]$Owner = "TheCaptain989", 31 | 32 | # GitHub repository name 33 | [string]$Repository = "radarr-striptracks", 34 | 35 | # GitHub respository release tag 36 | [string]$Release = "latest", 37 | 38 | # GitHub API root URL 39 | [string]$GhApiRoot = "https://api.github.com" 40 | ) 41 | #endregion 42 | 43 | # Uneditable initial parameters 44 | $GhApiHeaders = @{"Accept"="application/vnd.github+json"; "X-GitHub-Api-Version"="2022-11-28"} 45 | $ZipFile = "$Directory\striptracks-$Release.zip" 46 | 47 | # Functions 48 | function Test-WSL { 49 | # Check that WSL is installed 50 | $local:WSLStatus = wsl --status 51 | if ($LASTEXITCODE -ne 0) { 52 | switch ($LASTEXITCODE) { 53 | 50 { Write-Error -Message "WSL does not appear to be installed. Run 'wsl --install' first." -Category NotInstalled -TargetObject $WSLStatus } 54 | default { Write-Error -Message "Error $LASTEXITCODE when attempting to check WSL status." -TargetObject $WSLStatus } 55 | } 56 | } 57 | return $LASTEXITCODE 58 | } 59 | 60 | function Install-LinuxPackages { 61 | # Install the required Linux packages 62 | $local:PlanTextPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) 63 | $local:WSLStatus = wsl -- echo "$PlanTextPassword" `| sudo -S bash -c "apt update && apt install mkvtoolnix jq" 2>&1 64 | if ($LASTEXITCODE -ne 0) { 65 | switch ($LASTEXITCODE) { 66 | 1 { Write-Error -Message "Your password is incorrect." -Category AuthenticationError -TargetObject $WSLStatus } 67 | default { Write-Error -Message "Error $LASTEXITCODE when attempting to install required Linux packages." -TargetObject $WSLStatus } 68 | } 69 | } 70 | return $LASTEXITCODE 71 | } 72 | 73 | function Expand-ZipFile { 74 | # Unzip the necessary script files from the archive 75 | Add-Type -AssemblyName System.IO.Compression.FileSystem 76 | $ZipObj = [System.IO.Compression.ZipFile]::OpenRead($ZipFile) 77 | $ZipEntries = $ZipObj.Entries | Where-Object { $_.FullName -like "*/wsl/wsl-*.cmd" -or $_.Name -eq "striptracks.sh" } 78 | foreach ($Entry in $ZipEntries) { 79 | [IO.Compression.ZipFileExtensions]::ExtractToFile($Entry, "$Directory\$($Entry.Name)", $true) 80 | } 81 | $ZipObj.Dispose() 82 | return $LASTEXITCODE 83 | } 84 | 85 | # Save working directory 86 | $OrgDirectory = $pwd 87 | 88 | # Check that WSL is installed 89 | Write-Output "Checking WSL status..." 90 | if ((Test-WSL) -ne 0) { return } 91 | 92 | # Install the required Linux packages 93 | Write-Output "Installing required Linux packages..." 94 | if ((Install-LinuxPackages) -ne 0) { return } 95 | 96 | # Create the new directory if it doesn't already exist and change to it 97 | if (-not (Test-Path $Directory)) { 98 | Write-Output "Creating $Directory" 99 | New-Item -ItemType Directory $Directory | Out-Null 100 | } 101 | Set-Location -Path $Directory 102 | 103 | # Query GitHub for release version 104 | Write-Output "Getting striptracks release info..." 105 | $ApiResponse = (Invoke-WebRequest -Headers $GhApiHeaders -Uri "$GhApiRoot/repos/$Owner/$Repository/releases/$Release").Content | ConvertFrom-Json 106 | $ModVersion = $ApiResponse.tag_name 107 | 108 | # Download striptracks ZIP archive 109 | Write-Output "Downloading striptracks ZIP archive..." 110 | Invoke-WebRequest -Headers $GhApiHeaders -Uri $ApiResponse.zipball_url -OutFile $ZipFile 111 | 112 | # Unzip files 113 | Write-Output "Extracting files from ZIP archive..." 114 | if ((Expand-ZipFile) -ne 0) { return } 115 | 116 | # Edit some script files 117 | (Get-Content -Path "$Directory\wsl-striptracks.cmd") -replace "set STRIPTRACKS_ROOT=%ProgramData%\\striptracks", "set STRIPTRACKS_ROOT=$Directory" | Set-Content -Path "$Directory\wsl-striptracks.cmd" 118 | # This method preserves Linux newline endings 119 | Set-Content -Path "$Directory\striptracks.sh" -NoNewline -Value (((Get-Content -Path "$Directory\striptracks.sh") -replace "{{VERSION}}", $ModVersion -join "`n") + "`n") 120 | 121 | # Close and remove the ZIP archive 122 | Write-Output "Deleting ZIP archive" 123 | Remove-Item -Path $ZipFile 124 | 125 | # Make the striptracks.sh script executable 126 | Write-Output "Making striptracks.sh executable" 127 | wsl chmod +x striptracks.sh 128 | 129 | # Exit 130 | Set-Location -Path $OrgDirectory.Path 131 | Write-Output "striptracks has been installed to $Directory" 132 | -------------------------------------------------------------------------------- /wsl/wsl-striptracks-debug.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | wsl-striptracks.cmd -d 4 | -------------------------------------------------------------------------------- /wsl/wsl-striptracks.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem This is a wrapper script for striptrack.sh that is meant to be called 3 | rem by Radarr or Sonarr as a Custom Script. It sets up the environment 4 | rem and calls striptracks in a virtual Windows Subsystem for Linux (WSL). 5 | rem https://github.com/TheCaptain989/radarr-striptracks/ 6 | 7 | rem Seemingly ubiquitous required batch file localization 8 | setlocal enableextensions enabledelayedexpansion 9 | 10 | rem Set the script execution root 11 | set STRIPTRACKS_ROOT=%ProgramData%\striptracks 12 | 13 | rem WSLENV is a special environment variable that can pass values 14 | rem back and forth and translate file and directory paths between 15 | rem Windows and Linux 16 | set WSLENV=STRIPTRACKS_ROOT/p:%WSLENV% 17 | 18 | rem Pass the appropriate variables to WSL for each supported script mode 19 | rem Uses the default ProgramData location for Radarr/Sonarr configuration 20 | rem Check for radarr variable 21 | if defined radarr_eventtype ( 22 | cd %ProgramData%\Radarr 23 | set WSLENV=radarr_eventtype:radarr_moviefile_path/p:radarr_movie_path/p:radarr_movie_id:radarr_moviefile_id:radarr_movie_title:radarr_movie_year:%WSLENV% 24 | ) 25 | rem Check for sonarr variable 26 | if defined sonarr_eventtype ( 27 | cd %ProgramData%\Sonarr 28 | set WSLENV=sonarr_eventtype:sonarr_episodefile_path/p:sonarr_series_path/p:sonarr_episodefile_episodeids:sonarr_episodefile_id:sonarr_series_id:sonarr_series_title:sonarr_episodefile_episodetitles:sonarr_episodefile_seasonnumber:sonarr_episodefile_episodenumbers:%WSLENV% 29 | ) 30 | 31 | rem Add the log path so script logs show up in Radarr/Sonarr 32 | set CMDLINEARGS=--log ./logs/striptracks.txt 33 | 34 | rem Test for the STRIPTRACKS_ARGS variable and add the log option 35 | rem but don't override if it is already present 36 | if defined STRIPTRACKS_ARGS ( 37 | set WSLENV=STRIPTRACKS_ARGS:%WSLENV% 38 | rem Check for existing log option, both long and short 39 | echo "%STRIPTRACKS_ARGS%" | find "--log " >nul 40 | if errorlevel 1 ( 41 | echo "%STRIPTRACKS_ARGS%" | find "-l " >nul 42 | if errorlevel 1 ( 43 | rem No log option, so add it 44 | set STRIPTRACKS_ARGS=%STRIPTRACKS_ARGS% %CMDLINEARGS% 45 | set CMDLINEARGS= 46 | ) 47 | ) 48 | ) 49 | 50 | rem Call striptracks.sh script using WSL 51 | rem Pass command-line arguments if they exist 52 | wsl $STRIPTRACKS_ROOT/striptracks.sh %CMDLINEARGS% %* 53 | --------------------------------------------------------------------------------