javascript-ampache 1.1.3 → 1.1.5

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.
@@ -1,221 +1,221 @@
1
- import qs from "querystringify";
2
- import { SongResponse, SongsResponse, DeletedSongsResponse } from "./types";
3
- import {
4
- Base,
5
- BinaryBoolean,
6
- ExtendedPagination,
7
- Pagination,
8
- Success,
9
- UID,
10
- } from "../base";
11
-
12
- export class Songs extends Base {
13
- /**
14
- * Returns songs based on the specified filter
15
- * @remarks MINIMUM_API_VERSION=380001
16
- * @param [params.filter] Filter results to match this string
17
- * @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
18
- * @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
19
- * @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
20
- * @param [params.offset]
21
- * @param [params.limit]
22
- * @param [params.cond]
23
- * @param [params.sort]
24
- * @see {@link https://ampache.org/api/api-json-methods#songs}
25
- */
26
- songs(
27
- params?: {
28
- filter?: string;
29
- exact?: BinaryBoolean;
30
- add?: Date;
31
- update?: Date;
32
- } & ExtendedPagination,
33
- ) {
34
- let query = "songs";
35
- query += qs.stringify(params, "&");
36
- return this.request<SongsResponse>(query);
37
- }
38
-
39
- /**
40
- * Returns a single song
41
- * @remarks MINIMUM_API_VERSION=380001
42
- * @param params.filter UID to find
43
- * @see {@link https://ampache.org/api/api-json-methods#song}
44
- */
45
- song(params: { filter: UID }) {
46
- let query = "song";
47
- query += qs.stringify(params, "&");
48
- return this.request<SongResponse>(query);
49
- }
50
-
51
- /**
52
- * Songs of the specified artist
53
- * @remarks MINIMUM_API_VERSION=380001
54
- * @param params.filter UID to find
55
- * @param [params.top50] 0, 1 (if true filter to the artist top 50)
56
- * @param [params.offset]
57
- * @param [params.limit]
58
- * @param [params.cond]
59
- * @param [params.sort]
60
- * @see {@link https://ampache.org/api/api-json-methods#artist_songs}
61
- */
62
- artistSongs(
63
- params: {
64
- filter: UID;
65
- top50?: BinaryBoolean;
66
- } & ExtendedPagination,
67
- ) {
68
- let query = "artist_songs";
69
- query += qs.stringify(params, "&");
70
- return this.request<SongsResponse>(query);
71
- }
72
-
73
- /**
74
- * Songs of the specified album
75
- * @remarks MINIMUM_API_VERSION=380001
76
- * @param params.filter UID to find
77
- * @param [params.offset]
78
- * @param [params.limit]
79
- * @param [params.cond]
80
- * @param [params.sort]
81
- * @see {@link https://ampache.org/api/api-json-methods#album_songs}
82
- */
83
- albumSongs(
84
- params: {
85
- filter: UID;
86
- } & ExtendedPagination,
87
- ) {
88
- let query = "album_songs";
89
- query += qs.stringify(params, "&");
90
- return this.request<SongsResponse>(query);
91
- }
92
-
93
- /**
94
- * Songs of the specified genre
95
- * @remarks MINIMUM_API_VERSION=380001
96
- * @param params.filter UID to find
97
- * @param [params.offset]
98
- * @param [params.limit]
99
- * @param [params.cond]
100
- * @param [params.sort]
101
- * @see {@link https://ampache.org/api/api-json-methods#genre_songs}
102
- */
103
- genreSongs(
104
- params: {
105
- filter: UID;
106
- } & ExtendedPagination,
107
- ) {
108
- let query = "genre_songs";
109
- query += qs.stringify(params, "&");
110
- return this.request<SongsResponse>(query);
111
- }
112
-
113
- /**
114
- * This returns the songs for a playlist
115
- * @remarks MINIMUM_API_VERSION=380001
116
- * @param params.filter UID to find
117
- * @param [params.random] 0, 1 (if true get random songs using limit)
118
- * @param [params.offset]
119
- * @param [params.limit]
120
- * @see {@link https://ampache.org/api/api-json-methods#playlist_songs}
121
- */
122
- playlistSongs(
123
- params: {
124
- filter: UID;
125
- random?: BinaryBoolean;
126
- } & Pagination,
127
- ) {
128
- let query = "playlist_songs";
129
- query += qs.stringify(params, "&");
130
- return this.request<SongsResponse>(query);
131
- }
132
-
133
- /**
134
- * This returns the songs for a license
135
- * @remarks MINIMUM_API_VERSION=420000
136
- * @param params.filter UID to find
137
- * @param [params.offset]
138
- * @param [params.limit]
139
- * @param [params.cond]
140
- * @param [params.sort]
141
- * @see {@link https://ampache.org/api/api-json-methods#license_songs}
142
- */
143
- licenseSongs(
144
- params: {
145
- filter: UID;
146
- } & ExtendedPagination,
147
- ) {
148
- let query = "license_songs";
149
- query += qs.stringify(params, "&");
150
- return this.request<SongsResponse>(query);
151
- }
152
-
153
- /**
154
- * Delete an existing song. (if you are allowed to)
155
- * @remarks MINIMUM_API_VERSION=5.0.0
156
- * @param params.filter UID of song to delete
157
- * @see {@link https://ampache.org/api/api-json-methods#song_delete}
158
- */
159
- songDelete(params: { filter: UID }) {
160
- let query = "song_delete";
161
- query += qs.stringify(params, "&");
162
- return this.request<Success>(query);
163
- }
164
-
165
- /**
166
- * Get the full song file tags using VaInfo
167
- * This is used to get tags for remote catalogs to allow maximum data to be returned
168
- * @remarks MINIMUM_API_VERSION=7.5.0
169
- * @param params.filter UID of song to fetch
170
- * @see {@link https://ampache.org/api/api-json-methods#song_tags}
171
- */
172
- // songTags(params: { filter: UID }) {
173
- // let query = "song_tags";
174
- // query += qs.stringify(params, "&");
175
- // return this.request<SongResponse>(query); // TODO update reponse
176
- // }
177
-
178
- /**
179
- * This takes a URL and returns the song object in question
180
- * @remarks MINIMUM_API_VERSION=380001
181
- * @param params.url Full Ampache URL from server
182
- * @see {@link https://ampache.org/api/api-json-methods#url_to_song}
183
- */
184
- urlToSong(params: { url: string }) {
185
- let query = "url_to_song";
186
- params.url = encodeURIComponent(params.url);
187
- query += qs.stringify(params, "&");
188
- return this.request<SongResponse>(query);
189
- }
190
-
191
- /**
192
- * This searches the songs and returns... songs
193
- * @remarks MINIMUM_API_VERSION=380001
194
- * @param params.filter Filter results to match this string
195
- * @param [params.offset]
196
- * @param [params.limit]
197
- * @see {@link https://ampache.org/api/api-json-methods#search_songs}
198
- */
199
- searchSongs(
200
- params: {
201
- filter: string;
202
- } & Pagination,
203
- ) {
204
- let query = "search_songs";
205
- query += qs.stringify(params, "&");
206
- return this.request<SongsResponse>(query);
207
- }
208
-
209
- /**
210
- * Returns songs that have been deleted from the server
211
- * @remarks MINIMUM_API_VERSION=500000
212
- * @param [params.offset]
213
- * @param [params.limit]
214
- * @see {@link https://ampache.org/api/api-json-methods#deleted_songs}
215
- */
216
- deletedSongs(params?: {} & Pagination) {
217
- let query = "deleted_songs";
218
- query += qs.stringify(params, "&");
219
- return this.request<DeletedSongsResponse>(query);
220
- }
221
- }
1
+ import qs from "querystringify";
2
+ import { SongResponse, SongsResponse, DeletedSongsResponse } from "./types";
3
+ import {
4
+ Base,
5
+ BinaryBoolean,
6
+ ExtendedPagination,
7
+ Pagination,
8
+ Success,
9
+ UID,
10
+ } from "../base";
11
+
12
+ export class Songs extends Base {
13
+ /**
14
+ * Returns songs based on the specified filter
15
+ * @remarks MINIMUM_API_VERSION=380001
16
+ * @param [params.filter] Filter results to match this string
17
+ * @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
18
+ * @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
19
+ * @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
20
+ * @param [params.offset]
21
+ * @param [params.limit]
22
+ * @param [params.cond]
23
+ * @param [params.sort]
24
+ * @see {@link https://ampache.org/api/api-json-methods#songs}
25
+ */
26
+ songs(
27
+ params?: {
28
+ filter?: string;
29
+ exact?: BinaryBoolean;
30
+ add?: Date;
31
+ update?: Date;
32
+ } & ExtendedPagination,
33
+ ) {
34
+ let query = "songs";
35
+ query += qs.stringify(params, "&");
36
+ return this.request<SongsResponse>(query);
37
+ }
38
+
39
+ /**
40
+ * Returns a single song
41
+ * @remarks MINIMUM_API_VERSION=380001
42
+ * @param params.filter UID to find
43
+ * @see {@link https://ampache.org/api/api-json-methods#song}
44
+ */
45
+ song(params: { filter: UID }) {
46
+ let query = "song";
47
+ query += qs.stringify(params, "&");
48
+ return this.request<SongResponse>(query);
49
+ }
50
+
51
+ /**
52
+ * Songs of the specified artist
53
+ * @remarks MINIMUM_API_VERSION=380001
54
+ * @param params.filter UID to find
55
+ * @param [params.top50] 0, 1 (if true filter to the artist top 50)
56
+ * @param [params.offset]
57
+ * @param [params.limit]
58
+ * @param [params.cond]
59
+ * @param [params.sort]
60
+ * @see {@link https://ampache.org/api/api-json-methods#artist_songs}
61
+ */
62
+ artistSongs(
63
+ params: {
64
+ filter: UID;
65
+ top50?: BinaryBoolean;
66
+ } & ExtendedPagination,
67
+ ) {
68
+ let query = "artist_songs";
69
+ query += qs.stringify(params, "&");
70
+ return this.request<SongsResponse>(query);
71
+ }
72
+
73
+ /**
74
+ * Songs of the specified album
75
+ * @remarks MINIMUM_API_VERSION=380001
76
+ * @param params.filter UID to find
77
+ * @param [params.offset]
78
+ * @param [params.limit]
79
+ * @param [params.cond]
80
+ * @param [params.sort]
81
+ * @see {@link https://ampache.org/api/api-json-methods#album_songs}
82
+ */
83
+ albumSongs(
84
+ params: {
85
+ filter: UID;
86
+ } & ExtendedPagination,
87
+ ) {
88
+ let query = "album_songs";
89
+ query += qs.stringify(params, "&");
90
+ return this.request<SongsResponse>(query);
91
+ }
92
+
93
+ /**
94
+ * Songs of the specified genre
95
+ * @remarks MINIMUM_API_VERSION=380001
96
+ * @param params.filter UID to find
97
+ * @param [params.offset]
98
+ * @param [params.limit]
99
+ * @param [params.cond]
100
+ * @param [params.sort]
101
+ * @see {@link https://ampache.org/api/api-json-methods#genre_songs}
102
+ */
103
+ genreSongs(
104
+ params: {
105
+ filter: UID;
106
+ } & ExtendedPagination,
107
+ ) {
108
+ let query = "genre_songs";
109
+ query += qs.stringify(params, "&");
110
+ return this.request<SongsResponse>(query);
111
+ }
112
+
113
+ /**
114
+ * This returns the songs for a playlist
115
+ * @remarks MINIMUM_API_VERSION=380001
116
+ * @param params.filter UID to find
117
+ * @param [params.random] 0, 1 (if true get random songs using limit)
118
+ * @param [params.offset]
119
+ * @param [params.limit]
120
+ * @see {@link https://ampache.org/api/api-json-methods#playlist_songs}
121
+ */
122
+ playlistSongs(
123
+ params: {
124
+ filter: UID;
125
+ random?: BinaryBoolean;
126
+ } & Pagination,
127
+ ) {
128
+ let query = "playlist_songs";
129
+ query += qs.stringify(params, "&");
130
+ return this.request<SongsResponse>(query);
131
+ }
132
+
133
+ /**
134
+ * This returns the songs for a license
135
+ * @remarks MINIMUM_API_VERSION=420000
136
+ * @param params.filter UID to find
137
+ * @param [params.offset]
138
+ * @param [params.limit]
139
+ * @param [params.cond]
140
+ * @param [params.sort]
141
+ * @see {@link https://ampache.org/api/api-json-methods#license_songs}
142
+ */
143
+ licenseSongs(
144
+ params: {
145
+ filter: UID;
146
+ } & ExtendedPagination,
147
+ ) {
148
+ let query = "license_songs";
149
+ query += qs.stringify(params, "&");
150
+ return this.request<SongsResponse>(query);
151
+ }
152
+
153
+ /**
154
+ * Delete an existing song. (if you are allowed to)
155
+ * @remarks MINIMUM_API_VERSION=5.0.0
156
+ * @param params.filter UID of song to delete
157
+ * @see {@link https://ampache.org/api/api-json-methods#song_delete}
158
+ */
159
+ songDelete(params: { filter: UID }) {
160
+ let query = "song_delete";
161
+ query += qs.stringify(params, "&");
162
+ return this.request<Success>(query);
163
+ }
164
+
165
+ /**
166
+ * Get the full song file tags using VaInfo
167
+ * This is used to get tags for remote catalogs to allow maximum data to be returned
168
+ * @remarks MINIMUM_API_VERSION=7.5.0
169
+ * @param params.filter UID of song to fetch
170
+ * @see {@link https://ampache.org/api/api-json-methods#song_tags}
171
+ */
172
+ // songTags(params: { filter: UID }) {
173
+ // let query = "song_tags";
174
+ // query += qs.stringify(params, "&");
175
+ // return this.request<SongResponse>(query); // TODO update reponse
176
+ // }
177
+
178
+ /**
179
+ * This takes a URL and returns the song object in question
180
+ * @remarks MINIMUM_API_VERSION=380001
181
+ * @param params.url Full Ampache URL from server
182
+ * @see {@link https://ampache.org/api/api-json-methods#url_to_song}
183
+ */
184
+ urlToSong(params: { url: string }) {
185
+ let query = "url_to_song";
186
+ params.url = encodeURIComponent(params.url);
187
+ query += qs.stringify(params, "&");
188
+ return this.request<SongResponse>(query);
189
+ }
190
+
191
+ /**
192
+ * This searches the songs and returns... songs
193
+ * @remarks MINIMUM_API_VERSION=380001
194
+ * @param params.filter Filter results to match this string
195
+ * @param [params.offset]
196
+ * @param [params.limit]
197
+ * @see {@link https://ampache.org/api/api-json-methods#search_songs}
198
+ */
199
+ searchSongs(
200
+ params: {
201
+ filter: string;
202
+ } & Pagination,
203
+ ) {
204
+ let query = "search_songs";
205
+ query += qs.stringify(params, "&");
206
+ return this.request<SongsResponse>(query);
207
+ }
208
+
209
+ /**
210
+ * Returns songs that have been deleted from the server
211
+ * @remarks MINIMUM_API_VERSION=500000
212
+ * @param [params.offset]
213
+ * @param [params.limit]
214
+ * @see {@link https://ampache.org/api/api-json-methods#deleted_songs}
215
+ */
216
+ deletedSongs(params?: {} & Pagination) {
217
+ let query = "deleted_songs";
218
+ query += qs.stringify(params, "&");
219
+ return this.request<DeletedSongsResponse>(query);
220
+ }
221
+ }