javascript-ampache 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -6
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.m.js +1 -1
- package/dist/index.m.js.map +1 -1
- package/dist/index.modern.mjs +1 -1
- package/dist/index.modern.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +8 -7
- package/src/albums.js +106 -0
- package/src/artists.js +105 -0
- package/src/auth.js +142 -0
- package/src/base.js +145 -0
- package/src/bookmarks.js +106 -0
- package/src/catalogs.js +133 -0
- package/src/genres.js +57 -0
- package/src/index.js +30 -0
- package/src/labels.js +53 -0
- package/src/licenses.js +47 -0
- package/src/live-streams.js +97 -0
- package/src/playlists.js +241 -0
- package/src/podcasts.js +230 -0
- package/src/preferences.js +114 -0
- package/src/shares.js +99 -0
- package/src/shouts.js +24 -0
- package/src/songs.js +273 -0
- package/src/system.js +510 -0
- package/src/users.js +224 -0
- package/src/{utils.ts → utils.js} +16 -16
- package/src/videos.js +84 -0
- package/dist/albums/index.d.ts +0 -64
- package/dist/albums/types.d.ts +0 -37
- package/dist/artists/index.d.ts +0 -64
- package/dist/artists/types.d.ts +0 -35
- package/dist/auth/index.d.ts +0 -56
- package/dist/auth/types.d.ts +0 -32
- package/dist/base.d.ts +0 -47
- package/dist/bookmarks/index.d.ts +0 -91
- package/dist/bookmarks/types.d.ts +0 -13
- package/dist/catalogs/index.d.ts +0 -87
- package/dist/catalogs/types.d.ts +0 -19
- package/dist/genres/index.d.ts +0 -28
- package/dist/genres/types.d.ts +0 -22
- package/dist/index.d.ts +0 -24
- package/dist/labels/index.d.ts +0 -32
- package/dist/labels/types.d.ts +0 -18
- package/dist/licenses/index.d.ts +0 -32
- package/dist/licenses/types.d.ts +0 -12
- package/dist/live-streams/index.d.ts +0 -80
- package/dist/live-streams/types.d.ts +0 -14
- package/dist/playlists/index.d.ts +0 -208
- package/dist/playlists/types.d.ts +0 -26
- package/dist/podcasts/index.d.ts +0 -121
- package/dist/podcasts/types.d.ts +0 -79
- package/dist/preferences/index.d.ts +0 -80
- package/dist/preferences/types.d.ts +0 -18
- package/dist/shares/index.d.ts +0 -69
- package/dist/shares/types.d.ts +0 -23
- package/dist/shouts/index.d.ts +0 -17
- package/dist/shouts/types.d.ts +0 -10
- package/dist/songs/index.d.ts +0 -146
- package/dist/songs/types.d.ts +0 -73
- package/dist/system/index.d.ts +0 -419
- package/dist/system/types.d.ts +0 -31
- package/dist/users/index.d.ts +0 -190
- package/dist/users/types.d.ts +0 -34
- package/dist/utils.d.ts +0 -4
- package/dist/videos/index.d.ts +0 -33
- package/dist/videos/types.d.ts +0 -38
- package/src/albums/index.ts +0 -88
- package/src/albums/types.ts +0 -40
- package/src/artists/index.ts +0 -88
- package/src/artists/types.ts +0 -38
- package/src/auth/index.ts +0 -118
- package/src/auth/types.ts +0 -32
- package/src/base.ts +0 -133
- package/src/bookmarks/index.ts +0 -116
- package/src/bookmarks/types.ts +0 -15
- package/src/catalogs/index.ts +0 -130
- package/src/catalogs/types.ts +0 -27
- package/src/genres/index.ts +0 -39
- package/src/genres/types.ts +0 -25
- package/src/index.ts +0 -63
- package/src/labels/index.ts +0 -43
- package/src/labels/types.ts +0 -20
- package/src/licenses/index.ts +0 -43
- package/src/licenses/types.ts +0 -14
- package/src/live-streams/index.ts +0 -104
- package/src/live-streams/types.ts +0 -16
- package/src/playlists/index.ts +0 -284
- package/src/playlists/types.ts +0 -29
- package/src/podcasts/index.ts +0 -174
- package/src/podcasts/types.ts +0 -85
- package/src/preferences/index.ts +0 -114
- package/src/preferences/types.ts +0 -20
- package/src/shares/index.ts +0 -100
- package/src/shares/types.ts +0 -25
- package/src/shouts/index.ts +0 -18
- package/src/shouts/types.ts +0 -11
- package/src/songs/index.ts +0 -221
- package/src/songs/types.ts +0 -77
- package/src/system/index.ts +0 -860
- package/src/system/types.ts +0 -50
- package/src/users/index.ts +0 -227
- package/src/users/types.ts +0 -38
- package/src/videos/index.ts +0 -49
- package/src/videos/types.ts +0 -42
package/src/songs.js
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} SongResponse
|
|
3
|
+
* @property {import("./base.js").UID} id
|
|
4
|
+
* @property {string} title
|
|
5
|
+
* @property {string} name
|
|
6
|
+
* @property {import("./artists.js").ArtistSummary} artist
|
|
7
|
+
* @property {import("./albums.js").AlbumSummary} album
|
|
8
|
+
* @property {import("./artists.js").ArtistSummary} albumartist
|
|
9
|
+
* @property {number} disk
|
|
10
|
+
* @property {number} track
|
|
11
|
+
* @property {string} filename
|
|
12
|
+
* @property {import("./genres.js").GenreSummary[]} genre
|
|
13
|
+
* @property {number} playlisttrack
|
|
14
|
+
* @property {number} time
|
|
15
|
+
* @property {number|string} year
|
|
16
|
+
* @property {string} format
|
|
17
|
+
* @property {string} stream_format
|
|
18
|
+
* @property {number} rate
|
|
19
|
+
* @property {string} mode
|
|
20
|
+
* @property {string} mime
|
|
21
|
+
* @property {string} stream_mime
|
|
22
|
+
* @property {string} url
|
|
23
|
+
* @property {number} size
|
|
24
|
+
* @property {string|null} mbid
|
|
25
|
+
* @property {string|null} album_mbid
|
|
26
|
+
* @property {string|null} artist_mbid
|
|
27
|
+
* @property {string} art
|
|
28
|
+
* @property {boolean} has_art
|
|
29
|
+
* @property {boolean} flag
|
|
30
|
+
* @property {number|null} rating
|
|
31
|
+
* @property {number|null} averagerating
|
|
32
|
+
* @property {number} playcount
|
|
33
|
+
* @property {number} catalog
|
|
34
|
+
* @property {string} composer
|
|
35
|
+
* @property {number|null} channels
|
|
36
|
+
* @property {string} comment
|
|
37
|
+
* @property {string|null} license
|
|
38
|
+
* @property {string} publisher
|
|
39
|
+
* @property {string} language
|
|
40
|
+
* @property {string} lyrics
|
|
41
|
+
* @property {number|null} replaygain_album_gain
|
|
42
|
+
* @property {number|null} replaygain_album_peak
|
|
43
|
+
* @property {number|null} replaygain_track_gain
|
|
44
|
+
* @property {number|null} replaygain_track_peak
|
|
45
|
+
* @property {number|null} r128_album_gain
|
|
46
|
+
* @property {number|null} r128_track_gain
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @typedef {Object} SongsResponse
|
|
51
|
+
* @property {number} total_count
|
|
52
|
+
* @property {string} md5
|
|
53
|
+
* @property {SongResponse[]} song
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @typedef {Object} DeletedSongResponse
|
|
58
|
+
* @property {import("./base.js").UID} id
|
|
59
|
+
* @property {number} addition_time
|
|
60
|
+
* @property {number} delete_time
|
|
61
|
+
* @property {number} update_time
|
|
62
|
+
* @property {string} title
|
|
63
|
+
* @property {string} file
|
|
64
|
+
* @property {import("./base.js").UID} catalog
|
|
65
|
+
* @property {number} total_count
|
|
66
|
+
* @property {number} total_skip
|
|
67
|
+
* @property {import("./base.js").UID} album
|
|
68
|
+
* @property {import("./base.js").UID} artist
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @typedef {Object} DeletedSongsResponse
|
|
73
|
+
* @property {number} total_count
|
|
74
|
+
* @property {string} md5
|
|
75
|
+
* @property {DeletedSongResponse[]} deleted_song
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
import qs from "querystringify";
|
|
79
|
+
|
|
80
|
+
export const songsMethods = {
|
|
81
|
+
/**
|
|
82
|
+
* Returns songs based on the specified filter
|
|
83
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
84
|
+
* @param {Object} [params]
|
|
85
|
+
* @param {string} [params.filter] Filter results to match this string
|
|
86
|
+
* @param {import("./base.js").BinaryBoolean} [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
|
|
87
|
+
* @param {Date} [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
|
|
88
|
+
* @param {Date} [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
|
|
89
|
+
* @param {number} [params.offset]
|
|
90
|
+
* @param {number} [params.limit]
|
|
91
|
+
* @param {string} [params.cond]
|
|
92
|
+
* @param {string} [params.sort]
|
|
93
|
+
* @returns {Promise<SongsResponse>}
|
|
94
|
+
* @see {@link https://ampache.org/api/api-json-methods#songs}
|
|
95
|
+
*/
|
|
96
|
+
songs(params) {
|
|
97
|
+
return this.call("songs", params);
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Returns a single song
|
|
102
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
103
|
+
* @param {Object} params
|
|
104
|
+
* @param {import("./base.js").UID} params.filter UID to find
|
|
105
|
+
* @returns {Promise<SongResponse>}
|
|
106
|
+
* @see {@link https://ampache.org/api/api-json-methods#song}
|
|
107
|
+
*/
|
|
108
|
+
song(params) {
|
|
109
|
+
return this.call("song", params);
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Songs of the specified artist
|
|
114
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
115
|
+
* @param {Object} params
|
|
116
|
+
* @param {import("./base.js").UID} params.filter UID to find
|
|
117
|
+
* @param {import("./base.js").BinaryBoolean} [params.top50] 0, 1 (if true filter to the artist top 50)
|
|
118
|
+
* @param {number} [params.offset]
|
|
119
|
+
* @param {number} [params.limit]
|
|
120
|
+
* @param {string} [params.cond]
|
|
121
|
+
* @param {string} [params.sort]
|
|
122
|
+
* @returns {Promise<SongsResponse>}
|
|
123
|
+
* @see {@link https://ampache.org/api/api-json-methods#artist_songs}
|
|
124
|
+
*/
|
|
125
|
+
artistSongs(params) {
|
|
126
|
+
return this.call("artist_songs", params);
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Songs of the specified album
|
|
131
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
132
|
+
* @param {Object} params
|
|
133
|
+
* @param {import("./base.js").UID} params.filter UID to find
|
|
134
|
+
* @param {number} [params.offset]
|
|
135
|
+
* @param {number} [params.limit]
|
|
136
|
+
* @param {string} [params.cond]
|
|
137
|
+
* @param {string} [params.sort]
|
|
138
|
+
* @returns {Promise<SongsResponse>}
|
|
139
|
+
* @see {@link https://ampache.org/api/api-json-methods#album_songs}
|
|
140
|
+
*/
|
|
141
|
+
albumSongs(params) {
|
|
142
|
+
return this.call("album_songs", params);
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Songs of the specified genre
|
|
147
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
148
|
+
* @param {Object} params
|
|
149
|
+
* @param {import("./base.js").UID} params.filter UID to find
|
|
150
|
+
* @param {number} [params.offset]
|
|
151
|
+
* @param {number} [params.limit]
|
|
152
|
+
* @param {string} [params.cond]
|
|
153
|
+
* @param {string} [params.sort]
|
|
154
|
+
* @returns {Promise<SongsResponse>}
|
|
155
|
+
* @see {@link https://ampache.org/api/api-json-methods#genre_songs}
|
|
156
|
+
*/
|
|
157
|
+
genreSongs(params) {
|
|
158
|
+
return this.call("genre_songs", params);
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* This returns the songs for a playlist
|
|
163
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
164
|
+
* @param {Object} params
|
|
165
|
+
* @param {import("./base.js").UID} params.filter UID to find
|
|
166
|
+
* @param {import("./base.js").BinaryBoolean} [params.random] 0, 1 (if true get random songs using limit)
|
|
167
|
+
* @param {number} [params.offset]
|
|
168
|
+
* @param {number} [params.limit]
|
|
169
|
+
* @returns {Promise<SongsResponse>}
|
|
170
|
+
* @see {@link https://ampache.org/api/api-json-methods#playlist_songs}
|
|
171
|
+
*/
|
|
172
|
+
playlistSongs(params) {
|
|
173
|
+
return this.call("playlist_songs", params);
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* This returns the songs for a license
|
|
178
|
+
* @remarks MINIMUM_API_VERSION=420000
|
|
179
|
+
* @param {Object} params
|
|
180
|
+
* @param {import("./base.js").UID} params.filter UID to find
|
|
181
|
+
* @param {number} [params.offset]
|
|
182
|
+
* @param {number} [params.limit]
|
|
183
|
+
* @param {string} [params.cond]
|
|
184
|
+
* @param {string} [params.sort]
|
|
185
|
+
* @returns {Promise<SongsResponse>}
|
|
186
|
+
* @see {@link https://ampache.org/api/api-json-methods#license_songs}
|
|
187
|
+
*/
|
|
188
|
+
licenseSongs(params) {
|
|
189
|
+
return this.call("license_songs", params);
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Delete an existing song. (if you are allowed to)
|
|
194
|
+
* @remarks MINIMUM_API_VERSION=5.0.0
|
|
195
|
+
* @param {Object} params
|
|
196
|
+
* @param {import("./base.js").UID} params.filter UID of song to delete
|
|
197
|
+
* @returns {Promise<import("./base.js").Success>}
|
|
198
|
+
* @see {@link https://ampache.org/api/api-json-methods#song_delete}
|
|
199
|
+
*/
|
|
200
|
+
songDelete(params) {
|
|
201
|
+
return this.call("song_delete", params);
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Get the full song file tags using VaInfo
|
|
206
|
+
* This is used to get tags for remote catalogs to allow maximum data to be returned
|
|
207
|
+
* @remarks MINIMUM_API_VERSION=6.7.0
|
|
208
|
+
* @param {Object} params
|
|
209
|
+
* @param {import("./base.js").UID} params.filter UID of song to fetch
|
|
210
|
+
* @returns {Promise<*>}
|
|
211
|
+
* @see {@link https://ampache.org/api/api-json-methods#song_tags}
|
|
212
|
+
*/
|
|
213
|
+
songTags(params) {
|
|
214
|
+
return this.call("song_tags", params);
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Return database lyrics or search with plugins by song id
|
|
219
|
+
* @remarks MINIMUM_API_VERSION=6.7.0
|
|
220
|
+
* @param {Object} params
|
|
221
|
+
* @param {import("./base.js").UID} params.filter Song id to find
|
|
222
|
+
* @param {import("./base.js").BinaryBoolean} [params.plugins] 0, 1, if false disable plugin lookup (default: 1)
|
|
223
|
+
* @returns {Promise<*>}
|
|
224
|
+
* @see {@link https://ampache.org/api/api-json-methods#get_lyrics}
|
|
225
|
+
*/
|
|
226
|
+
getLyrics(params) {
|
|
227
|
+
return this.call("get_lyrics", params);
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* This takes a URL and returns the song object in question
|
|
232
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
233
|
+
* @param {Object} params
|
|
234
|
+
* @param {string} [params.url] Full Ampache URL from server (deprecated in 7.9.0+, use filter)
|
|
235
|
+
* @param {string} [params.filter] Alias of url (Ampache 7.9.0+)
|
|
236
|
+
* @returns {Promise<SongResponse>}
|
|
237
|
+
* @see {@link https://ampache.org/api/api-json-methods#url_to_song}
|
|
238
|
+
*/
|
|
239
|
+
urlToSong(params) {
|
|
240
|
+
let query = "url_to_song";
|
|
241
|
+
const out = { ...params };
|
|
242
|
+
if (out.url != null) out.url = encodeURIComponent(out.url);
|
|
243
|
+
query += qs.stringify(out, "&");
|
|
244
|
+
return this.request(query);
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* This searches the songs and returns... songs
|
|
249
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
250
|
+
* @param {Object} params
|
|
251
|
+
* @param {string} params.filter Filter results to match this string
|
|
252
|
+
* @param {number} [params.offset]
|
|
253
|
+
* @param {number} [params.limit]
|
|
254
|
+
* @returns {Promise<SongsResponse>}
|
|
255
|
+
* @see {@link https://ampache.org/api/api-json-methods#search_songs}
|
|
256
|
+
*/
|
|
257
|
+
searchSongs(params) {
|
|
258
|
+
return this.call("search_songs", params);
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Returns songs that have been deleted from the server
|
|
263
|
+
* @remarks MINIMUM_API_VERSION=500000
|
|
264
|
+
* @param {Object} [params]
|
|
265
|
+
* @param {number} [params.offset]
|
|
266
|
+
* @param {number} [params.limit]
|
|
267
|
+
* @returns {Promise<DeletedSongsResponse>}
|
|
268
|
+
* @see {@link https://ampache.org/api/api-json-methods#deleted_songs}
|
|
269
|
+
*/
|
|
270
|
+
deletedSongs(params) {
|
|
271
|
+
return this.call("deleted_songs", params);
|
|
272
|
+
},
|
|
273
|
+
};
|