Skip to content

Commit

Permalink
Added "Skip" option to batch encoding picker settings. When chosen, t…
Browse files Browse the repository at this point in the history
…he item won't be queued when the output file already exists.
  • Loading branch information
RandomEngy committed Jun 30, 2024
1 parent 7950e8d commit d51d2ed
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 26 deletions.
3 changes: 2 additions & 1 deletion VidCoder/Model/WhenFileExists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public enum WhenFileExists
{
Prompt,
Overwrite,
AutoRename
AutoRename,
Skip
}
9 changes: 9 additions & 0 deletions VidCoder/Resources/EnumsRes.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions VidCoder/Resources/EnumsRes.resx
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,7 @@
<data name="EncodeCompleteActionType_Restart" xml:space="preserve">
<value>Restart</value>
</data>
<data name="WhenFileExists_Skip" xml:space="preserve">
<value>Skip</value>
</data>
</root>
3 changes: 3 additions & 0 deletions VidCoder/Services/OutputPathService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ public string ResolveOutputPathConflicts(
{
case WhenFileExists.Prompt:
break;
case WhenFileExists.Skip:
StaticResolver.Resolve<IAppLogger>().Log("Skipping job, output file already exists: " + initialOutputPath);
return null;
case WhenFileExists.Overwrite:
if (checkResult == FileQueueCheckResult.InQueue && allowQueueRemoval)
{
Expand Down
60 changes: 35 additions & 25 deletions VidCoder/Services/ProcessingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1528,23 +1528,30 @@ public void QueueTitles(List<SourceTitle> titles, int titleStartOverride, string

string extension = this.outputPathService.GetOutputExtension();
string queueOutputPath = this.outputPathService.BuildOutputPath(queueOutputFileName, extension, sourcePath: null, outputFolder: outputFolder);
string finalOutputPath = this.outputPathService.ResolveOutputPathConflicts(queueOutputPath, this.main.SourcePath, isBatch: true, picker, allowConflictDialog: false, allowQueueRemoval: true);

job.FinalOutputPath = this.outputPathService.ResolveOutputPathConflicts(queueOutputPath, this.main.SourcePath, isBatch: true, picker, allowConflictDialog: false, allowQueueRemoval: true);
if (finalOutputPath != null)
{
job.FinalOutputPath = finalOutputPath;

var jobVM = new EncodeJobViewModel(
job,
this.main.SourceData,
this.main.GetVideoSourceMetadata(),
sourceParentFolder: null,
manualOutputPath: false,
nameFormatOverride: nameFormatOverride,
presetName: this.presetsService.SelectedPreset.DisplayName,
pickerName: picker.Name);
var jobVM = new EncodeJobViewModel(
job,
this.main.SourceData,
this.main.GetVideoSourceMetadata(),
sourceParentFolder: null,
manualOutputPath: false,
nameFormatOverride: nameFormatOverride,
presetName: this.presetsService.SelectedPreset.DisplayName,
pickerName: picker.Name);

jobsToAdd.Add(jobVM);
jobsToAdd.Add(jobVM);
}
}

this.QueueMultipleJobs(jobsToAdd);
if (jobsToAdd.Count > 0)
{
this.QueueMultipleJobs(jobsToAdd);
}
}

private void RetryJobIfNeeded(EncodeJobViewModel encodeJobViewModel)
Expand Down Expand Up @@ -1715,8 +1722,6 @@ public void QueueFromScanResults(IList<ScanResult> scanResults, bool start)
presetName: preset.Name,
pickerName: picker.Name);

itemsToQueue.Add(jobVM);

var titles = jobVM.VideoSource.Titles;

SourceTitle title = titles.Single(t => t.Index == job.Title);
Expand Down Expand Up @@ -1755,20 +1760,25 @@ public void QueueFromScanResults(IList<ScanResult> scanResults, bool start)
allowConflictDialog: !scanResult.JobInstructions.IsBatch,
allowQueueRemoval: true);

if (Utilities.IsValidFullPath(queueOutputPath))
if (queueOutputPath != null)
{
job.FinalOutputPath = queueOutputPath;
itemsToQueue.Add(jobVM);

queuedOutputFiles.Add(queueOutputPath);
}
else
{
this.logger.LogError($"Could not add \"{queueOutputPath}\" to queue; it is not a valid full file path.");
}
if (Utilities.IsValidFullPath(queueOutputPath))
{
job.FinalOutputPath = queueOutputPath;

if (scanResults.Count == 1 && !string.IsNullOrWhiteSpace(scanResult.JobInstructions.DestinationOverride))
{
job.FinalOutputPath = scanResult.JobInstructions.DestinationOverride;
queuedOutputFiles.Add(queueOutputPath);
}
else
{
this.logger.LogError($"Could not add \"{queueOutputPath}\" to queue; it is not a valid full file path.");
}

if (scanResults.Count == 1 && !string.IsNullOrWhiteSpace(scanResult.JobInstructions.DestinationOverride))
{
job.FinalOutputPath = scanResult.JobInstructions.DestinationOverride;
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions VidCoder/ViewModel/PickerWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ public WhenFileExists WhenFileExistsSingle
{
new ComboChoice<WhenFileExists>(WhenFileExists.Overwrite, EnumsRes.WhenFileExists_Overwrite),
new ComboChoice<WhenFileExists>(WhenFileExists.AutoRename, EnumsRes.WhenFileExists_AutoRename),
new ComboChoice<WhenFileExists>(WhenFileExists.Skip, EnumsRes.WhenFileExists_Skip),
};

public WhenFileExists WhenFileExistsBatch
Expand Down

0 comments on commit d51d2ed

Please sign in to comment.