From d3d59443fae34728fdfc18ce563370211b2f79eb Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Mon, 22 Jan 2024 00:47:46 +0100 Subject: [PATCH] Add file size in /info --- transcoder/src/info.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/transcoder/src/info.go b/transcoder/src/info.go index 6673247b..666c3b63 100644 --- a/transcoder/src/info.go +++ b/transcoder/src/info.go @@ -19,6 +19,8 @@ type MediaInfo struct { Path string `json:"path"` /// The extension currently used to store this video file Extension string `json:"extension"` + /// The file size of the video file. + Size uint64 `json:"size"` /// The length of the media in seconds. Length float32 `json:"length"` /// The container of the video file of this episode. @@ -105,11 +107,21 @@ func ParseFloat(str string) float32 { func ParseUint(str string) uint32 { i, err := strconv.ParseUint(str, 10, 32) if err != nil { + println(str) return 0 } return uint32(i) } +func ParseUint64(str string) uint64 { + i, err := strconv.ParseUint(str, 10, 64) + if err != nil { + println(str) + return 0 + } + return i +} + func ParseTime(str string) float32 { x := strings.Split(str, ":") hours, minutes, sms := ParseFloat(x[0]), ParseFloat(x[1]), x[2] @@ -188,6 +200,7 @@ func GetInfo(path string) (*MediaInfo, error) { Path: path, // Remove leading . Extension: filepath.Ext(path)[1:], + Size: ParseUint64(mi.Parameter(mediainfo.StreamGeneral, 0, "FileSize")), // convert seconds to ms Length: ParseFloat(mi.Parameter(mediainfo.StreamGeneral, 0, "Duration")) / 1000, Container: mi.Parameter(mediainfo.StreamGeneral, 0, "Format"),