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" case ResolutionQuadHD: return "1440p" case ResolutionFullHD: return "1080p" case ResolutionHD: return "720p" case ResolutionSD: return "SD" default: return fmt.Sprintf("%sp", r) } }