Associate funscript files on scan (#2978)

This commit is contained in:
WithoutPants
2022-10-06 11:17:01 +11:00
committed by GitHub
parent 55001ddcf1
commit b160c3bb97
4 changed files with 52 additions and 20 deletions

View File

@@ -55,3 +55,25 @@ func (d *Decorator) Decorate(ctx context.Context, fs file.FS, f file.File) (file
Interactive: interactive,
}, nil
}
func (d *Decorator) IsMissingMetadata(ctx context.Context, fs file.FS, f file.File) bool {
const (
unsetString = "unset"
unsetNumber = -1
)
vf, ok := f.(*file.VideoFile)
if !ok {
return true
}
interactive := false
if _, err := fs.Lstat(GetFunscriptPath(vf.Base().Path)); err == nil {
interactive = true
}
return vf.VideoCodec == unsetString || vf.AudioCodec == unsetString ||
vf.Format == unsetString || vf.Width == unsetNumber ||
vf.Height == unsetNumber || vf.FrameRate == unsetNumber ||
vf.BitRate == unsetNumber || interactive != vf.Interactive
}