updated track remover to use variables

This commit is contained in:
john
2022-12-20 11:40:16 +13:00
parent 3a41d0552e
commit f10f331c2e

View File

@@ -46,9 +46,9 @@ public class FfmpegBuilderAudioTrackRemover: FfmpegBuilderNode
{
_MatchTypes = new List<ListOption>
{
new ListOption { Label = "Title", Value = MatchTypeOption.Title },
new ListOption { Label = "Language", Value = MatchTypeOption.Language },
new ListOption { Label = "Codec", Value = MatchTypeOption.Codec }
new () { Label = "Title", Value = MatchTypeOption.Title },
new () { Label = "Language", Value = MatchTypeOption.Language },
new () { Label = "Codec", Value = MatchTypeOption.Codec }
};
}
return _MatchTypes;
@@ -93,17 +93,18 @@ public class FfmpegBuilderAudioTrackRemover: FfmpegBuilderNode
}
public override int Execute(NodeParameters args)
{
string pattern = args.ReplaceVariables(this.Pattern, stripMissing: true);
if(string.IsNullOrEmpty(StreamType) || StreamType.ToLower() == "audio")
return RemoveTracks(Model.AudioStreams) ? 1 : 2;
return RemoveTracks(pattern, Model.AudioStreams) ? 1 : 2;
if (StreamType.ToLower() == "subtitle")
return RemoveTracks(Model.SubtitleStreams) ? 1 : 2;
return RemoveTracks(pattern, Model.SubtitleStreams) ? 1 : 2;
if (StreamType.ToLower() == "video")
return RemoveTracks(Model.VideoStreams) ? 1 : 2;
return RemoveTracks(pattern, Model.VideoStreams) ? 1 : 2;
return 2;
}
private bool RemoveTracks<T>(List<T> tracks) where T: FfmpegStream
private bool RemoveTracks<T>(string pattern, List<T> tracks) where T: FfmpegStream
{
bool removing = false;
Regex? regex = null;
@@ -119,7 +120,7 @@ public class FfmpegBuilderAudioTrackRemover: FfmpegBuilderNode
continue;
}
if (RemoveAll || string.IsNullOrEmpty(this.Pattern))
if (RemoveAll || string.IsNullOrEmpty(pattern))
{
track.Deleted = true;
removing = true;
@@ -127,7 +128,7 @@ public class FfmpegBuilderAudioTrackRemover: FfmpegBuilderNode
}
if (regex == null)
regex = new Regex(this.Pattern, RegexOptions.IgnoreCase);
regex = new Regex(pattern, RegexOptions.IgnoreCase);
string str = "";
if(track is FfmpegAudioStream audio)