-
Notifications
You must be signed in to change notification settings - Fork 14
/
browsing.go
189 lines (174 loc) · 5.66 KB
/
browsing.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package subsonic
// GetMusicFolders returns all configured top-level music folders.
func (s *Client) GetMusicFolders() ([]*MusicFolder, error) {
resp, err := s.Get("getMusicFolders", nil)
if err != nil {
return nil, err
}
return resp.MusicFolders.MusicFolder, nil
}
// GetIndexes returns the index of entries by letter/number.
//
// Optional Parameters:
// musicFolderId: Only return songs in the music folder with the given ID. See getMusicFolders.
// ifModifiedSince: If specified, only return a result if the artist collection has changed since the given time (in milliseconds since 1 Jan 1970).
func (s *Client) GetIndexes(parameters map[string]string) (*Indexes, error) {
resp, err := s.Get("getIndexes", parameters)
if err != nil {
return nil, err
}
return resp.Indexes, nil
}
// GetMusicDirectory returns a listing of all files in a music directory. Typically used to get list of albums for an artist, or list of songs for an album.
// The ID can be an album, song, or artist - anything considered within the directory hierarchy of Subsonic.
func (s *Client) GetMusicDirectory(id string) (*Directory, error) {
resp, err := s.Get("getMusicDirectory", map[string]string{"id": id})
if err != nil {
return nil, err
}
return resp.Directory, nil
}
// GetGenres returns all genres in the server.
func (s *Client) GetGenres() ([]*Genre, error) {
resp, err := s.Get("getGenres", nil)
if err != nil {
return nil, err
}
return resp.Genres.Genre, nil
}
// GetArtists returns all artists in the server.
//
// Optional Parameters:
// musicFolderId: Only return songs in the music folder with the given ID. See getMusicFolders.
func (s *Client) GetArtists(parameters map[string]string) (*ArtistsID3, error) {
resp, err := s.Get("getArtists", parameters)
if err != nil {
return nil, err
}
return resp.Artists, nil
}
// GetAlbum returns an Artist by ID.
func (s *Client) GetArtist(id string) (*ArtistID3, error) {
resp, err := s.Get("getArtist", map[string]string{"id": id})
if err != nil {
return nil, err
}
return resp.Artist, nil
}
// GetAlbum returns an Album by ID.
func (s *Client) GetAlbum(id string) (*AlbumID3, error) {
resp, err := s.Get("getAlbum", map[string]string{"id": id})
if err != nil {
return nil, err
}
return resp.Album, nil
}
// GetSong returns a Song by ID.
func (s *Client) GetSong(id string) (*Child, error) {
resp, err := s.Get("getSong", map[string]string{"id": id})
if err != nil {
return nil, err
}
return resp.Song, nil
}
// GetArtistInfo returns biography, image links, and similar artists from last.fm.
//
// Optional Parameters:
// count: Max number of similar artists to return.
// includeNotPresent: Whether to return artists that are not present in the media library.
func (s *Client) GetArtistInfo(id string, parameters map[string]string) (*ArtistInfo, error) {
params := make(map[string]string)
params["id"] = id
for k, v := range parameters {
params[k] = v
}
resp, err := s.Get("getArtistInfo", params)
if err != nil {
return nil, err
}
return resp.ArtistInfo, nil
}
// GetArtistInfo2 returns biography, image links, and similar artists like GetArtistInfo, but using id3 tags.
//
// Optional Parameters:
// count: Max number of similar artists to return.
// includeNotPresent: Whether to return artists that are not present in the media library.
func (s *Client) GetArtistInfo2(id string, parameters map[string]string) (*ArtistInfo2, error) {
params := make(map[string]string)
params["id"] = id
for k, v := range parameters {
params[k] = v
}
resp, err := s.Get("getArtistInfo2", params)
if err != nil {
return nil, err
}
return resp.ArtistInfo2, nil
}
// GetAlbumInfo returns album notes, image data, etc using data from last.fm.
// This accepts both album and song IDs.
func (s *Client) GetAlbumInfo(id string) (*AlbumInfo, error) {
resp, err := s.Get("getAlbumInfo", map[string]string{"id": id})
if err != nil {
return nil, err
}
return resp.AlbumInfo, nil
}
// GetAlbumInfo2 returns the same data as GetAlbumInfo, but organized by id3 tag.
// It only accepts album IDs.
func (s *Client) GetAlbumInfo2(id string) (*AlbumInfo, error) {
resp, err := s.Get("getAlbumInfo2", map[string]string{"id": id})
if err != nil {
return nil, err
}
return resp.AlbumInfo, nil
}
// GetSimilarSongs finds similar songs to an album, track, or artist.
// This is mostly used for radio features. This accepts artist, album, or song IDs.
//
// Optional Parameters:
// count: Number of songs to return
func (s *Client) GetSimilarSongs(id string, parameters map[string]string) ([]*Child, error) {
params := make(map[string]string)
params["id"] = id
for k, v := range parameters {
params[k] = v
}
resp, err := s.Get("getSimilarSongs", params)
if err != nil {
return nil, err
}
return resp.SimilarSongs.Song, nil
}
// GetSimilarSongs2 finds similar songs like GetSimilarSongs, but using id3 tags.
//
// Optional Parameters:
// count: Number of songs to return
func (s *Client) GetSimilarSongs2(id string, parameters map[string]string) ([]*Child, error) {
params := make(map[string]string)
params["id"] = id
for k, v := range parameters {
params[k] = v
}
resp, err := s.Get("getSimilarSongs2", params)
if err != nil {
return nil, err
}
return resp.SimilarSongs2.Song, nil
}
// GetTopSongs returns the top songs for a given artist by name.
//
// Optional Parameters:
// count: Number of songs to return
func (s *Client) GetTopSongs(name string, parameters map[string]string) ([]*Child, error) {
params := make(map[string]string)
params["artist"] = name
for k, v := range parameters {
params[k] = v
}
resp, err := s.Get("getTopSongs", params)
if err != nil {
return nil, err
}
return resp.TopSongs.Song, nil
}