model/resolution.go
2022-08-04 16:45:36 +02:00

32 lines
576 B
Go

package model
import (
"strconv"
"strings"
)
type Resolution int
const (
Resolution4K Resolution = 2160
ResolutionQuadHD Resolution = 1440
ResolutionFullHD Resolution = 1080
ResolutionHD Resolution = 720
ResolutionSD Resolution = 480
ResolutionUnknown Resolution = 0
)
func ParseResolution(str string) (Resolution, error) {
switch strings.TrimSpace(str) {
case "4K":
return Resolution4K, nil
case "HD":
return ResolutionHD, nil
case "SD":
return ResolutionSD, nil
default:
v, err := strconv.Atoi(str)
return Resolution(v), err
}
}