Fixed array length and nil panic

This commit is contained in:
bytedream 2022-02-13 20:31:50 +01:00
parent 8544a49cab
commit 1b0124e385
2 changed files with 56 additions and 4 deletions

View file

@ -152,11 +152,16 @@ func (e *Episode) GetFormat(resolution string, subtitle LOCALE, hardsub bool) (*
var res *Format
for _, format := range formats {
if resolution == "worst" || resolution == "best" {
curSplitRes := strings.SplitN(format.Video.Resolution, "x", 1)
if res == nil {
res = format
continue
}
curSplitRes := strings.SplitN(format.Video.Resolution, "x", 2)
curResX, _ := strconv.Atoi(curSplitRes[0])
curResY, _ := strconv.Atoi(curSplitRes[1])
resSplitRes := strings.SplitN(res.Video.Resolution, "x", 1)
resSplitRes := strings.SplitN(res.Video.Resolution, "x", 2)
resResX, _ := strconv.Atoi(resSplitRes[0])
resResY, _ := strconv.Atoi(resSplitRes[1])