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