mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 04:04:21 -04:00
Improve medioinfo with invalid videos and add multiple videos support to the /info
This commit is contained in:
parent
6ec387e724
commit
7193a599b7
@ -160,11 +160,11 @@ export const WatchInfoP = z
|
|||||||
/**
|
/**
|
||||||
* The container of the video file of this episode. Common containers are mp4, mkv, avi and so on.
|
* The container of the video file of this episode. Common containers are mp4, mkv, avi and so on.
|
||||||
*/
|
*/
|
||||||
container: z.string(),
|
container: z.string().nullable(),
|
||||||
/**
|
/**
|
||||||
* The video track.
|
* The video track.
|
||||||
*/
|
*/
|
||||||
video: VideoP,
|
video: VideoP.nullable(),
|
||||||
/**
|
/**
|
||||||
* The list of audio tracks.
|
* The list of audio tracks.
|
||||||
*/
|
*/
|
||||||
|
@ -60,7 +60,7 @@ const MediaInfoTable = ({
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
[t("mediainfo.file")]: path?.replace(/^\/video\//, ""),
|
[t("mediainfo.file")]: path?.replace(/^\/video\//, ""),
|
||||||
[t("mediainfo.container")]: container,
|
[t("mediainfo.container")]: container !== null ? container : t("mediainfo.nocontainer"),
|
||||||
[t("mediainfo.duration")]: duration,
|
[t("mediainfo.duration")]: duration,
|
||||||
[t("mediainfo.size")]: size,
|
[t("mediainfo.size")]: size,
|
||||||
},
|
},
|
||||||
@ -69,7 +69,9 @@ const MediaInfoTable = ({
|
|||||||
? `${video.width}x${video.height} (${video.quality}) - ${formatBitrate(
|
? `${video.width}x${video.height} (${video.quality}) - ${formatBitrate(
|
||||||
video.bitrate,
|
video.bitrate,
|
||||||
)} - ${video.codec}`
|
)} - ${video.codec}`
|
||||||
: undefined,
|
: video === null
|
||||||
|
? t("mediainfo.novideo")
|
||||||
|
: undefined,
|
||||||
},
|
},
|
||||||
audios === undefined
|
audios === undefined
|
||||||
? { [t("mediainfo.audio")]: undefined }
|
? { [t("mediainfo.audio")]: undefined }
|
||||||
|
@ -185,6 +185,8 @@
|
|||||||
"forced": "Forced",
|
"forced": "Forced",
|
||||||
"default": "Default",
|
"default": "Default",
|
||||||
"duration": "Duration",
|
"duration": "Duration",
|
||||||
"size": "Size"
|
"size": "Size",
|
||||||
|
"novideo": "No video",
|
||||||
|
"nocontainer": "Invalid container"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,6 +185,8 @@
|
|||||||
"forced": "Forcé",
|
"forced": "Forcé",
|
||||||
"default": "Par Défaut",
|
"default": "Par Défaut",
|
||||||
"duration": "Duration",
|
"duration": "Duration",
|
||||||
"size": "Taille"
|
"size": "Taille",
|
||||||
|
"novideo": "Pas de video",
|
||||||
|
"nocontainer": "Conteneur invalide"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,11 @@ type MediaInfo struct {
|
|||||||
/// The length of the media in seconds.
|
/// The length of the media in seconds.
|
||||||
Duration float32 `json:"duration"`
|
Duration float32 `json:"duration"`
|
||||||
/// The container of the video file of this episode.
|
/// The container of the video file of this episode.
|
||||||
Container string `json:"container"`
|
Container *string `json:"container"`
|
||||||
/// The video codec and infromations.
|
/// The video codec and infromations.
|
||||||
Video Video `json:"video"`
|
Video *Video `json:"video"`
|
||||||
|
/// The list of videos if there are multiples.
|
||||||
|
Videos []Video `json:"videos"`
|
||||||
/// The list of audio tracks.
|
/// The list of audio tracks.
|
||||||
Audios []Audio `json:"audios"`
|
Audios []Audio `json:"audios"`
|
||||||
/// The list of subtitles tracks.
|
/// The list of subtitles tracks.
|
||||||
@ -200,7 +202,7 @@ func GetInfo(path string) (*MediaInfo, error) {
|
|||||||
attachments = make([]string, 0)
|
attachments = make([]string, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &MediaInfo{
|
ret := MediaInfo{
|
||||||
Sha: sha,
|
Sha: sha,
|
||||||
Path: path,
|
Path: path,
|
||||||
// Remove leading .
|
// Remove leading .
|
||||||
@ -208,21 +210,23 @@ func GetInfo(path string) (*MediaInfo, error) {
|
|||||||
Size: ParseUint64(mi.Parameter(mediainfo.StreamGeneral, 0, "FileSize")),
|
Size: ParseUint64(mi.Parameter(mediainfo.StreamGeneral, 0, "FileSize")),
|
||||||
// convert ms to seconds
|
// convert ms to seconds
|
||||||
Duration: ParseFloat(mi.Parameter(mediainfo.StreamGeneral, 0, "Duration")) / 1000,
|
Duration: ParseFloat(mi.Parameter(mediainfo.StreamGeneral, 0, "Duration")) / 1000,
|
||||||
Container: mi.Parameter(mediainfo.StreamGeneral, 0, "Format"),
|
Container: OrNull(mi.Parameter(mediainfo.StreamGeneral, 0, "Format")),
|
||||||
Video: Video{
|
Videos: Map(make([]Video, ParseUint(mi.Parameter(mediainfo.StreamVideo, 0, "StreamCount"))), func(_ Video, i int) Video {
|
||||||
// This codec is not in the right format (does not include bitdepth...).
|
return Video{
|
||||||
Codec: mi.Parameter(mediainfo.StreamVideo, 0, "Format"),
|
// This codec is not in the right format (does not include bitdepth...).
|
||||||
Language: OrNull(mi.Parameter(mediainfo.StreamVideo, 0, "Language")),
|
Codec: mi.Parameter(mediainfo.StreamVideo, 0, "Format"),
|
||||||
Quality: QualityFromHeight(ParseUint(mi.Parameter(mediainfo.StreamVideo, 0, "Height"))),
|
Language: OrNull(mi.Parameter(mediainfo.StreamVideo, 0, "Language")),
|
||||||
Width: ParseUint(mi.Parameter(mediainfo.StreamVideo, 0, "Width")),
|
Quality: QualityFromHeight(ParseUint(mi.Parameter(mediainfo.StreamVideo, 0, "Height"))),
|
||||||
Height: ParseUint(mi.Parameter(mediainfo.StreamVideo, 0, "Height")),
|
Width: ParseUint(mi.Parameter(mediainfo.StreamVideo, 0, "Width")),
|
||||||
Bitrate: ParseUint(
|
Height: ParseUint(mi.Parameter(mediainfo.StreamVideo, 0, "Height")),
|
||||||
Or(
|
Bitrate: ParseUint(
|
||||||
mi.Parameter(mediainfo.StreamVideo, 0, "BitRate"),
|
Or(
|
||||||
mi.Parameter(mediainfo.StreamVideo, 0, "OverallBitRate"),
|
mi.Parameter(mediainfo.StreamVideo, 0, "BitRate"),
|
||||||
|
mi.Parameter(mediainfo.StreamVideo, 0, "OverallBitRate"),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
}
|
||||||
},
|
}),
|
||||||
Audios: Map(make([]Audio, ParseUint(mi.Parameter(mediainfo.StreamAudio, 0, "StreamCount"))), func(_ Audio, i int) Audio {
|
Audios: Map(make([]Audio, ParseUint(mi.Parameter(mediainfo.StreamAudio, 0, "StreamCount"))), func(_ Audio, i int) Audio {
|
||||||
return Audio{
|
return Audio{
|
||||||
Index: uint32(i),
|
Index: uint32(i),
|
||||||
@ -269,5 +273,9 @@ func GetInfo(path string) (*MediaInfo, error) {
|
|||||||
func(font string, _ int) string {
|
func(font string, _ int) string {
|
||||||
return fmt.Sprintf("/video/%s/attachment/%s", sha, font)
|
return fmt.Sprintf("/video/%s/attachment/%s", sha, font)
|
||||||
}),
|
}),
|
||||||
}, nil
|
}
|
||||||
|
if len(ret.Videos) > 0 {
|
||||||
|
ret.Video = &ret.Videos[0]
|
||||||
|
}
|
||||||
|
return &ret, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user