mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 20:24:27 -04:00
Add file size in /info
This commit is contained in:
parent
a74fbce48e
commit
d3d59443fa
@ -19,6 +19,8 @@ type MediaInfo struct {
|
|||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
/// The extension currently used to store this video file
|
/// The extension currently used to store this video file
|
||||||
Extension string `json:"extension"`
|
Extension string `json:"extension"`
|
||||||
|
/// The file size of the video file.
|
||||||
|
Size uint64 `json:"size"`
|
||||||
/// The length of the media in seconds.
|
/// The length of the media in seconds.
|
||||||
Length float32 `json:"length"`
|
Length float32 `json:"length"`
|
||||||
/// The container of the video file of this episode.
|
/// The container of the video file of this episode.
|
||||||
@ -105,11 +107,21 @@ func ParseFloat(str string) float32 {
|
|||||||
func ParseUint(str string) uint32 {
|
func ParseUint(str string) uint32 {
|
||||||
i, err := strconv.ParseUint(str, 10, 32)
|
i, err := strconv.ParseUint(str, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
println(str)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return uint32(i)
|
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 {
|
func ParseTime(str string) float32 {
|
||||||
x := strings.Split(str, ":")
|
x := strings.Split(str, ":")
|
||||||
hours, minutes, sms := ParseFloat(x[0]), ParseFloat(x[1]), x[2]
|
hours, minutes, sms := ParseFloat(x[0]), ParseFloat(x[1]), x[2]
|
||||||
@ -188,6 +200,7 @@ func GetInfo(path string) (*MediaInfo, error) {
|
|||||||
Path: path,
|
Path: path,
|
||||||
// Remove leading .
|
// Remove leading .
|
||||||
Extension: filepath.Ext(path)[1:],
|
Extension: filepath.Ext(path)[1:],
|
||||||
|
Size: ParseUint64(mi.Parameter(mediainfo.StreamGeneral, 0, "FileSize")),
|
||||||
// convert seconds to ms
|
// convert seconds to ms
|
||||||
Length: ParseFloat(mi.Parameter(mediainfo.StreamGeneral, 0, "Duration")) / 1000,
|
Length: ParseFloat(mi.Parameter(mediainfo.StreamGeneral, 0, "Duration")) / 1000,
|
||||||
Container: mi.Parameter(mediainfo.StreamGeneral, 0, "Format"),
|
Container: mi.Parameter(mediainfo.StreamGeneral, 0, "Format"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user