package model import ( "fmt" "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(strings.TrimSuffix(str, "p")) return Resolution(v), err } } func (r Resolution) String() string { switch r { case Resolution4K: return "4K" default: return fmt.Sprintf("%dp", r) } }