javascript-ampache 1.0.9 → 1.1.1

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 (86) hide show
  1. package/README.md +50 -47
  2. package/dist/albums/index.d.ts +7 -13
  3. package/dist/albums/types.d.ts +9 -4
  4. package/dist/artists/index.d.ts +8 -14
  5. package/dist/artists/types.d.ts +10 -5
  6. package/dist/auth/index.d.ts +1 -1
  7. package/dist/base.d.ts +5 -0
  8. package/dist/bookmarks/index.d.ts +20 -21
  9. package/dist/bookmarks/types.d.ts +7 -2
  10. package/dist/catalogs/index.d.ts +9 -11
  11. package/dist/catalogs/types.d.ts +8 -3
  12. package/dist/genres/index.d.ts +4 -6
  13. package/dist/genres/types.d.ts +6 -1
  14. package/dist/index.d.ts +19 -19
  15. package/dist/index.js +1 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.m.js +1 -1
  18. package/dist/index.m.js.map +1 -1
  19. package/dist/index.modern.mjs +1 -1
  20. package/dist/index.modern.mjs.map +1 -1
  21. package/dist/index.umd.js +1 -1
  22. package/dist/index.umd.js.map +1 -1
  23. package/dist/labels/index.d.ts +4 -6
  24. package/dist/labels/types.d.ts +6 -1
  25. package/dist/licenses/index.d.ts +4 -6
  26. package/dist/licenses/types.d.ts +6 -1
  27. package/dist/live-streams/index.d.ts +8 -10
  28. package/dist/live-streams/types.d.ts +6 -1
  29. package/dist/playlists/index.d.ts +15 -25
  30. package/dist/playlists/types.d.ts +7 -2
  31. package/dist/podcasts/index.d.ts +10 -16
  32. package/dist/podcasts/types.d.ts +20 -5
  33. package/dist/preferences/index.d.ts +8 -16
  34. package/dist/preferences/types.d.ts +6 -1
  35. package/dist/shares/index.d.ts +7 -9
  36. package/dist/shares/types.d.ts +6 -1
  37. package/dist/shouts/index.d.ts +4 -4
  38. package/dist/shouts/types.d.ts +1 -1
  39. package/dist/songs/index.d.ts +12 -28
  40. package/dist/songs/types.d.ts +12 -2
  41. package/dist/system/index.d.ts +24 -24
  42. package/dist/system/types.d.ts +9 -9
  43. package/dist/users/index.d.ts +10 -10
  44. package/dist/users/types.d.ts +7 -2
  45. package/dist/videos/index.d.ts +5 -9
  46. package/dist/videos/types.d.ts +12 -2
  47. package/package.json +38 -38
  48. package/src/albums/index.ts +86 -86
  49. package/src/albums/types.ts +38 -32
  50. package/src/artists/index.ts +88 -88
  51. package/src/artists/types.ts +38 -32
  52. package/src/auth/index.ts +103 -103
  53. package/src/auth/types.ts +25 -25
  54. package/src/base.ts +134 -119
  55. package/src/bookmarks/index.ts +116 -122
  56. package/src/bookmarks/types.ts +15 -9
  57. package/src/catalogs/index.ts +130 -119
  58. package/src/catalogs/types.ts +27 -15
  59. package/src/genres/index.ts +39 -40
  60. package/src/genres/types.ts +23 -17
  61. package/src/index.ts +63 -26
  62. package/src/labels/index.ts +43 -44
  63. package/src/labels/types.ts +20 -14
  64. package/src/licenses/index.ts +43 -44
  65. package/src/licenses/types.ts +14 -8
  66. package/src/live-streams/index.ts +104 -107
  67. package/src/live-streams/types.ts +16 -10
  68. package/src/playlists/index.ts +262 -269
  69. package/src/playlists/types.ts +20 -14
  70. package/src/podcasts/index.ts +174 -177
  71. package/src/podcasts/types.ts +85 -67
  72. package/src/preferences/index.ts +114 -116
  73. package/src/preferences/types.ts +18 -12
  74. package/src/shares/index.ts +100 -96
  75. package/src/shares/types.ts +25 -19
  76. package/src/shouts/index.ts +18 -22
  77. package/src/shouts/types.ts +9 -9
  78. package/src/songs/index.ts +208 -203
  79. package/src/songs/types.ts +77 -65
  80. package/src/system/index.ts +689 -572
  81. package/src/system/types.ts +33 -19
  82. package/src/users/index.ts +227 -245
  83. package/src/users/types.ts +38 -32
  84. package/src/utils.ts +25 -25
  85. package/src/videos/index.ts +49 -53
  86. package/src/videos/types.ts +42 -30
