Allow customisation of preview generation (#673)

* Add generate-specific options
* Include no-cache in preview response
This commit is contained in:
WithoutPants
2020-07-23 12:51:35 +10:00
committed by GitHub
parent 37be146a9d
commit a2341f0819
18 changed files with 509 additions and 53 deletions

View File

@@ -167,6 +167,33 @@ func (s *singleton) Export() {
}()
}
func setGeneratePreviewOptionsInput(optionsInput *models.GeneratePreviewOptionsInput) {
if optionsInput.PreviewSegments == nil {
val := config.GetPreviewSegments()
optionsInput.PreviewSegments = &val
}
if optionsInput.PreviewSegmentDuration == nil {
val := config.GetPreviewSegmentDuration()
optionsInput.PreviewSegmentDuration = &val
}
if optionsInput.PreviewExcludeStart == nil {
val := config.GetPreviewExcludeStart()
optionsInput.PreviewExcludeStart = &val
}
if optionsInput.PreviewExcludeEnd == nil {
val := config.GetPreviewExcludeEnd()
optionsInput.PreviewExcludeEnd = &val
}
if optionsInput.PreviewPreset == nil {
val := config.GetPreviewPreset()
optionsInput.PreviewPreset = &val
}
}
func (s *singleton) Generate(input models.GenerateMetadataInput) {
if s.Status.Status != Idle {
return
@@ -181,8 +208,6 @@ func (s *singleton) Generate(input models.GenerateMetadataInput) {
//this.job.total = await ObjectionUtils.getCount(Scene);
instance.Paths.Generated.EnsureTmpDir()
preset := config.GetPreviewPreset().String()
galleryIDs := utils.StringSliceToIntSlice(input.GalleryIDs)
sceneIDs := utils.StringSliceToIntSlice(input.SceneIDs)
markerIDs := utils.StringSliceToIntSlice(input.MarkerIDs)
@@ -251,6 +276,12 @@ func (s *singleton) Generate(input models.GenerateMetadataInput) {
overwrite = *input.Overwrite
}
generatePreviewOptions := input.PreviewOptions
if generatePreviewOptions == nil {
generatePreviewOptions = &models.GeneratePreviewOptionsInput{}
}
setGeneratePreviewOptionsInput(generatePreviewOptions)
for i, scene := range scenes {
s.Status.setProgress(i, total)
if s.Status.stopping {
@@ -276,7 +307,12 @@ func (s *singleton) Generate(input models.GenerateMetadataInput) {
}
if input.Previews {
task := GeneratePreviewTask{Scene: *scene, ImagePreview: input.ImagePreviews, PreviewPreset: preset, Overwrite: overwrite}
task := GeneratePreviewTask{
Scene: *scene,
ImagePreview: input.ImagePreviews,
Options: *generatePreviewOptions,
Overwrite: overwrite,
}
go task.Start(&wg)
}