javascript-ampache 0.0.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.
- package/LICENSE +674 -0
- package/README.md +44 -0
- package/dist/albums/index.d.ts +62 -0
- package/dist/albums/types.d.ts +29 -0
- package/dist/artists/index.d.ts +64 -0
- package/dist/artists/types.d.ts +29 -0
- package/dist/auth/index.d.ts +47 -0
- package/dist/auth/types.d.ts +22 -0
- package/dist/base.d.ts +28 -0
- package/dist/bookmarks/index.d.ts +70 -0
- package/dist/bookmarks/types.d.ts +8 -0
- package/dist/catalogs/index.d.ts +51 -0
- package/dist/catalogs/types.d.ts +14 -0
- package/dist/genres/index.d.ts +30 -0
- package/dist/genres/types.d.ts +15 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.m.js +2 -0
- package/dist/index.m.js.map +1 -0
- package/dist/index.modern.js +2 -0
- package/dist/index.modern.js.map +1 -0
- package/dist/index.umd.js +2 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/labels/index.d.ts +32 -0
- package/dist/labels/types.d.ts +13 -0
- package/dist/licenses/index.d.ts +32 -0
- package/dist/licenses/types.d.ts +7 -0
- package/dist/live-streams/index.d.ts +32 -0
- package/dist/live-streams/types.d.ts +9 -0
- package/dist/playlists/index.d.ts +145 -0
- package/dist/playlists/types.d.ts +12 -0
- package/dist/podcasts/index.d.ts +125 -0
- package/dist/podcasts/types.d.ts +57 -0
- package/dist/preferences/index.d.ts +84 -0
- package/dist/preferences/types.d.ts +11 -0
- package/dist/shares/index.d.ts +69 -0
- package/dist/shares/types.d.ts +18 -0
- package/dist/shouts/index.d.ts +17 -0
- package/dist/shouts/types.d.ts +8 -0
- package/dist/songs/index.d.ts +140 -0
- package/dist/songs/types.d.ts +62 -0
- package/dist/system/index.d.ts +267 -0
- package/dist/system/types.d.ts +9 -0
- package/dist/users/index.d.ts +134 -0
- package/dist/users/types.d.ts +29 -0
- package/dist/utils.d.ts +2 -0
- package/dist/videos/index.d.ts +37 -0
- package/dist/videos/types.d.ts +27 -0
- package/package.json +40 -0
- package/src/albums/index.ts +80 -0
- package/src/albums/types.ts +31 -0
- package/src/artists/index.ts +82 -0
- package/src/artists/types.ts +31 -0
- package/src/auth/index.ts +91 -0
- package/src/auth/types.ts +22 -0
- package/src/base.ts +64 -0
- package/src/bookmarks/index.ts +94 -0
- package/src/bookmarks/types.ts +9 -0
- package/src/catalogs/index.ts +71 -0
- package/src/catalogs/types.ts +15 -0
- package/src/genres/index.ts +39 -0
- package/src/genres/types.ts +17 -0
- package/src/index.ts +26 -0
- package/src/labels/index.ts +42 -0
- package/src/labels/types.ts +14 -0
- package/src/licenses/index.ts +42 -0
- package/src/licenses/types.ts +8 -0
- package/src/live-streams/index.ts +42 -0
- package/src/live-streams/types.ts +10 -0
- package/src/playlists/index.ts +198 -0
- package/src/playlists/types.ts +13 -0
- package/src/podcasts/index.ts +174 -0
- package/src/podcasts/types.ts +60 -0
- package/src/preferences/index.ts +118 -0
- package/src/preferences/types.ts +12 -0
- package/src/shares/index.ts +94 -0
- package/src/shares/types.ts +19 -0
- package/src/shouts/index.ts +22 -0
- package/src/shouts/types.ts +9 -0
- package/src/songs/index.ts +191 -0
- package/src/songs/types.ts +64 -0
- package/src/system/index.ts +483 -0
- package/src/system/types.ts +11 -0
- package/src/users/index.ts +179 -0
- package/src/users/types.ts +32 -0
- package/src/utils.ts +25 -0
- package/src/videos/index.ts +53 -0
- package/src/videos/types.ts +29 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { Base, BinaryBoolean, Pagination, Success, UID } from '../base';
|
|
2
|
+
export declare class System extends Base {
|
|
3
|
+
/**
|
|
4
|
+
* Check Ampache for updates and run the update if there is one.
|
|
5
|
+
* @remarks MINIMUM_API_VERSION=5.0.0
|
|
6
|
+
* @see {@link https://ampache.org/api/api-json-methods#system_update}
|
|
7
|
+
*/
|
|
8
|
+
systemUpdate(): Promise<Success>;
|
|
9
|
+
/**
|
|
10
|
+
* This takes a collection of inputs and returns ID + name for the object type
|
|
11
|
+
* @remarks MINIMUM_API_VERSION=400001
|
|
12
|
+
* @param params.type type of object to find
|
|
13
|
+
* @param [params.filter] search the name of the object_type
|
|
14
|
+
* @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
|
|
15
|
+
* @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
|
|
16
|
+
* @param [params.include] 0, 1 (include songs in a playlist or episodes in a podcast)
|
|
17
|
+
* @param [params.hide_search] 0, 1 (if true do not include searches/smartlists in the result)
|
|
18
|
+
* @param [params.offset]
|
|
19
|
+
* @param [params.limit]
|
|
20
|
+
* @see {@link https://ampache.org/api/api-json-methods#get_indexes}
|
|
21
|
+
*/
|
|
22
|
+
getIndexes(params: {
|
|
23
|
+
type: 'song' | 'album' | 'artist' | 'album_artist' | 'playlist' | 'podcast' | 'podcast_episode' | 'live_stream';
|
|
24
|
+
filter?: string;
|
|
25
|
+
add?: Date;
|
|
26
|
+
update?: Date;
|
|
27
|
+
include?: BinaryBoolean;
|
|
28
|
+
hide_search?: number;
|
|
29
|
+
} & Pagination): Promise<any>;
|
|
30
|
+
/**
|
|
31
|
+
* Return similar artist IDs or similar song IDs compared to the input filter
|
|
32
|
+
* @remarks MINIMUM_API_VERSION=420000
|
|
33
|
+
* @param params.type type of object to check against
|
|
34
|
+
* @param params.filter UID to find
|
|
35
|
+
* @param [params.offset]
|
|
36
|
+
* @param [params.limit]
|
|
37
|
+
* @see {@link https://ampache.org/api/api-json-methods#get_similar}
|
|
38
|
+
*/
|
|
39
|
+
getSimilar(params: {
|
|
40
|
+
type: 'song' | 'artist';
|
|
41
|
+
filter: UID;
|
|
42
|
+
} & Pagination): Promise<any>;
|
|
43
|
+
/**
|
|
44
|
+
* Get some items based on some simple search types and filters. (Random by default)
|
|
45
|
+
* @remarks MINIMUM_API_VERSION=380001; CHANGED_IN_API_VERSION=400001
|
|
46
|
+
* @param params.type Object type
|
|
47
|
+
* @param [params.filter] newest, highest, frequent, recent, forgotten, flagged, random
|
|
48
|
+
* @param [params.user_id] Filter results to a certain user by UID
|
|
49
|
+
* @param [params.username] Filter results to a certain user by username
|
|
50
|
+
* @param [params.offset]
|
|
51
|
+
* @param [params.limit]
|
|
52
|
+
* @see {@link https://ampache.org/api/api-json-methods#stats}
|
|
53
|
+
*/
|
|
54
|
+
stats(params: {
|
|
55
|
+
type: 'song' | 'album' | 'artist' | 'video' | 'playlist' | 'podcast' | 'podcast_episode';
|
|
56
|
+
filter?: 'newest' | 'highest' | 'frequent' | 'recent' | 'forgotten' | 'flagged' | 'random';
|
|
57
|
+
user_id?: number;
|
|
58
|
+
username?: string;
|
|
59
|
+
} & Pagination): Promise<any>;
|
|
60
|
+
/**
|
|
61
|
+
* This rates a library item
|
|
62
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
63
|
+
* @param params.type Object type
|
|
64
|
+
* @param params.id UID to find
|
|
65
|
+
* @param params.rating Rating to apply
|
|
66
|
+
* @see {@link https://ampache.org/api/api-json-methods#rate}
|
|
67
|
+
*/
|
|
68
|
+
rate(params: {
|
|
69
|
+
type: 'song' | 'album' | 'artist' | 'playlist' | 'podcast' | 'podcast_episode' | 'video' | 'tvshow' | 'tvshow_season';
|
|
70
|
+
id: UID;
|
|
71
|
+
rating: 0 | 1 | 2 | 3 | 4 | 5;
|
|
72
|
+
}): Promise<Success>;
|
|
73
|
+
/**
|
|
74
|
+
* This flags a library item as a favorite
|
|
75
|
+
* @remarks MINIMUM_API_VERSION=400001
|
|
76
|
+
* @param params.type Object type
|
|
77
|
+
* @param params.id UID to find
|
|
78
|
+
* @param params.flag 0, 1
|
|
79
|
+
* @see {@link https://ampache.org/api/api-json-methods#flag}
|
|
80
|
+
*/
|
|
81
|
+
flag(params: {
|
|
82
|
+
type: 'song' | 'album' | 'artist' | 'playlist' | 'podcast' | 'podcast_episode' | 'video' | 'tvshow' | 'tvshow_season';
|
|
83
|
+
id: UID;
|
|
84
|
+
flag: BinaryBoolean;
|
|
85
|
+
}): Promise<Success>;
|
|
86
|
+
/**
|
|
87
|
+
* Take a song_id and update the object_count and user_activity table with a play. This allows other sources to record play history to Ampache.
|
|
88
|
+
* If you don't supply a user id (optional) then just fall back to you.
|
|
89
|
+
* ACCESS REQUIRED: 100 (Admin) permission to change another user's play history
|
|
90
|
+
* @remarks MINIMUM_API_VERSION=400001
|
|
91
|
+
* @param params.id UID of song
|
|
92
|
+
* @param [params.user] UID of user
|
|
93
|
+
* @param [params.client] Client string
|
|
94
|
+
* @param [params.date] UNIXTIME
|
|
95
|
+
* @see {@link https://ampache.org/api/api-json-methods#record_play}
|
|
96
|
+
*/
|
|
97
|
+
recordPlay(params: {
|
|
98
|
+
id: UID;
|
|
99
|
+
user?: UID;
|
|
100
|
+
client?: string;
|
|
101
|
+
date?: number;
|
|
102
|
+
}): Promise<Success>;
|
|
103
|
+
/**
|
|
104
|
+
* Search for a song using text info and then record a play if found. This allows other sources to record play history to ampache
|
|
105
|
+
* @remarks MINIMUM_API_VERSION=400001
|
|
106
|
+
* @param params.song HTML encoded string
|
|
107
|
+
* @param params.artist HTML encoded string
|
|
108
|
+
* @param params.album HTML encoded string
|
|
109
|
+
* @param [params.songmbid] Song MBID
|
|
110
|
+
* @param [params.artistmbid] Artist MBID
|
|
111
|
+
* @param [params.albummbid] Album MBID
|
|
112
|
+
* @param [params.song_mbid] Alias of songmbid
|
|
113
|
+
* @param [params.artist_mbid] Alias of artistmbid
|
|
114
|
+
* @param [params.album_mbid] Alias of albummbid
|
|
115
|
+
* @param [params.date] UNIXTIME
|
|
116
|
+
* @param [params.client] Client string
|
|
117
|
+
* @see {@link https://ampache.org/api/api-json-methods#scrobble}
|
|
118
|
+
*/
|
|
119
|
+
scrobble(params: {
|
|
120
|
+
song: string;
|
|
121
|
+
artist: string;
|
|
122
|
+
album: string;
|
|
123
|
+
songmbid?: string;
|
|
124
|
+
artistmbid?: string;
|
|
125
|
+
albummbid?: string;
|
|
126
|
+
song_mbid?: string;
|
|
127
|
+
artist_mbid?: string;
|
|
128
|
+
album_mbid?: string;
|
|
129
|
+
date?: number;
|
|
130
|
+
client?: string;
|
|
131
|
+
}): Promise<Success>;
|
|
132
|
+
/**
|
|
133
|
+
* Update a single album, artist, song from the tag data
|
|
134
|
+
* @remarks MINIMUM_API_VERSION=400001
|
|
135
|
+
* @param params.type Object type
|
|
136
|
+
* @param params.id UID to find
|
|
137
|
+
* @see {@link https://ampache.org/api/api-json-methods#update_from_tags}
|
|
138
|
+
*/
|
|
139
|
+
updateFromTags(params: {
|
|
140
|
+
type: 'song' | 'artist' | 'album';
|
|
141
|
+
id: UID;
|
|
142
|
+
}): Promise<Success>;
|
|
143
|
+
/**
|
|
144
|
+
* Update artist information and fetch similar artists from last.fm
|
|
145
|
+
* Make sure lastfm_API_key is set in your configuration file
|
|
146
|
+
* ACCESS REQUIRED: 75 (Catalog Manager)
|
|
147
|
+
* @remarks MINIMUM_API_VERSION=400001
|
|
148
|
+
* @param params.id UID to find
|
|
149
|
+
* @see {@link https://ampache.org/api/api-json-methods#update_artist_info}
|
|
150
|
+
*/
|
|
151
|
+
updateArtistInfo(params: {
|
|
152
|
+
id: UID;
|
|
153
|
+
}): Promise<Success>;
|
|
154
|
+
/**
|
|
155
|
+
* Updates a single album, artist, song running the gather_art process.
|
|
156
|
+
* Doesn't overwrite existing art by default.
|
|
157
|
+
* ACCESS REQUIRED: 75 (Catalog Manager)
|
|
158
|
+
* @remarks MINIMUM_API_VERSION=400001
|
|
159
|
+
* @param params.id UID to update
|
|
160
|
+
* @param params.type Object type
|
|
161
|
+
* @param [params.overwrite]
|
|
162
|
+
* @see {@link https://ampache.org/api/api-json-methods#update_art}
|
|
163
|
+
*/
|
|
164
|
+
updateArt(params: {
|
|
165
|
+
id: UID;
|
|
166
|
+
type: 'artist' | 'album' | 'song';
|
|
167
|
+
overwrite?: BinaryBoolean;
|
|
168
|
+
}): Promise<Success>;
|
|
169
|
+
/**
|
|
170
|
+
* Streams a given media file. Takes the file id in parameter with optional max bit rate, file format, time offset,
|
|
171
|
+
* size and estimate content length option.
|
|
172
|
+
* NOTE search and playlist will only stream a random object from the list.
|
|
173
|
+
* @remarks MINIMUM_API_VERSION=400001
|
|
174
|
+
* @param params.id UID to find
|
|
175
|
+
* @param params.type Object type
|
|
176
|
+
* @param [params.bitrate] Max bitrate for transcoding
|
|
177
|
+
* @param [params.format] mp3, ogg, raw, etc (raw returns the original format)
|
|
178
|
+
* @param [params.offset] Time offset
|
|
179
|
+
* @param [params.length] 0, 1 (estimate content length)
|
|
180
|
+
* @see {@link https://ampache.org/api/api-json-methods#stream}
|
|
181
|
+
*/
|
|
182
|
+
stream(params: {
|
|
183
|
+
id: UID;
|
|
184
|
+
type: 'song' | 'podcast_episode' | 'search' | 'playlist';
|
|
185
|
+
bitrate?: number;
|
|
186
|
+
format?: string;
|
|
187
|
+
offset?: number;
|
|
188
|
+
length?: BinaryBoolean;
|
|
189
|
+
}): Promise<unknown>;
|
|
190
|
+
/**
|
|
191
|
+
* Downloads a given media file. set format=raw to download the full file
|
|
192
|
+
* NOTE search and playlist will only download a random object from the list
|
|
193
|
+
* @remarks MINIMUM_API_VERSION=400001
|
|
194
|
+
* @param params.id UID to find
|
|
195
|
+
* @param params.type Object type
|
|
196
|
+
* @param [params.format] mp3, ogg, raw, etc (raw returns the original format)
|
|
197
|
+
* @see {@link https://ampache.org/api/api-json-methods#download}
|
|
198
|
+
*/
|
|
199
|
+
download(params: {
|
|
200
|
+
id: UID;
|
|
201
|
+
type: 'song' | 'podcast_episode' | 'search' | 'playlist';
|
|
202
|
+
format?: string;
|
|
203
|
+
}): Promise<unknown>;
|
|
204
|
+
/**
|
|
205
|
+
* Get an art image file.
|
|
206
|
+
* @remarks MINIMUM_API_VERSION=400001
|
|
207
|
+
* @param params.id UID to find
|
|
208
|
+
* @param params.type Object type
|
|
209
|
+
* @see {@link https://ampache.org/api/api-json-methods#get_art}
|
|
210
|
+
*/
|
|
211
|
+
getArt(params: {
|
|
212
|
+
id: UID;
|
|
213
|
+
type: 'song' | 'artist' | 'album' | 'playlist' | 'search' | 'podcast';
|
|
214
|
+
}): Promise<unknown>;
|
|
215
|
+
/**
|
|
216
|
+
* This is for controlling localplay
|
|
217
|
+
* @param params.command The command to send to the localplay controller
|
|
218
|
+
* @param [params.oid] Object UID
|
|
219
|
+
* @param [params.type] Object type
|
|
220
|
+
* @param [params.clear] 0, 1 (Clear the current playlist before adding)
|
|
221
|
+
* @remarks MINIMUM_API_VERSION=380001; CHANGED_IN_API_VERSION=5.0.0
|
|
222
|
+
* @see {@link https://ampache.org/api/api-json-methods#localplay}
|
|
223
|
+
*/
|
|
224
|
+
localplay(params: {
|
|
225
|
+
command: 'next' | 'prev' | 'stop' | 'play' | 'pause' | 'add' | 'volume_up' | 'volume_down' | 'volume_mute' | 'delete_all' | 'skip' | 'status';
|
|
226
|
+
oid?: number;
|
|
227
|
+
type?: 'song' | 'video' | 'podcast_episode' | 'channel' | 'broadcast' | 'democratic' | 'live_stream';
|
|
228
|
+
clear?: BinaryBoolean;
|
|
229
|
+
}): Promise<unknown>;
|
|
230
|
+
/**
|
|
231
|
+
* Get the list of songs in your localplay playlist
|
|
232
|
+
* @remarks MINIMUM_API_VERSION=5.0.0
|
|
233
|
+
* @see {@link https://ampache.org/api/api-json-methods#localplay_songs}
|
|
234
|
+
*/
|
|
235
|
+
localplaySongs(): Promise<unknown>;
|
|
236
|
+
/**
|
|
237
|
+
* This is for controlling democratic play (Songs only). VOTE: +1 vote for the oid. DEVOTE: -1 vote for the oid.
|
|
238
|
+
* PLAYLIST: Return an array of song items with an additional VOTE COUNT element.
|
|
239
|
+
* PLAY: Returns the URL for playing democratic play.
|
|
240
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
241
|
+
* @param params.oid UID of song
|
|
242
|
+
* @param params.method vote, devote, playlist, play
|
|
243
|
+
* @see {@link https://ampache.org/api/api-json-methods#democratic}
|
|
244
|
+
*/
|
|
245
|
+
democratic(params: {
|
|
246
|
+
oid: UID;
|
|
247
|
+
method: 'vote' | 'devote' | 'playlist' | 'play';
|
|
248
|
+
}): Promise<unknown>;
|
|
249
|
+
/**
|
|
250
|
+
* Perform an advanced search given passed rules.
|
|
251
|
+
* You'll want to consult the docs for this.
|
|
252
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
253
|
+
* @param params.operator and, or (whether to match one rule or all)
|
|
254
|
+
* @param params.type Object type to return
|
|
255
|
+
* @param params.rules An array of rules
|
|
256
|
+
* @param [params.random] 0, 1 (random order of results; default to 0)
|
|
257
|
+
* @param [params.offset]
|
|
258
|
+
* @param [params.limit]
|
|
259
|
+
* @see {@link https://ampache.org/api/api-json-methods#advanced_search}
|
|
260
|
+
*/
|
|
261
|
+
advancedSearch(params: {
|
|
262
|
+
operator: 'and' | 'or';
|
|
263
|
+
type: 'song' | 'album' | 'artist' | 'label' | 'playlist' | 'podcast' | 'podcast_episode' | 'genre' | 'user' | 'video';
|
|
264
|
+
rules: Array<Array<string>>;
|
|
265
|
+
random?: BinaryBoolean;
|
|
266
|
+
} & Pagination): Promise<any>;
|
|
267
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Song } from "../songs/types";
|
|
2
|
+
import { Album } from "../albums/types";
|
|
3
|
+
import { Artist } from "../artists/types";
|
|
4
|
+
import { Playlist } from "../playlists/types";
|
|
5
|
+
import { Podcast, PodcastEpisode } from "../podcasts/types";
|
|
6
|
+
import { LiveStream } from "../live-streams/types";
|
|
7
|
+
import { Video } from "../videos/types";
|
|
8
|
+
export type IndexType = Song | Album | Artist | Playlist | Podcast | PodcastEpisode | LiveStream;
|
|
9
|
+
export type StatsType = Song | Album | Artist | Video | Playlist | Podcast | PodcastEpisode;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { User, UserSummary, Activity } from './types';
|
|
2
|
+
import { Base, BinaryBoolean, Success } from '../base';
|
|
3
|
+
export declare class Users extends Base {
|
|
4
|
+
/**
|
|
5
|
+
* Get ids and usernames for your site
|
|
6
|
+
* @remarks MINIMUM_API_VERSION=5.0.0
|
|
7
|
+
* @see {@link https://ampache.org/api/api-json-methods#users}
|
|
8
|
+
*/
|
|
9
|
+
users(): Promise<UserSummary[] | {
|
|
10
|
+
user: UserSummary[];
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* This get a user's public information
|
|
14
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
15
|
+
* @param params.username UID to find
|
|
16
|
+
* @see {@link https://ampache.org/api/api-json-methods#user}
|
|
17
|
+
*/
|
|
18
|
+
user(params: {
|
|
19
|
+
username: string;
|
|
20
|
+
}): Promise<User>;
|
|
21
|
+
/**
|
|
22
|
+
* Create a new user
|
|
23
|
+
* ACCESS REQUIRED: 100 (Admin)
|
|
24
|
+
* @remarks MINIMUM_API_VERSION=400001
|
|
25
|
+
* @param params.username Username
|
|
26
|
+
* @param params.password SHA256 hashed password
|
|
27
|
+
* @param params.email Email
|
|
28
|
+
* @param [params.fullname] Full Name
|
|
29
|
+
* @param [params.disable] 0, 1
|
|
30
|
+
* @param [params.catalog_filter_group] Catalog filter group, default = 0
|
|
31
|
+
* @see {@link https://ampache.org/api/api-json-methods#user_create}
|
|
32
|
+
*/
|
|
33
|
+
userCreate(params: {
|
|
34
|
+
username: string;
|
|
35
|
+
password: string;
|
|
36
|
+
email: string;
|
|
37
|
+
fullname?: string;
|
|
38
|
+
disable?: BinaryBoolean;
|
|
39
|
+
catalog_filter_group?: number;
|
|
40
|
+
}): Promise<Success>;
|
|
41
|
+
/**
|
|
42
|
+
* Update an existing user
|
|
43
|
+
* ACCESS REQUIRED: 100 (Admin)
|
|
44
|
+
* @remarks MINIMUM_API_VERSION=400001
|
|
45
|
+
* @param params.username Username
|
|
46
|
+
* @param [params.password] Password
|
|
47
|
+
* @param [params.email] Email
|
|
48
|
+
* @param [params.fullname] Full Name
|
|
49
|
+
* @param [params.website] Website
|
|
50
|
+
* @param [params.state] State
|
|
51
|
+
* @param [params.city] City
|
|
52
|
+
* @param [params.disable] 0, 1
|
|
53
|
+
* @param [params.maxbitrate] Max bitrate for transcoding
|
|
54
|
+
* @see {@link https://ampache.org/api/api-json-methods#user_update}
|
|
55
|
+
*/
|
|
56
|
+
userUpdate(params: {
|
|
57
|
+
username: string;
|
|
58
|
+
password?: string;
|
|
59
|
+
email?: string;
|
|
60
|
+
fullname?: string;
|
|
61
|
+
website?: string;
|
|
62
|
+
state?: string;
|
|
63
|
+
city?: string;
|
|
64
|
+
disable?: BinaryBoolean;
|
|
65
|
+
maxbitrate?: string;
|
|
66
|
+
}): Promise<Success>;
|
|
67
|
+
/**
|
|
68
|
+
* Delete an existing user.
|
|
69
|
+
* ACCESS REQUIRED: 100 (Admin)
|
|
70
|
+
* @remarks MINIMUM_API_VERSION=400001
|
|
71
|
+
* @param params.filter UID of user to delete
|
|
72
|
+
* @see {@link https://ampache.org/api/api-json-methods#user_delete}
|
|
73
|
+
*/
|
|
74
|
+
userDelete(params: {
|
|
75
|
+
filter: string;
|
|
76
|
+
}): Promise<Success>;
|
|
77
|
+
/**
|
|
78
|
+
* This gets the followers for the requested username
|
|
79
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
80
|
+
* @param params.username UID to find
|
|
81
|
+
* @see {@link https://ampache.org/api/api-json-methods#followers}
|
|
82
|
+
*/
|
|
83
|
+
followers(params: {
|
|
84
|
+
username: string;
|
|
85
|
+
}): Promise<UserSummary[] | {
|
|
86
|
+
user: UserSummary[];
|
|
87
|
+
}>;
|
|
88
|
+
/**
|
|
89
|
+
* Get a list of people that this user follows
|
|
90
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
91
|
+
* @see {@link https://ampache.org/api/api-json-methods#following}
|
|
92
|
+
*/
|
|
93
|
+
following(params: {
|
|
94
|
+
username: string;
|
|
95
|
+
}): Promise<UserSummary[] | {
|
|
96
|
+
user: UserSummary[];
|
|
97
|
+
}>;
|
|
98
|
+
/**
|
|
99
|
+
* This will follow/unfollow a user
|
|
100
|
+
* @param params.username Username string to find
|
|
101
|
+
* @see {@link https://ampache.org/api/api-json-methods#toggle_follow}
|
|
102
|
+
*/
|
|
103
|
+
toggleFollow(params: {
|
|
104
|
+
username: string;
|
|
105
|
+
}): Promise<Success>;
|
|
106
|
+
/**
|
|
107
|
+
* This get a user timeline
|
|
108
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
109
|
+
* @param params.username Username to find
|
|
110
|
+
* @param [params.limit] Max results to return
|
|
111
|
+
* @param [params.since] UNIXTIME
|
|
112
|
+
* @see {@link https://ampache.org/api/api-json-methods#timeline}
|
|
113
|
+
*/
|
|
114
|
+
timeline(params: {
|
|
115
|
+
username: string;
|
|
116
|
+
limit?: number;
|
|
117
|
+
since?: number;
|
|
118
|
+
}): Promise<Activity[] | {
|
|
119
|
+
activity: Activity[];
|
|
120
|
+
}>;
|
|
121
|
+
/**
|
|
122
|
+
* This get current user friends timeline
|
|
123
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
124
|
+
* @param [params.limit] Max results to return
|
|
125
|
+
* @param [params.since] UNIXTIME
|
|
126
|
+
* @see {@link https://ampache.org/api/api-json-methods#friends_timeline}
|
|
127
|
+
*/
|
|
128
|
+
friendsTimeline(params?: {
|
|
129
|
+
limit?: number;
|
|
130
|
+
since?: number;
|
|
131
|
+
}): Promise<Activity[] | {
|
|
132
|
+
activity: Activity[];
|
|
133
|
+
}>;
|
|
134
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { UID } from "../base";
|
|
2
|
+
export type UserSummary = {
|
|
3
|
+
id: UID;
|
|
4
|
+
username: string;
|
|
5
|
+
};
|
|
6
|
+
export type User = {
|
|
7
|
+
id: UID;
|
|
8
|
+
username: string;
|
|
9
|
+
auth: string;
|
|
10
|
+
email: string;
|
|
11
|
+
access: number;
|
|
12
|
+
streamtoken: string | null;
|
|
13
|
+
fullname_public: number;
|
|
14
|
+
validation: string | null;
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
create_date: number;
|
|
17
|
+
last_seen: number;
|
|
18
|
+
website: string | null;
|
|
19
|
+
state: string | null;
|
|
20
|
+
city: string | null;
|
|
21
|
+
};
|
|
22
|
+
export type Activity = {
|
|
23
|
+
id: UID;
|
|
24
|
+
date: number;
|
|
25
|
+
object_type: string;
|
|
26
|
+
object_id: UID;
|
|
27
|
+
action: string;
|
|
28
|
+
user: UserSummary;
|
|
29
|
+
};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Video, DeletedVideo } from './types';
|
|
2
|
+
import { Base, BinaryBoolean, Pagination, UID } from '../base';
|
|
3
|
+
export declare class Videos extends Base {
|
|
4
|
+
/**
|
|
5
|
+
* Get videos
|
|
6
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
7
|
+
* @param [params.filter] Filter results to match this string
|
|
8
|
+
* @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
|
|
9
|
+
* @param [params.offset]
|
|
10
|
+
* @param [params.limit]
|
|
11
|
+
* @see {@link https://ampache.org/api/api-json-methods#videos}
|
|
12
|
+
*/
|
|
13
|
+
videos(params?: {
|
|
14
|
+
filter?: string;
|
|
15
|
+
exact?: BinaryBoolean;
|
|
16
|
+
} & Pagination): Promise<Video[] | {
|
|
17
|
+
video: Video[];
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* This returns a single video
|
|
21
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
22
|
+
* @param params.filter UID to find
|
|
23
|
+
* @see {@link https://ampache.org/api/api-json-methods#video}
|
|
24
|
+
*/
|
|
25
|
+
video(params: {
|
|
26
|
+
filter: UID;
|
|
27
|
+
}): Promise<Video>;
|
|
28
|
+
/**
|
|
29
|
+
* This returns video objects that have been deleted
|
|
30
|
+
* @param [params.offset]
|
|
31
|
+
* @param [params.limit]
|
|
32
|
+
* @see {@link https://ampache.org/api/api-json-methods#deleted_videos}
|
|
33
|
+
*/
|
|
34
|
+
deletedVideos(params?: {} & Pagination): Promise<DeletedVideo[] | {
|
|
35
|
+
deleted_video: DeletedVideo[];
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { UID } from "../base";
|
|
2
|
+
import { GenreSummary } from "../genres/types";
|
|
3
|
+
export type Video = {
|
|
4
|
+
id: UID;
|
|
5
|
+
title: string;
|
|
6
|
+
mime: string;
|
|
7
|
+
resolution: string;
|
|
8
|
+
size: number;
|
|
9
|
+
genre: GenreSummary[];
|
|
10
|
+
time: number;
|
|
11
|
+
url: string;
|
|
12
|
+
art: string;
|
|
13
|
+
flag: boolean;
|
|
14
|
+
rating: number | null;
|
|
15
|
+
averagerating: number | null;
|
|
16
|
+
playcount: number;
|
|
17
|
+
};
|
|
18
|
+
export type DeletedVideo = {
|
|
19
|
+
id: UID;
|
|
20
|
+
addition_time: number;
|
|
21
|
+
delete_time: number;
|
|
22
|
+
title: string;
|
|
23
|
+
file: string;
|
|
24
|
+
catalog: UID;
|
|
25
|
+
total_count: number;
|
|
26
|
+
total_skip: number;
|
|
27
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "javascript-ampache",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A JS library for the Ampache API",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.m.js",
|
|
7
|
+
"umd:main": "dist/index.umd.js",
|
|
8
|
+
"source": "src/index.ts",
|
|
9
|
+
"repository": "github:mitchray/javascript-ampache",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "rimraf dist && microbundle --tsconfig tsconfig.json",
|
|
12
|
+
"dev": "microbundle watch --tsconfig tsconfig.json",
|
|
13
|
+
"test": "jest"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/jest": "^25.2.1",
|
|
17
|
+
"jest": "^29.3.1",
|
|
18
|
+
"microbundle": "0.13.0",
|
|
19
|
+
"nock": "^12.0.3",
|
|
20
|
+
"rimraf": "^4.1.1"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"ampache",
|
|
24
|
+
"javascript",
|
|
25
|
+
"typescript",
|
|
26
|
+
"api",
|
|
27
|
+
"js"
|
|
28
|
+
],
|
|
29
|
+
"author": "mitchray (https://github.com/mitchray)",
|
|
30
|
+
"license": "GPL-3.0-only",
|
|
31
|
+
"files": [
|
|
32
|
+
"src",
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"isomorphic-unfetch": "3.1.0",
|
|
37
|
+
"jssha": "^3.3.0",
|
|
38
|
+
"querystringify": "2.2.0"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import qs from 'querystringify';
|
|
2
|
+
import { Album } from './types';
|
|
3
|
+
import { Base, BinaryBoolean, Pagination, UID } from '../base';
|
|
4
|
+
|
|
5
|
+
export class Albums extends Base {
|
|
6
|
+
/**
|
|
7
|
+
* This returns albums based on the provided search filters
|
|
8
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
9
|
+
* @param [params.filter] UID to find
|
|
10
|
+
* @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
|
|
11
|
+
* @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
|
|
12
|
+
* @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
|
|
13
|
+
* @param [params.include] albums, songs (include child objects in the response)
|
|
14
|
+
* @param [params.offset]
|
|
15
|
+
* @param [params.limit]
|
|
16
|
+
* @see {@link https://ampache.org/api/api-json-methods#albums}
|
|
17
|
+
*/
|
|
18
|
+
async albums (params?: {
|
|
19
|
+
filter?: number,
|
|
20
|
+
exact?: BinaryBoolean,
|
|
21
|
+
add?: Date,
|
|
22
|
+
update?: Date,
|
|
23
|
+
include?: "albums" | "songs",
|
|
24
|
+
} & Pagination) {
|
|
25
|
+
let query = 'albums';
|
|
26
|
+
query += qs.stringify(params, '&');
|
|
27
|
+
let data = await this.request<{album: Album[]}>(query);
|
|
28
|
+
return (data.album) ? data.album : data;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* This returns a single album based on the UID provided
|
|
33
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
34
|
+
* @param params.filter UID to find
|
|
35
|
+
* @param [params.include] songs (include child objects in the response)
|
|
36
|
+
* @see {@link https://ampache.org/api/api-json-methods#album}
|
|
37
|
+
*/
|
|
38
|
+
album (params: {
|
|
39
|
+
filter: UID,
|
|
40
|
+
include?: 'songs'
|
|
41
|
+
}) {
|
|
42
|
+
let query = 'album';
|
|
43
|
+
query += qs.stringify(params, '&');
|
|
44
|
+
return this.request<Album>(query);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* This returns the albums of an artist
|
|
49
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
50
|
+
* @param params.filter UID to find
|
|
51
|
+
* @param [params.offset]
|
|
52
|
+
* @param [params.limit]
|
|
53
|
+
* @see {@link https://ampache.org/api/api-json-methods#artist_albums}
|
|
54
|
+
*/
|
|
55
|
+
async artistAlbums (params: {
|
|
56
|
+
filter: UID
|
|
57
|
+
} & Pagination) {
|
|
58
|
+
let query = 'artist_albums';
|
|
59
|
+
query += qs.stringify(params, '&');
|
|
60
|
+
let data = await this.request<{album: Album[]}>(query);
|
|
61
|
+
return (data.album) ? data.album : data;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* This returns the albums associated with the genre in question
|
|
66
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
67
|
+
* @param params.filter UID to find
|
|
68
|
+
* @param [params.offset]
|
|
69
|
+
* @param [params.limit]
|
|
70
|
+
* @see {@link https://ampache.org/api/api-json-methods#genre_albums}
|
|
71
|
+
*/
|
|
72
|
+
async genreAlbums (params?: {
|
|
73
|
+
filter: UID
|
|
74
|
+
} & Pagination) {
|
|
75
|
+
let query = 'genre_albums';
|
|
76
|
+
query += qs.stringify(params, '&');
|
|
77
|
+
let data = await this.request<{album: Album[]}>(query);
|
|
78
|
+
return (data.album) ? data.album : data;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { UID } from '../base';
|
|
2
|
+
import { GenreSummary } from "../genres/types";
|
|
3
|
+
import { ArtistSummary } from "../artists/types";
|
|
4
|
+
import { Song } from "../songs/types";
|
|
5
|
+
|
|
6
|
+
export type AlbumSummary = {
|
|
7
|
+
id: UID,
|
|
8
|
+
name: string,
|
|
9
|
+
prefix: string | null,
|
|
10
|
+
basename: string,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type Album = {
|
|
14
|
+
id: UID,
|
|
15
|
+
name: string,
|
|
16
|
+
prefix: string | null,
|
|
17
|
+
basename: string,
|
|
18
|
+
artist: ArtistSummary,
|
|
19
|
+
time: number,
|
|
20
|
+
year: number | string,
|
|
21
|
+
tracks?: Song[],
|
|
22
|
+
songcount: number,
|
|
23
|
+
disccount: number,
|
|
24
|
+
type: string | null,
|
|
25
|
+
genre: GenreSummary[],
|
|
26
|
+
art: string,
|
|
27
|
+
flag: boolean,
|
|
28
|
+
rating: number | null,
|
|
29
|
+
averagerating: number | null,
|
|
30
|
+
mbid: string | null
|
|
31
|
+
}
|