added option to subtitle extractor to set working file

This commit is contained in:
reven
2022-01-13 22:31:29 +13:00
parent d98ce25084
commit 010747fe09
3 changed files with 22 additions and 1 deletions

Binary file not shown.

View File

@@ -135,7 +135,9 @@
"Language": "Language",
"Language-Help": "The ISO 639-2 language code to use. \nhttps://en.wikipedia.org/wiki/List_of_ISO_639-2_codes",
"OutputFile": "Output File",
"OutputFile-Help": "Where to save the the output file to, e.g. \"'{folder.Orig.FullName}\\{file.Orig.FileName}.srt'\" to save it with the original file as a srt output.\nIf left blank an srt subtitle will be created in the same folder as the original input file."
"OutputFile-Help": "Where to save the the output file to, e.g. \"'{folder.Orig.FullName}\\{file.Orig.FileName}.srt'\" to save it with the original file as a srt output.\nIf left blank an srt subtitle will be created in the same folder as the original input file.",
"SetWorkingFile": "Set as Working File",
"SetWorkingFile-Help": "When this is checked, if a subtitle is extracted, the working file will be changed to this extracted subtitle. The original working file will NOT be deleted."
}
},
"VideoCodec": {

View File

@@ -19,6 +19,18 @@
[File(2)]
public string OutputFile { get; set; }
[Boolean(3)]
public bool SetWorkingFile { get; set; }
private Dictionary<string, object> _Variables;
public override Dictionary<string, object> Variables => _Variables;
public SubtitleExtractor()
{
_Variables = new Dictionary<string, object>()
{
{ "sub.FileName", "/path/to/subtitle.sub" }
};
}
public override int Execute(NodeParameters args)
{
try
@@ -88,6 +100,13 @@
if (result.ExitCode == 0)
{
args.UpdateVariables(new Dictionary<string, object>
{
{ "sub.FileName", OutputFile }
});
if (SetWorkingFile)
args.SetWorkingFile(OutputFile, dontDelete: true);
return 1;
}