Skip to content

Commit

Permalink
Scanner: Remove goroutine for chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthi-chaud committed Apr 15, 2024
1 parent 84b7a68 commit e77a0bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
14 changes: 6 additions & 8 deletions scanner/pkg/actions/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ func RegisterFile(path string, c *config.Config) error {
glg.Failf(err.Error())
return err
}
go func() {
for i, chapterId := range res.ChaptersId {
thumbnailBytes, err := pkg.GetFrame(path, int64(dto.Chapters[i].StartTimestamp)+int64(dto.Chapters[i].EndTimestamp-dto.Chapters[i].StartTimestamp)/2)
api.SaveChapterThumbnail(chapterId, thumbnailBytes, *c)
if err != nil {
glg.Fail(err)
}
for i, chapterId := range res.ChaptersId {
thumbnailBytes, err := pkg.GetFrame(path, int64(dto.Chapters[i].StartTimestamp)+int64(dto.Chapters[i].EndTimestamp-dto.Chapters[i].StartTimestamp)/2)
api.SaveChapterThumbnail(chapterId, thumbnailBytes, *c)
if err != nil {
glg.Fail(err)
}
}()
}
} else if parsedPath.Extra != nil {
dto, err := buildExtraDto(path, parsedPath.Extra, mediainfo)

Expand Down
6 changes: 1 addition & 5 deletions scanner/pkg/thumbnail.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ package pkg
import (
"bytes"
"fmt"
// "fmt"
"io"
"os"

// "time"

"github.com/u2takey/ffmpeg-go"
)
Expand All @@ -18,6 +14,6 @@ func GetFrame(filepath string, timestamp int64) (io.Reader, error) {
err := ffmpeg_go.Input(filepath, ffmpeg_go.KwArgs{"ss": formattedDuration}).
Filter("select", ffmpeg_go.Args{"gte(n,1)"}).
Output("pipe:", ffmpeg_go.KwArgs{"vframes": 1, "format": "image2", "vcodec": "mjpeg"}).
WithOutput(buf, os.Stdout).Run()
WithOutput(buf).Run()
return buf, err
}

0 comments on commit e77a0bc

Please sign in to comment.