feat: complte media store

This commit is contained in:
Rogee
2024-12-06 15:06:15 +08:00
parent 43bde1e62a
commit 7d446b46c2
10 changed files with 199 additions and 226 deletions

View File

@@ -5,6 +5,7 @@ import (
"crypto/md5"
"fmt"
"io"
"math"
"os"
"os/exec"
"path/filepath"
@@ -108,7 +109,7 @@ func (d *DiscoverMedias) processVideo(video string, to string) (media_store.Vide
if err != nil {
return info, errors.Wrapf(err, "get media duration: %s", video)
}
info.Duration = uint(duration)
info.Duration = duration
return info, nil
}
@@ -295,7 +296,7 @@ func (d *DiscoverMedias) getPrice(dir string) (uint, error) {
}
// getMediaDuration get the duration of a media file
func (d *DiscoverMedias) getMediaDuration(file string) (float64, error) {
func (d *DiscoverMedias) getMediaDuration(file string) (int64, error) {
// ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input_video.mp4
args := []string{
"-v", "error",
@@ -315,7 +316,7 @@ func (d *DiscoverMedias) getMediaDuration(file string) (float64, error) {
return 0, errors.Wrapf(err, "get media duration: %s", file)
}
return duration, nil
return int64(math.Floor(duration)), nil
}
// getMedias get the medias in the directory