mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Fix chapter extraction bug when no chapters exist
This commit is contained in:
parent
a6076eb856
commit
b312403201
@ -145,6 +145,13 @@ func OrNull(str string) *string {
|
||||
return &str
|
||||
}
|
||||
|
||||
func Max(x, y uint32) uint32 {
|
||||
if x < y {
|
||||
return y
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
var SubtitleExtensions = map[string]string{
|
||||
"subrip": "srt",
|
||||
"ass": "srt",
|
||||
@ -229,7 +236,7 @@ func GetInfo(path string) (MediaInfo, error) {
|
||||
Link: link,
|
||||
}
|
||||
}),
|
||||
Chapters: Map(make([]Chapter, chapters_end-chapters_begin-1), func(i int) Chapter {
|
||||
Chapters: Map(make([]Chapter, Max(chapters_end-chapters_begin, 1)-1), func(i int) Chapter {
|
||||
return Chapter{
|
||||
StartTime: ParseTime(mi.GetI(mediainfo.StreamMenu, 0, int(chapters_begin)+i, mediainfo.InfoName)),
|
||||
// +1 is safe, the value at chapters_end contains the right duration
|
||||
@ -237,5 +244,7 @@ func GetInfo(path string) (MediaInfo, error) {
|
||||
Name: mi.GetI(mediainfo.StreamMenu, 0, int(chapters_begin)+i, mediainfo.InfoText),
|
||||
}
|
||||
}),
|
||||
// TODO: populate fonts
|
||||
Fonts: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user