Files
godeez/internal/downloader/options.go
T

34 lines
473 B
Go

package downloader
import (
"fmt"
)
var validQualities = map[string]bool{
"mp3_128": true,
"mp3_320": true,
"flac": true,
"best": true,
}
type Options struct {
OutputDir string
Quality string
}
func (o *Options) Validate(appDir string) error {
if o.OutputDir == "" {
o.OutputDir = appDir
}
if o.Quality == "" {
o.Quality = "best"
}
if !validQualities[o.Quality] {
return fmt.Errorf("invalid quality option: %s", o.Quality)
}
return nil
}