mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Clean missing captions during scan (#3240)
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/stashapp/stash/pkg/file"
|
||||
"github.com/stashapp/stash/pkg/file/video"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/models/paths"
|
||||
@@ -36,6 +37,7 @@ type ScanHandler struct {
|
||||
|
||||
CoverGenerator CoverGenerator
|
||||
ScanGenerator ScanGenerator
|
||||
CaptionUpdater video.CaptionUpdater
|
||||
PluginCache *plugin.Cache
|
||||
|
||||
FileNamingAlgorithm models.HashAlgorithm
|
||||
@@ -52,6 +54,9 @@ func (h *ScanHandler) validate() error {
|
||||
if h.ScanGenerator == nil {
|
||||
return errors.New("ScanGenerator is required")
|
||||
}
|
||||
if h.CaptionUpdater == nil {
|
||||
return errors.New("CaptionUpdater is required")
|
||||
}
|
||||
if !h.FileNamingAlgorithm.IsValid() {
|
||||
return errors.New("FileNamingAlgorithm is required")
|
||||
}
|
||||
@@ -72,6 +77,12 @@ func (h *ScanHandler) Handle(ctx context.Context, f file.File, oldFile file.File
|
||||
return ErrNotVideoFile
|
||||
}
|
||||
|
||||
if oldFile != nil {
|
||||
if err := video.CleanCaptions(ctx, videoFile, nil, h.CaptionUpdater); err != nil {
|
||||
return fmt.Errorf("cleaning captions: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// try to match the file to a scene
|
||||
existing, err := h.CreatorUpdater.FindByFileID(ctx, f.Base().ID)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user