refactor: consolidate download domain into download package

This commit is contained in:
Mathis Maquenne
2026-08-05 11:46:10 +02:00
parent dbb808f371
commit 5c95554855
14 changed files with 314 additions and 300 deletions
+38
View File
@@ -0,0 +1,38 @@
package download
import (
"fmt"
"time"
)
var validQualities = map[string]bool{
"mp3_128": true,
"mp3_320": true,
"flac": true,
}
type Options struct {
Quality string
Timeout time.Duration
Limit int
BPM bool
Genre bool
Strict bool
}
func (o *Options) Validate() error {
if !validQualities[o.Quality] {
return fmt.Errorf("invalid quality option: %s", o.Quality)
}
if o.Timeout <= 0 {
return fmt.Errorf("timeout must be a positive duration")
}
if o.Limit <= 0 {
return fmt.Errorf("limit must be a positive integer")
}
if o.Limit > 100 {
return fmt.Errorf("limit must not exceed 100")
}
return nil
}