javascript-ampache 1.1.10 → 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.
Files changed (108) hide show
  1. package/README.md +16 -6
  2. package/dist/index.js +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.m.js +1 -1
  5. package/dist/index.m.js.map +1 -1
  6. package/dist/index.modern.mjs +1 -1
  7. package/dist/index.modern.mjs.map +1 -1
  8. package/dist/index.umd.js +1 -1
  9. package/dist/index.umd.js.map +1 -1
  10. package/package.json +8 -7
  11. package/src/albums.js +106 -0
  12. package/src/artists.js +105 -0
  13. package/src/auth.js +142 -0
  14. package/src/base.js +145 -0
  15. package/src/bookmarks.js +106 -0
  16. package/src/catalogs.js +133 -0
  17. package/src/genres.js +57 -0
  18. package/src/index.js +30 -0
  19. package/src/labels.js +53 -0
  20. package/src/licenses.js +47 -0
  21. package/src/live-streams.js +97 -0
  22. package/src/playlists.js +241 -0
  23. package/src/podcasts.js +230 -0
  24. package/src/preferences.js +114 -0
  25. package/src/shares.js +99 -0
  26. package/src/shouts.js +24 -0
  27. package/src/songs.js +273 -0
  28. package/src/system.js +510 -0
  29. package/src/users.js +224 -0
  30. package/src/{utils.ts → utils.js} +16 -16
  31. package/src/videos.js +84 -0
  32. package/dist/albums/index.d.ts +0 -64
  33. package/dist/albums/types.d.ts +0 -37
  34. package/dist/artists/index.d.ts +0 -64
  35. package/dist/artists/types.d.ts +0 -35
  36. package/dist/auth/index.d.ts +0 -56
  37. package/dist/auth/types.d.ts +0 -32
  38. package/dist/base.d.ts +0 -47
  39. package/dist/bookmarks/index.d.ts +0 -91
  40. package/dist/bookmarks/types.d.ts +0 -13
  41. package/dist/catalogs/index.d.ts +0 -87
  42. package/dist/catalogs/types.d.ts +0 -19
  43. package/dist/genres/index.d.ts +0 -28
  44. package/dist/genres/types.d.ts +0 -22
  45. package/dist/index.d.ts +0 -24
  46. package/dist/labels/index.d.ts +0 -32
  47. package/dist/labels/types.d.ts +0 -18
  48. package/dist/licenses/index.d.ts +0 -32
  49. package/dist/licenses/types.d.ts +0 -12
  50. package/dist/live-streams/index.d.ts +0 -80
  51. package/dist/live-streams/types.d.ts +0 -14
  52. package/dist/playlists/index.d.ts +0 -204
  53. package/dist/playlists/types.d.ts +0 -26
  54. package/dist/podcasts/index.d.ts +0 -121
  55. package/dist/podcasts/types.d.ts +0 -79
  56. package/dist/preferences/index.d.ts +0 -80
  57. package/dist/preferences/types.d.ts +0 -18
  58. package/dist/shares/index.d.ts +0 -69
  59. package/dist/shares/types.d.ts +0 -23
  60. package/dist/shouts/index.d.ts +0 -17
  61. package/dist/shouts/types.d.ts +0 -10
  62. package/dist/songs/index.d.ts +0 -143
  63. package/dist/songs/types.d.ts +0 -73
  64. package/dist/system/index.d.ts +0 -407
  65. package/dist/system/types.d.ts +0 -24
  66. package/dist/users/index.d.ts +0 -190
  67. package/dist/users/types.d.ts +0 -34
  68. package/dist/utils.d.ts +0 -4
  69. package/dist/videos/index.d.ts +0 -33
  70. package/dist/videos/types.d.ts +0 -38
  71. package/src/albums/index.ts +0 -88
  72. package/src/albums/types.ts +0 -40
  73. package/src/artists/index.ts +0 -88
  74. package/src/artists/types.ts +0 -38
  75. package/src/auth/index.ts +0 -118
  76. package/src/auth/types.ts +0 -32
  77. package/src/base.ts +0 -133
  78. package/src/bookmarks/index.ts +0 -116
  79. package/src/bookmarks/types.ts +0 -15
  80. package/src/catalogs/index.ts +0 -130
  81. package/src/catalogs/types.ts +0 -27
  82. package/src/genres/index.ts +0 -39
  83. package/src/genres/types.ts +0 -25
  84. package/src/index.ts +0 -63
  85. package/src/labels/index.ts +0 -43
  86. package/src/labels/types.ts +0 -20
  87. package/src/licenses/index.ts +0 -43
  88. package/src/licenses/types.ts +0 -14
  89. package/src/live-streams/index.ts +0 -104
  90. package/src/live-streams/types.ts +0 -16
  91. package/src/playlists/index.ts +0 -280
  92. package/src/playlists/types.ts +0 -29
  93. package/src/podcasts/index.ts +0 -174
  94. package/src/podcasts/types.ts +0 -85
  95. package/src/preferences/index.ts +0 -114
  96. package/src/preferences/types.ts +0 -20
  97. package/src/shares/index.ts +0 -100
  98. package/src/shares/types.ts +0 -25
  99. package/src/shouts/index.ts +0 -18
  100. package/src/shouts/types.ts +0 -11
  101. package/src/songs/index.ts +0 -221
  102. package/src/songs/types.ts +0 -77
  103. package/src/system/index.ts +0 -845
  104. package/src/system/types.ts +0 -42
  105. package/src/users/index.ts +0 -227
  106. package/src/users/types.ts +0 -38
  107. package/src/videos/index.ts +0 -49
  108. 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
+ };