-
Notifications
You must be signed in to change notification settings - Fork 1
/
search_options.go
60 lines (47 loc) · 857 Bytes
/
search_options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package lyricfind
import (
"fmt"
"net/url"
)
type SearchOptions struct {
Artist string
Album string
Track string
Lyrics string
Meta string
All string
OnlyDisplayable bool
Offset int
Limit int
}
func (o *SearchOptions) values() url.Values {
v := url.Values{}
if o.Artist != "" {
v.Set("artist", o.Artist)
}
if o.Album != "" {
v.Set("album", o.Album)
}
if o.Track != "" {
v.Set("track", o.Track)
}
if o.Lyrics != "" {
v.Set("lyrics", o.Lyrics)
}
if o.Meta != "" {
v.Set("meta", o.Meta)
}
if o.All != "" {
v.Set("all", o.All)
}
if o.OnlyDisplayable {
v.Set("alltracks", "no")
}
if o.Offset != 0 {
v.Set("offset", fmt.Sprintf("%d", o.Offset))
}
if o.Limit != 0 {
v.Set("limit", fmt.Sprintf("%d", o.Limit))
}
return v
}