@@ -1,269 +1,262 @@
1
- import qs from 'querystringify';
2
- import { Playlist } from './types';
3
- import { Song } from "../songs/types";
4
- import {Base, BinaryBoolean, ExtendedPagination, Pagination, Success, UID} from '../base';
5
-
6
- export class Playlists extends Base {
7
- /**
8
- * This returns playlists based on the specified filter
9
- * @remarks MINIMUM_API_VERSION=380001
10
- * @param [params.filter] Filter results to match this string
11
- * @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
12
- * @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
13
- * @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
14
- * @param [params.hide_search] 0, 1 (if true do not include searches/smartlists in the result)
15
- * @param [params.show_dupes] 0, 1 (if true ignore 'api_hide_dupe_searches' setting)
16
- * @param [params.offset]
17
- * @param [params.limit]
18
- * @param [params.cond]
19
- * @param [params.sort]
20
- * @see {@link https://ampache.org/api/api-json-methods#playlists}
21
- */
22
- async playlists (params?: {
23
- filter?: string,
24
- exact?: BinaryBoolean,
25
- add?: Date,
26
- update?: Date,
27
- hide_search?: BinaryBoolean,
28
- show_dupes?: BinaryBoolean,
29
- } & ExtendedPagination) {
30
- let query = 'playlists';
31
- query += qs.stringify(params, '&');
32
- let data = await this.request<{playlist: Playlist[]}>(query);
33
- return (data.playlist) ? data.playlist : data;
34
- }
35
-
36
- /**
37
- * This returns smartlists based on the specified filter. NOTE: Filtered from Playlists() so pagination is invalid.
38
- * @remarks MINIMUM_API_VERSION=380001
39
- * @param [params.filter] Filter results to match this string
40
- * @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
41
- * @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
42
- * @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
43
- * @param [params.show_dupes] 0, 1 (if true ignore 'api_hide_dupe_searches' setting)
44
- * @see {@link https://ampache.org/api/api-json-methods#playlists}
45
- */
46
- async smartlists (params?: {
47
- filter?: string,
48
- exact?: BinaryBoolean,
49
- add?: Date,
50
- update?: Date,
51
- show_dupes?: BinaryBoolean,
52
- }) {
53
- let query = 'playlists';
54
- query += qs.stringify(params, '&');
55
- let data = await this.request<{playlist: Playlist[]}>(query);
56
-
57
- let results = (data.playlist) ? data.playlist : data;
58
-
59
- // filter out regular playlists
60
- if (Array.isArray(results)) {
61
- results = results.filter(function(item) {
62
- return item.id.toString().match(/^smart_/);
63
- })
64
- }
65
-
66
- return results;
67
- }
68
-
69
- /**
70
- * This returns a single playlist
71
- * @remarks MINIMUM_API_VERSION=380001
72
- * @param params.filter UID to find
73
- * @see {@link https://ampache.org/api/api-json-methods#playlist}
74
- */
75
- playlist (params: {
76
- filter: UID
77
- }) {
78
- let query = 'playlist';
79
- query += qs.stringify(params, '&');
80
- return this.request<Playlist>(query);
81
- }
82
-
83
- /**
84
- * This returns a user's playlists based on the specified filter
85
- * @remarks MINIMUM_API_VERSION=6.3.0
86
- * @param [params.filter] Filter results to match this string
87
- * @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
88
- * @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
89
- * @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
90
- * @param [params.offset]
91
- * @param [params.limit]
92
- * @param [params.cond]
93
- * @param [params.sort]
94
- * @see {@link https://ampache.org/api/api-json-methods#user_playlists}
95
- */
96
- async userPlaylists (params?: {
97
- filter?: string,
98
- exact?: BinaryBoolean,
99
- add?: Date,
100
- update?: Date,
101
- } & ExtendedPagination) {
102
- let query = 'user_playlists';
103
- query += qs.stringify(params, '&');
104
- let data = await this.request<{playlist: Playlist[]}>(query);
105
- return (data.playlist) ? data.playlist : data;
106
- }
107
-
108
- /**
109
- * This returns a user's smartlists based on the specified filter
110
- * @remarks MINIMUM_API_VERSION=6.3.0
111
- * @param [params.filter] Filter results to match this string
112
- * @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
113
- * @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
114
- * @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
115
- * @param [params.offset]
116
- * @param [params.limit]
117
- * @param [params.cond]
118
- * @param [params.sort]
119
- * @see {@link https://ampache.org/api/api-json-methods#user_smartlists}
120
- */
121
- async userSmartlists (params?: {
122
- filter?: string,
123
- exact?: BinaryBoolean,
124
- add?: Date,
125
- update?: Date,
126
- } & ExtendedPagination) {
127
- let query = 'user_smartlists';
128
- query += qs.stringify(params, '&');
129
- let data = await this.request<{playlist: Playlist[]}>(query);
130
- return (data.playlist) ? data.playlist : data;
131
- }
132
-
133
- /**
134
- * This creates a new playlist and returns it
135
- * @remarks MINIMUM_API_VERSION=380001
136
- * @param params.name Playlist name
137
- * @param [params.type] public, private (Playlist type)
138
- * @see {@link https://ampache.org/api/api-json-methods#playlist_create}
139
- */
140
- playlistCreate (params: {
141
- name: string,
142
- type?: 'public' | 'private',
143
- }) {
144
- let query = 'playlist_create';
145
- query += qs.stringify(params, '&');
146
- return this.request<Playlist>(query);
147
- }
148
-
149
- /**
150
- * This adds an item to a playlist
151
- * @remarks MINIMUM_API_VERSION=6.3.0
152
- * @param params.filter UID of Playlist
153
- * @param params.id UID of the object to add to playlist
154
- * @param params.type 'song', 'album', 'artist', 'playlist'
155
- * @see {@link https://ampache.org/api/api-json-methods#playlist_add}
156
- */
157
- playlistAdd (params: {
158
- filter: UID,
159
- id: UID,
160
- type: 'song' | 'album' | 'artist' | 'playlist',
161
- }) {
162
- let query = 'playlist_add';
163
- query += qs.stringify(params, '&');
164
- return this.request<Success>(query);
165
- }
166
-
167
- /**
168
- * This modifies name and type of the playlist.
169
- * NOTE items and tracks must be sent together and be of equal length.
170
- * @remarks MINIMUM_API_VERSION=400001
171
- * @param params.filter UID to find
172
- * @param [params.name] Playlist name
173
- * @param [params.type] public, private (Playlist type)
174
- * @param [params.owner] Change playlist owner to the user id (-1 = System playlist)
175
- * @param [params.items] comma-separated song_id's (replaces existing items with a new id)
176
- * @param [params.tracks] comma-separated playlisttrack numbers matched to 'items' in order
177
- * @see {@link https://ampache.org/api/api-json-methods#playlist_edit}
178
- */
179
- playlistEdit (params: {
180
- filter: UID,
181
- name?: string,
182
- type?: 'public' | 'private',
183
- owner?: string,
184
- items?: string,
185
- tracks?: string,
186
- }) {
187
- let query = 'playlist_edit';
188
- query += qs.stringify(params, '&');
189
- return this.request<Success>(query);
190
- }
191
-
192
- /**
193
- * This deletes a playlist
194
- * @remarks MINIMUM_API_VERSION=380001
195
- * @param params.filter UID of playlist to delete
196
- * @see {@link https://ampache.org/api/api-json-methods#playlist_delete}
197
- */
198
- playlistDelete (params: {
199
- filter: UID,
200
- }) {
201
- let query = 'playlist_delete';
202
- query += qs.stringify(params, '&');
203
- return this.request<Success>(query);
204
- }
205
-
206
- /**
207
- * This adds a song to a playlist
208
- * @remarks MINIMUM_API_VERSION=380001; CHANGED_IN_API_VERSION=400003
209
- * @param params.filter UID of Playlist
210
- * @param params.song UID of song to add to playlist
211
- * @param [params.check] 0, 1 Whether to check and ignore duplicates (default = 0)
212
- * @see {@link https://ampache.org/api/api-json-methods#playlist_add_song}
213
- * @deprecated Being removed in 7.0.0. Use `playlist_add` instead.
214
- */
215
- playlistAddSong (params: {
216
- filter: UID,
217
- song: UID,
218
- check?: BinaryBoolean,
219
- }) {
220
- let query = 'playlist_add_song';
221
- query += qs.stringify(params, '&');
222
- return this.request<Success>(query);
223
- }
224
-
225
- /**
226
- * This remove a song from a playlist
227
- * @remarks MINIMUM_API_VERSION=380001; CHANGED_IN_API_VERSION=400001
228
- * @param params.filter UID of Playlist
229
- * @param [params.song] UID of song to remove from playlist
230
- * @param [params.track] Track number to remove from playlist
231
- * @see {@link https://ampache.org/api/api-json-methods#playlist_remove_song}
232
- */
233
- playlistRemoveSong (params: {
234
- filter: UID,
235
- song?: UID,
236
- track?: number,
237
- }) {
238
- let query = 'playlist_remove_song';
239
- query += qs.stringify(params, '&');
240
- return this.request<Success>(query);
241
- }
242
-
243
- /**
244
- * Get a list of song JSON, indexes or id's based on some simple search criteria
245
- * @remarks MINIMUM_API_VERSION=400001; CHANGED_IN_API_VERSION=400002; 'recent' will search for tracks played after 'Popular Threshold' days; 'forgotten' will search for tracks played before 'Popular Threshold' days; 'unplayed' added in 400002 for searching unplayed tracks
246
- * @param [params.mode] (default = 'random')
247
- * @param [params.filter] string LIKE matched to song title
248
- * @param [params.album] UID of album
249
- * @param [params.artist] UID of artist
250
- * @param [params.flag] 0, 1 (get flagged songs only. default = 0)
251
- * @param [params.format] song, index, id (default = 'song')
252
- * @param [params.offset]
253
- * @param [params.limit]
254
- * @see {@link https://ampache.org/api/api-json-methods#playlist_generate}
255
- */
256
- async playlistGenerate (params?: {
257
- mode?: 'recent' | 'forgotten' | 'unplayed' | 'random',
258
- filter?: string,
259
- album?: number,
260
- artist?: number,
261
- flag?: BinaryBoolean,
262
- format?: 'song' | 'index' | 'id',
263
- } & Pagination) {
264
- let query = 'playlist_generate';
265
- query += qs.stringify(params, '&');
266
- let data = await this.request<{song: Song[]}>(query);
267
- return (data.song) ? data.song : data;
268
- }
269
- }
1
+ import qs from "querystringify";
2
+ import { PlaylistResponse, PlaylistsResponse } from "./types";
3
+ import { SongsResponse } from "../songs/types";
4
+ import {
5
+ Base,
6
+ BinaryBoolean,
7
+ ExtendedPagination,
8
+ Pagination,
9
+ Success,
10
+ UID,
11
+ } from "../base";
12
+
13
+ export class Playlists extends Base {
14
+ /**
15
+ * This returns playlists based on the specified filter
16
+ * @remarks MINIMUM_API_VERSION=380001
17
+ * @param [params.filter] Filter results to match this string
18
+ * @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
19
+ * @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
20
+ * @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
21
+ * @param [params.hide_search] 0, 1 (if true do not include searches/smartlists in the result)
22
+ * @param [params.show_dupes] 0, 1 (if true ignore 'api_hide_dupe_searches' setting)
23
+ * @param [params.offset]
24
+ * @param [params.limit]
25
+ * @param [params.cond]
26
+ * @param [params.sort]
27
+ * @see {@link https://ampache.org/api/api-json-methods#playlists}
28
+ */
29
+ playlists(
30
+ params?: {
31
+ filter?: string;
32
+ exact?: BinaryBoolean;
33
+ add?: Date;
34
+ update?: Date;
35
+ hide_search?: BinaryBoolean;
36
+ show_dupes?: BinaryBoolean;
37
+ } & ExtendedPagination,
38
+ ) {
39
+ let query = "playlists";
40
+ query += qs.stringify(params, "&");
41
+ return this.request<PlaylistsResponse>(query);
42
+ }
43
+
44
+ /**
45
+ * This returns smartlists based on the specified filter. NOTE: Filtered from Playlists() so pagination is invalid.
46
+ * @remarks MINIMUM_API_VERSION=380001
47
+ * @param [params.filter] Filter results to match this string
48
+ * @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
49
+ * @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
50
+ * @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
51
+ * @param [params.show_dupes] 0, 1 (if true ignore 'api_hide_dupe_searches' setting)
52
+ * @see {@link https://ampache.org/api/api-json-methods#playlists}
53
+ */
54
+ smartlists(params?: {
55
+ filter?: string;
56
+ exact?: BinaryBoolean;
57
+ add?: Date;
58
+ update?: Date;
59
+ show_dupes?: BinaryBoolean;
60
+ }) {
61
+ let query = "playlists";
62
+ query += qs.stringify(params, "&");
63
+ return this.request<PlaylistsResponse>(query).then((response) => {
64
+ // filter out regular playlists
65
+ if (Array.isArray(response.playlist)) {
66
+ response.playlist = response.playlist.filter((item) =>
67
+ item.id.toString().startsWith("smart_"),
68
+ );
69
+ }
70
+ return response;
71
+ });
72
+ }
73
+
74
+ /**
75
+ * This returns a single playlist
76
+ * @remarks MINIMUM_API_VERSION=380001
77
+ * @param params.filter UID to find
78
+ * @see {@link https://ampache.org/api/api-json-methods#playlist}
79
+ */
80
+ playlist(params: { filter: UID }) {
81
+ let query = "playlist";
82
+ query += qs.stringify(params, "&");
83
+ return this.request<PlaylistResponse>(query);
84
+ }
85
+
86
+ /**
87
+ * This returns a user's playlists based on the specified filter
88
+ * @remarks MINIMUM_API_VERSION=6.3.0
89
+ * @param [params.filter] Filter results to match this string
90
+ * @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
91
+ * @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
92
+ * @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
93
+ * @param [params.offset]
94
+ * @param [params.limit]
95
+ * @param [params.cond]
96
+ * @param [params.sort]
97
+ * @see {@link https://ampache.org/api/api-json-methods#user_playlists}
98
+ */
99
+ userPlaylists(
100
+ params?: {
101
+ filter?: string;
102
+ exact?: BinaryBoolean;
103
+ add?: Date;
104
+ update?: Date;
105
+ } & ExtendedPagination,
106
+ ) {
107
+ let query = "user_playlists";
108
+ query += qs.stringify(params, "&");
109
+ return this.request<PlaylistsResponse>(query);
110
+ }
111
+
112
+ /**
113
+ * This returns a user's smartlists based on the specified filter
114
+ * @remarks MINIMUM_API_VERSION=6.3.0
115
+ * @param [params.filter] Filter results to match this string
116
+ * @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
117
+ * @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
118
+ * @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
119
+ * @param [params.offset]
120
+ * @param [params.limit]
121
+ * @param [params.cond]
122
+ * @param [params.sort]
123
+ * @see {@link https://ampache.org/api/api-json-methods#user_smartlists}
124
+ */
125
+ userSmartlists(
126
+ params?: {
127
+ filter?: string;
128
+ exact?: BinaryBoolean;
129
+ add?: Date;
130
+ update?: Date;
131
+ } & ExtendedPagination,
132
+ ) {
133
+ let query = "user_smartlists";
134
+ query += qs.stringify(params, "&");
135
+ return this.request<PlaylistsResponse>(query);
136
+ }
137
+
138
+ /**
139
+ * This creates a new playlist and returns it
140
+ * @remarks MINIMUM_API_VERSION=380001
141
+ * @param params.name Playlist name
142
+ * @param [params.type] public, private (Playlist type)
143
+ * @see {@link https://ampache.org/api/api-json-methods#playlist_create}
144
+ */
145
+ playlistCreate(params: { name: string; type?: "public" | "private" }) {
146
+ let query = "playlist_create";
147
+ query += qs.stringify(params, "&");
148
+ return this.request<PlaylistResponse>(query);
149
+ }
150
+
151
+ /**
152
+ * This adds an item to a playlist
153
+ * @remarks MINIMUM_API_VERSION=6.3.0
154
+ * @param params.filter UID of Playlist
155
+ * @param params.id UID of the object to add to playlist
156
+ * @param params.type 'song', 'album', 'artist', 'playlist'
157
+ * @see {@link https://ampache.org/api/api-json-methods#playlist_add}
158
+ */
159
+ playlistAdd(params: {
160
+ filter: UID;
161
+ id: UID;
162
+ type: "song" | "album" | "artist" | "playlist";
163
+ }) {
164
+ let query = "playlist_add";
165
+ query += qs.stringify(params, "&");
166
+ return this.request<Success>(query);
167
+ }
168
+
169
+ /**
170
+ * This modifies name and type of the playlist.
171
+ * NOTE items and tracks must be sent together and be of equal length.
172
+ * @remarks MINIMUM_API_VERSION=400001
173
+ * @param params.filter UID to find
174
+ * @param [params.name] Playlist name
175
+ * @param [params.type] public, private (Playlist type)
176
+ * @param [params.owner] Change playlist owner to the user id (-1 = System playlist)
177
+ * @param [params.items] comma-separated song_id's (replaces existing items with a new id)
178
+ * @param [params.tracks] comma-separated playlisttrack numbers matched to 'items' in order
179
+ * @see {@link https://ampache.org/api/api-json-methods#playlist_edit}
180
+ */
181
+ playlistEdit(params: {
182
+ filter: UID;
183
+ name?: string;
184
+ type?: "public" | "private";
185
+ owner?: string;
186
+ items?: string;
187
+ tracks?: string;
188
+ }) {
189
+ let query = "playlist_edit";
190
+ query += qs.stringify(params, "&");
191
+ return this.request<Success>(query);
192
+ }
193
+
194
+ /**
195
+ * This deletes a playlist
196
+ * @remarks MINIMUM_API_VERSION=380001
197
+ * @param params.filter UID of playlist to delete
198
+ * @see {@link https://ampache.org/api/api-json-methods#playlist_delete}
199
+ */
200
+ playlistDelete(params: { filter: UID }) {
201
+ let query = "playlist_delete";
202
+ query += qs.stringify(params, "&");
203
+ return this.request<Success>(query);
204
+ }
205
+
206
+ /**
207
+ * This adds a song to a playlist
208
+ * @remarks MINIMUM_API_VERSION=380001; CHANGED_IN_API_VERSION=400003
209
+ * @param params.filter UID of Playlist
210
+ * @param params.song UID of song to add to playlist
211
+ * @param [params.check] 0, 1 Whether to check and ignore duplicates (default = 0)
212
+ * @see {@link https://ampache.org/api/api-json-methods#playlist_add_song}
213
+ * @deprecated Being removed in 7.0.0. Use `playlist_add` instead.
214
+ */
215
+ playlistAddSong(params: { filter: UID; song: UID; check?: BinaryBoolean }) {
216
+ let query = "playlist_add_song";
217
+ query += qs.stringify(params, "&");
218
+ return this.request<Success>(query);
219
+ }
220
+
221
+ /**
222
+ * This remove a song from a playlist
223
+ * @remarks MINIMUM_API_VERSION=380001; CHANGED_IN_API_VERSION=400001
224
+ * @param params.filter UID of Playlist
225
+ * @param [params.song] UID of song to remove from playlist
226
+ * @param [params.track] Track number to remove from playlist
227
+ * @see {@link https://ampache.org/api/api-json-methods#playlist_remove_song}
228
+ */
229
+ playlistRemoveSong(params: { filter: UID; song?: UID; track?: number }) {
230
+ let query = "playlist_remove_song";
231
+ query += qs.stringify(params, "&");
232
+ return this.request<Success>(query);
233
+ }
234
+
235
+ /**
236
+ * Get a list of song JSON, indexes or id's based on some simple search criteria
237
+ * @remarks MINIMUM_API_VERSION=400001; CHANGED_IN_API_VERSION=400002; 'recent' will search for tracks played after 'Popular Threshold' days; 'forgotten' will search for tracks played before 'Popular Threshold' days; 'unplayed' added in 400002 for searching unplayed tracks
238
+ * @param [params.mode] (default = 'random')
239
+ * @param [params.filter] string LIKE matched to song title
240
+ * @param [params.album] UID of album
241
+ * @param [params.artist] UID of artist
242
+ * @param [params.flag] 0, 1 (get flagged songs only. default = 0)
243
+ * @param [params.format] song, index, id (default = 'song')
244
+ * @param [params.offset]
245
+ * @param [params.limit]
246
+ * @see {@link https://ampache.org/api/api-json-methods#playlist_generate}
247
+ */
248
+ playlistGenerate(
249
+ params?: {
250
+ mode?: "recent" | "forgotten" | "unplayed" | "random";
251
+ filter?: string;
252
+ album?: number;
253
+ artist?: number;
254
+ flag?: BinaryBoolean;
255
+ format?: "song" | "index" | "id";
256
+ } & Pagination,
257
+ ) {
258
+ let query = "playlist_generate";
259
+ query += qs.stringify(params, "&");
260
+ return this.request<SongsResponse>(query);
261
+ }
262
+ }
@@ -1,14 +1,20 @@
1
- import { UID } from "../base";
2
-
3
- export type Playlist = {
4
- id: UID,
5
- name: string,
6
- owner: string,
7
- items: number,
8
- type: 'public' | 'private',
9
- art: string,
10
- has_art: boolean,
11
- flag: boolean,
12
- rating: number | null,
13
- averagerating: number | null,
14
- }
1
+ import { UID } from "../base";
2
+
3
+ export type PlaylistResponse = {
4
+ id: UID;
5
+ name: string;
6
+ owner: string;
7
+ items: number;
8
+ type: "public" | "private";
9
+ art: string;
10
+ has_art: boolean;
11
+ flag: boolean;
12
+ rating: number | null;
13
+ averagerating: number | null;
14
+ };
15
+
16
+ export type PlaylistsResponse = {
17
+ total_count: number;
18
+ md5: string;
19
+ playlist: PlaylistResponse[];
20
+ };