Skip to content

Commit

Permalink
Corrected condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Marnalas committed Jan 10, 2025
1 parent 60840bc commit 0042403
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ var plugin = function (args) {
args.jobLog("Channels ".concat(channels, " determined has being the highest match"));
}
streams.forEach(function (stream, index) {
var _a, _b, _c, _d, _e;
var _a, _b, _c, _d, _e, _f, _g, _h;
if (stream.codec_type === 'audio') {
var dispositions = stream.disposition;
var isDescriptiveAudioStream = getIsDescriptiveAudioStream(stream);
Expand All @@ -150,7 +150,10 @@ var plugin = function (args) {
defaultSet = true;
shouldProcess = true;
}
else if (((_e = dispositions === null || dispositions === void 0 ? void 0 : dispositions.default) !== null && _e !== void 0 ? _e : 0) === 1) {
else if (((_e = dispositions === null || dispositions === void 0 ? void 0 : dispositions.default) !== null && _e !== void 0 ? _e : 0) === 1
&& (((_g = (_f = stream.tags) === null || _f === void 0 ? void 0 : _f.language) !== null && _g !== void 0 ? _g : '') !== languageCode
|| ((_h = stream.channels) !== null && _h !== void 0 ? _h : 0) !== channels
|| isDescriptiveAudioStream)) {
args.jobLog("Stream ".concat(index, " (language ").concat(languageCode, ", channels ").concat(channels, ", \n descriptive ").concat(isDescriptiveAudioStream, ") set has not default"));
stream.outputArgs.push("-c:".concat(index), 'copy', "-disposition:".concat(index), getFFMPEGDisposition(false, dispositions));
shouldProcess = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ const getFFMPEGDisposition = (isDefault: boolean, dispositions?: IDisposition):
};

const getIsDescriptiveAudioStream = (stream: IStreamDisposition): boolean => Boolean(stream.disposition
&& (stream.disposition.comment
|| stream.disposition.descriptions
|| stream.disposition.visual_impaired
|| /\b(commentary|description|descriptive)\b/gi.test(stream.tags?.title || '')));
&& (stream.disposition.comment
|| stream.disposition.descriptions
|| stream.disposition.visual_impaired
|| /\b(commentary|description|descriptive)\b/gi.test(stream.tags?.title || '')));

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
Expand Down Expand Up @@ -182,7 +182,10 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
);
defaultSet = true;
shouldProcess = true;
} else if ((dispositions?.default ?? 0) === 1) {
} else if ((dispositions?.default ?? 0) === 1
&& ((stream.tags?.language ?? '') !== languageCode
|| (stream.channels ?? 0) !== channels
|| isDescriptiveAudioStream)) {
args.jobLog(`Stream ${index} (language ${languageCode}, channels ${channels},
descriptive ${isDescriptiveAudioStream}) set has not default`);
stream.outputArgs.push(
Expand Down

0 comments on commit 0042403

Please sign in to comment.