From 8d2df527b746a71af28c000d9dc2822980d9dc87 Mon Sep 17 00:00:00 2001 From: bill <48220860+bnkai@users.noreply.github.com> Date: Fri, 18 Oct 2019 02:17:51 +0300 Subject: [PATCH] makeScreenshots cleanup --- pkg/manager/task_scan.go | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/pkg/manager/task_scan.go b/pkg/manager/task_scan.go index d35e75b6f..3d394f37e 100644 --- a/pkg/manager/task_scan.go +++ b/pkg/manager/task_scan.go @@ -163,31 +163,25 @@ func (t *ScanTask) makeScreenshots(probeResult *ffmpeg.VideoFile, checksum strin return } - if probeResult != nil { - // makescreenshots is called for a new file - t.makeScreenshot(*probeResult, thumbPath, 5, 320) - t.makeScreenshot(*probeResult, normalPath, 2, probeResult.Width) - } else { - // makescreenshots is called for an already existing file - if !thumbExists || !normalExists { - checkvideoFile, err := ffmpeg.NewVideoFile(instance.FFProbePath, t.FilePath) + if probeResult == nil { + var err error + probeResult, err = ffmpeg.NewVideoFile(instance.FFProbePath, t.FilePath) - if err != nil { - logger.Error(err.Error()) - return - } - if !thumbExists { - logger.Infof("Recreating thumbnail for %s", t.FilePath) - t.makeScreenshot(*checkvideoFile, thumbPath, 5, 320) - } - - if !normalExists { - logger.Infof("Recreating screenshot for %s", t.FilePath) - t.makeScreenshot(*checkvideoFile, normalPath, 2, checkvideoFile.Width) - } + if err != nil { + logger.Error(err.Error()) + return } } + if !thumbExists { + logger.Debugf("Creating thumbnail for %s", t.FilePath) + t.makeScreenshot(*probeResult, thumbPath, 5, 320) + } + + if !normalExists { + logger.Debugf("Creating screenshot for %s", t.FilePath) + t.makeScreenshot(*probeResult, normalPath, 2, probeResult.Width) + } } func (t *ScanTask) makeScreenshot(probeResult ffmpeg.VideoFile, outputPath string, quality int, width int) {