javascript-ampache 1.1.10 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -6
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.m.js +1 -1
- package/dist/index.m.js.map +1 -1
- package/dist/index.modern.mjs +1 -1
- package/dist/index.modern.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +8 -7
- package/src/albums.js +106 -0
- package/src/artists.js +105 -0
- package/src/auth.js +142 -0
- package/src/base.js +145 -0
- package/src/bookmarks.js +106 -0
- package/src/catalogs.js +133 -0
- package/src/genres.js +57 -0
- package/src/index.js +30 -0
- package/src/labels.js +53 -0
- package/src/licenses.js +47 -0
- package/src/live-streams.js +97 -0
- package/src/playlists.js +241 -0
- package/src/podcasts.js +230 -0
- package/src/preferences.js +114 -0
- package/src/shares.js +99 -0
- package/src/shouts.js +24 -0
- package/src/songs.js +273 -0
- package/src/system.js +510 -0
- package/src/users.js +224 -0
- package/src/{utils.ts → utils.js} +16 -16
- package/src/videos.js +84 -0
- package/dist/albums/index.d.ts +0 -64
- package/dist/albums/types.d.ts +0 -37
- package/dist/artists/index.d.ts +0 -64
- package/dist/artists/types.d.ts +0 -35
- package/dist/auth/index.d.ts +0 -56
- package/dist/auth/types.d.ts +0 -32
- package/dist/base.d.ts +0 -47
- package/dist/bookmarks/index.d.ts +0 -91
- package/dist/bookmarks/types.d.ts +0 -13
- package/dist/catalogs/index.d.ts +0 -87
- package/dist/catalogs/types.d.ts +0 -19
- package/dist/genres/index.d.ts +0 -28
- package/dist/genres/types.d.ts +0 -22
- package/dist/index.d.ts +0 -24
- package/dist/labels/index.d.ts +0 -32
- package/dist/labels/types.d.ts +0 -18
- package/dist/licenses/index.d.ts +0 -32
- package/dist/licenses/types.d.ts +0 -12
- package/dist/live-streams/index.d.ts +0 -80
- package/dist/live-streams/types.d.ts +0 -14
- package/dist/playlists/index.d.ts +0 -204
- package/dist/playlists/types.d.ts +0 -26
- package/dist/podcasts/index.d.ts +0 -121
- package/dist/podcasts/types.d.ts +0 -79
- package/dist/preferences/index.d.ts +0 -80
- package/dist/preferences/types.d.ts +0 -18
- package/dist/shares/index.d.ts +0 -69
- package/dist/shares/types.d.ts +0 -23
- package/dist/shouts/index.d.ts +0 -17
- package/dist/shouts/types.d.ts +0 -10
- package/dist/songs/index.d.ts +0 -143
- package/dist/songs/types.d.ts +0 -73
- package/dist/system/index.d.ts +0 -407
- package/dist/system/types.d.ts +0 -24
- package/dist/users/index.d.ts +0 -190
- package/dist/users/types.d.ts +0 -34
- package/dist/utils.d.ts +0 -4
- package/dist/videos/index.d.ts +0 -33
- package/dist/videos/types.d.ts +0 -38
- package/src/albums/index.ts +0 -88
- package/src/albums/types.ts +0 -40
- package/src/artists/index.ts +0 -88
- package/src/artists/types.ts +0 -38
- package/src/auth/index.ts +0 -118
- package/src/auth/types.ts +0 -32
- package/src/base.ts +0 -133
- package/src/bookmarks/index.ts +0 -116
- package/src/bookmarks/types.ts +0 -15
- package/src/catalogs/index.ts +0 -130
- package/src/catalogs/types.ts +0 -27
- package/src/genres/index.ts +0 -39
- package/src/genres/types.ts +0 -25
- package/src/index.ts +0 -63
- package/src/labels/index.ts +0 -43
- package/src/labels/types.ts +0 -20
- package/src/licenses/index.ts +0 -43
- package/src/licenses/types.ts +0 -14
- package/src/live-streams/index.ts +0 -104
- package/src/live-streams/types.ts +0 -16
- package/src/playlists/index.ts +0 -280
- package/src/playlists/types.ts +0 -29
- package/src/podcasts/index.ts +0 -174
- package/src/podcasts/types.ts +0 -85
- package/src/preferences/index.ts +0 -114
- package/src/preferences/types.ts +0 -20
- package/src/shares/index.ts +0 -100
- package/src/shares/types.ts +0 -25
- package/src/shouts/index.ts +0 -18
- package/src/shouts/types.ts +0 -11
- package/src/songs/index.ts +0 -221
- package/src/songs/types.ts +0 -77
- package/src/system/index.ts +0 -845
- package/src/system/types.ts +0 -42
- package/src/users/index.ts +0 -227
- package/src/users/types.ts +0 -38
- package/src/videos/index.ts +0 -49
- package/src/videos/types.ts +0 -42
package/dist/users/index.d.ts
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { UserResponse, UserSummary, ActivityResponse } from "./types";
|
|
2
|
-
import { Base, BinaryBoolean, ExtendedPagination, 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<{
|
|
10
|
-
user: UserSummary[];
|
|
11
|
-
}>;
|
|
12
|
-
/**
|
|
13
|
-
* This get a user's public information (or current user if username is omitted)
|
|
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<UserResponse>;
|
|
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
|
-
* Register as a new user if allowed.
|
|
43
|
-
* @remarks MINIMUM_API_VERSION=6.0.0
|
|
44
|
-
* @param params.username Username
|
|
45
|
-
* @param params.password SHA256 hashed password
|
|
46
|
-
* @param params.email Email
|
|
47
|
-
* @param [params.fullname] Full Name
|
|
48
|
-
* @see {@link https://ampache.org/api/api-json-methods/#register}
|
|
49
|
-
*/
|
|
50
|
-
register(params: {
|
|
51
|
-
username: string;
|
|
52
|
-
password: string;
|
|
53
|
-
email: string;
|
|
54
|
-
fullname?: string;
|
|
55
|
-
}): Promise<Success>;
|
|
56
|
-
/**
|
|
57
|
-
* Update an existing user
|
|
58
|
-
* ACCESS REQUIRED: 100 (Admin)
|
|
59
|
-
* @remarks MINIMUM_API_VERSION=400001
|
|
60
|
-
* @param params.username Username
|
|
61
|
-
* @param [params.password] Password
|
|
62
|
-
* @param [params.email] Email
|
|
63
|
-
* @param [params.fullname] Full Name
|
|
64
|
-
* @param [params.website] Website
|
|
65
|
-
* @param [params.state] State
|
|
66
|
-
* @param [params.city] City
|
|
67
|
-
* @param [params.disable] 0, 1
|
|
68
|
-
* @param [params.maxbitrate] Max bitrate for transcoding
|
|
69
|
-
* @see {@link https://ampache.org/api/api-json-methods#user_update}
|
|
70
|
-
* @deprecated Being removed in 7.0.0. Use `user_edit` instead.
|
|
71
|
-
*/
|
|
72
|
-
userUpdate(params: {
|
|
73
|
-
username: string;
|
|
74
|
-
password?: string;
|
|
75
|
-
email?: string;
|
|
76
|
-
fullname?: string;
|
|
77
|
-
website?: string;
|
|
78
|
-
state?: string;
|
|
79
|
-
city?: string;
|
|
80
|
-
disable?: BinaryBoolean;
|
|
81
|
-
maxbitrate?: string;
|
|
82
|
-
}): Promise<Success>;
|
|
83
|
-
/**
|
|
84
|
-
* Update an existing user
|
|
85
|
-
* ACCESS REQUIRED: 100 (Admin)
|
|
86
|
-
* @remarks MINIMUM_API_VERSION=6.0.0
|
|
87
|
-
* @param params.username Username
|
|
88
|
-
* @param [params.password] Password
|
|
89
|
-
* @param [params.email] Email
|
|
90
|
-
* @param [params.fullname] Full Name
|
|
91
|
-
* @param [params.website] Website
|
|
92
|
-
* @param [params.state] State
|
|
93
|
-
* @param [params.city] City
|
|
94
|
-
* @param [params.disable] 0, 1
|
|
95
|
-
* @param [params.maxbitrate] Max bitrate for transcoding
|
|
96
|
-
* @param [params.group] Catalog filter group, default = 0
|
|
97
|
-
* @param [params.fullname_public] show fullname in public display
|
|
98
|
-
* @param [params.reset_apikey] reset user Api Key
|
|
99
|
-
* @param [params.reset_streamtoken] reset user Stream Token
|
|
100
|
-
* @param [params.clear_stats] reset all stats for this user
|
|
101
|
-
* @see {@link https://ampache.org/api/api-json-methods#user_edit}
|
|
102
|
-
*/
|
|
103
|
-
userEdit(params: {
|
|
104
|
-
username: string;
|
|
105
|
-
password?: string;
|
|
106
|
-
email?: string;
|
|
107
|
-
fullname?: string;
|
|
108
|
-
website?: string;
|
|
109
|
-
state?: string;
|
|
110
|
-
city?: string;
|
|
111
|
-
maxbitrate?: string;
|
|
112
|
-
group?: number;
|
|
113
|
-
disable?: BinaryBoolean;
|
|
114
|
-
fullname_public?: BinaryBoolean;
|
|
115
|
-
reset_apikey?: BinaryBoolean;
|
|
116
|
-
reset_streamtoken?: BinaryBoolean;
|
|
117
|
-
clear_stats?: BinaryBoolean;
|
|
118
|
-
}): Promise<Success>;
|
|
119
|
-
/**
|
|
120
|
-
* Delete an existing user.
|
|
121
|
-
* ACCESS REQUIRED: 100 (Admin)
|
|
122
|
-
* @remarks MINIMUM_API_VERSION=400001
|
|
123
|
-
* @param params.filter UID of user to delete
|
|
124
|
-
* @see {@link https://ampache.org/api/api-json-methods#user_delete}
|
|
125
|
-
*/
|
|
126
|
-
userDelete(params: {
|
|
127
|
-
filter: string;
|
|
128
|
-
}): Promise<Success>;
|
|
129
|
-
/**
|
|
130
|
-
* This gets the followers for the requested username
|
|
131
|
-
* @remarks MINIMUM_API_VERSION=380001
|
|
132
|
-
* @param params.username UID to find
|
|
133
|
-
* @param [params.offset]
|
|
134
|
-
* @param [params.limit]
|
|
135
|
-
* @param [params.cond]
|
|
136
|
-
* @param [params.sort]
|
|
137
|
-
* @see {@link https://ampache.org/api/api-json-methods#followers}
|
|
138
|
-
*/
|
|
139
|
-
followers(params: {
|
|
140
|
-
username: string;
|
|
141
|
-
} & ExtendedPagination): Promise<{
|
|
142
|
-
user: UserSummary[];
|
|
143
|
-
}>;
|
|
144
|
-
/**
|
|
145
|
-
* Get a list of people that this user follows
|
|
146
|
-
* @remarks MINIMUM_API_VERSION=380001
|
|
147
|
-
* @see {@link https://ampache.org/api/api-json-methods#following}
|
|
148
|
-
*/
|
|
149
|
-
following(params: {
|
|
150
|
-
username: string;
|
|
151
|
-
}): Promise<{
|
|
152
|
-
user: UserSummary[];
|
|
153
|
-
}>;
|
|
154
|
-
/**
|
|
155
|
-
* This will follow/unfollow a user
|
|
156
|
-
* @param params.username Username string to find
|
|
157
|
-
* @see {@link https://ampache.org/api/api-json-methods#toggle_follow}
|
|
158
|
-
*/
|
|
159
|
-
toggleFollow(params: {
|
|
160
|
-
username: string;
|
|
161
|
-
}): Promise<Success>;
|
|
162
|
-
/**
|
|
163
|
-
* This get a user timeline
|
|
164
|
-
* @remarks MINIMUM_API_VERSION=380001
|
|
165
|
-
* @param params.username Username to find
|
|
166
|
-
* @param [params.limit] Max results to return
|
|
167
|
-
* @param [params.since] UNIXTIME
|
|
168
|
-
* @see {@link https://ampache.org/api/api-json-methods#timeline}
|
|
169
|
-
*/
|
|
170
|
-
timeline(params: {
|
|
171
|
-
username: string;
|
|
172
|
-
limit?: number;
|
|
173
|
-
since?: number;
|
|
174
|
-
}): Promise<{
|
|
175
|
-
activity: ActivityResponse[];
|
|
176
|
-
}>;
|
|
177
|
-
/**
|
|
178
|
-
* This get current user friends timeline
|
|
179
|
-
* @remarks MINIMUM_API_VERSION=380001
|
|
180
|
-
* @param [params.limit] Max results to return
|
|
181
|
-
* @param [params.since] UNIXTIME
|
|
182
|
-
* @see {@link https://ampache.org/api/api-json-methods#friends_timeline}
|
|
183
|
-
*/
|
|
184
|
-
friendsTimeline(params?: {
|
|
185
|
-
limit?: number;
|
|
186
|
-
since?: number;
|
|
187
|
-
}): Promise<{
|
|
188
|
-
activity: ActivityResponse[];
|
|
189
|
-
}>;
|
|
190
|
-
}
|
package/dist/users/types.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { UID } from "../base";
|
|
2
|
-
export type UserSummary = {
|
|
3
|
-
id: UID;
|
|
4
|
-
username: string;
|
|
5
|
-
};
|
|
6
|
-
export type UserResponse = {
|
|
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 UsersResponse = {
|
|
23
|
-
total_count: number;
|
|
24
|
-
md5: string;
|
|
25
|
-
user: UserResponse[];
|
|
26
|
-
};
|
|
27
|
-
export type ActivityResponse = {
|
|
28
|
-
id: UID;
|
|
29
|
-
date: number;
|
|
30
|
-
object_type: string;
|
|
31
|
-
object_id: UID;
|
|
32
|
-
action: string;
|
|
33
|
-
user: UserSummary;
|
|
34
|
-
};
|
package/dist/utils.d.ts
DELETED
package/dist/videos/index.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { VideoResponse, VideosResponse, DeletedVideosResponse } 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<VideosResponse>;
|
|
17
|
-
/**
|
|
18
|
-
* This returns a single video
|
|
19
|
-
* @remarks MINIMUM_API_VERSION=380001
|
|
20
|
-
* @param params.filter UID to find
|
|
21
|
-
* @see {@link https://ampache.org/api/api-json-methods#video}
|
|
22
|
-
*/
|
|
23
|
-
video(params: {
|
|
24
|
-
filter: UID;
|
|
25
|
-
}): Promise<VideoResponse>;
|
|
26
|
-
/**
|
|
27
|
-
* This returns video objects that have been deleted
|
|
28
|
-
* @param [params.offset]
|
|
29
|
-
* @param [params.limit]
|
|
30
|
-
* @see {@link https://ampache.org/api/api-json-methods#deleted_videos}
|
|
31
|
-
*/
|
|
32
|
-
deletedVideos(params?: {} & Pagination): Promise<DeletedVideosResponse>;
|
|
33
|
-
}
|
package/dist/videos/types.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { UID } from "../base";
|
|
2
|
-
import { GenreSummary } from "../genres/types";
|
|
3
|
-
export type VideoResponse = {
|
|
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
|
-
has_art: boolean;
|
|
14
|
-
flag: boolean;
|
|
15
|
-
rating: number | null;
|
|
16
|
-
averagerating: number | null;
|
|
17
|
-
playcount: number;
|
|
18
|
-
};
|
|
19
|
-
export type VideosResponse = {
|
|
20
|
-
total_count: number;
|
|
21
|
-
md5: string;
|
|
22
|
-
video: VideoResponse[];
|
|
23
|
-
};
|
|
24
|
-
export type DeletedVideoResponse = {
|
|
25
|
-
id: UID;
|
|
26
|
-
addition_time: number;
|
|
27
|
-
delete_time: number;
|
|
28
|
-
title: string;
|
|
29
|
-
file: string;
|
|
30
|
-
catalog: UID;
|
|
31
|
-
total_count: number;
|
|
32
|
-
total_skip: number;
|
|
33
|
-
};
|
|
34
|
-
export type DeletedVideosResponse = {
|
|
35
|
-
total_count: number;
|
|
36
|
-
md5: string;
|
|
37
|
-
deleted_video: DeletedVideoResponse[];
|
|
38
|
-
};
|
package/src/albums/index.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import qs from "querystringify";
|
|
2
|
-
import { AlbumResponse, AlbumsResponse } from "./types";
|
|
3
|
-
import { Base, BinaryBoolean, ExtendedPagination, 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
|
-
* @param [params.cond]
|
|
17
|
-
* @param [params.sort]
|
|
18
|
-
* @see {@link https://ampache.org/api/api-json-methods#albums}
|
|
19
|
-
*/
|
|
20
|
-
albums(
|
|
21
|
-
params?: {
|
|
22
|
-
filter?: number;
|
|
23
|
-
exact?: BinaryBoolean;
|
|
24
|
-
add?: Date;
|
|
25
|
-
update?: Date;
|
|
26
|
-
include?: "albums" | "songs";
|
|
27
|
-
} & ExtendedPagination,
|
|
28
|
-
) {
|
|
29
|
-
let query = "albums";
|
|
30
|
-
query += qs.stringify(params, "&");
|
|
31
|
-
return this.request<AlbumsResponse>(query);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* This returns a single album based on the UID provided
|
|
36
|
-
* @remarks MINIMUM_API_VERSION=380001
|
|
37
|
-
* @param params.filter UID to find
|
|
38
|
-
* @param [params.include] songs (include child objects in the response)
|
|
39
|
-
* @see {@link https://ampache.org/api/api-json-methods#album}
|
|
40
|
-
*/
|
|
41
|
-
album(params: { filter: UID; include?: "songs" }) {
|
|
42
|
-
let query = "album";
|
|
43
|
-
query += qs.stringify(params, "&");
|
|
44
|
-
return this.request<AlbumResponse>(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.album_artist] 0, 1 (if true filter for album artists only)
|
|
52
|
-
* @param [params.offset]
|
|
53
|
-
* @param [params.limit]
|
|
54
|
-
* @param [params.cond]
|
|
55
|
-
* @param [params.sort]
|
|
56
|
-
* @see {@link https://ampache.org/api/api-json-methods#artist_albums}
|
|
57
|
-
*/
|
|
58
|
-
artistAlbums(
|
|
59
|
-
params: {
|
|
60
|
-
filter: UID;
|
|
61
|
-
album_artist?: BinaryBoolean;
|
|
62
|
-
} & ExtendedPagination,
|
|
63
|
-
) {
|
|
64
|
-
let query = "artist_albums";
|
|
65
|
-
query += qs.stringify(params, "&");
|
|
66
|
-
return this.request<AlbumsResponse>(query);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* This returns the albums associated with the genre in question
|
|
71
|
-
* @remarks MINIMUM_API_VERSION=380001
|
|
72
|
-
* @param params.filter UID to find
|
|
73
|
-
* @param [params.offset]
|
|
74
|
-
* @param [params.limit]
|
|
75
|
-
* @param [params.cond]
|
|
76
|
-
* @param [params.sort]
|
|
77
|
-
* @see {@link https://ampache.org/api/api-json-methods#genre_albums}
|
|
78
|
-
*/
|
|
79
|
-
genreAlbums(
|
|
80
|
-
params?: {
|
|
81
|
-
filter: UID;
|
|
82
|
-
} & ExtendedPagination,
|
|
83
|
-
) {
|
|
84
|
-
let query = "genre_albums";
|
|
85
|
-
query += qs.stringify(params, "&");
|
|
86
|
-
return this.request<AlbumsResponse>(query);
|
|
87
|
-
}
|
|
88
|
-
}
|
package/src/albums/types.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { UID } from "../base";
|
|
2
|
-
import { GenreSummary } from "../genres/types";
|
|
3
|
-
import { ArtistSummary } from "../artists/types";
|
|
4
|
-
import { SongResponse } 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 AlbumResponse = {
|
|
14
|
-
id: UID;
|
|
15
|
-
name: string;
|
|
16
|
-
prefix: string | null;
|
|
17
|
-
basename: string;
|
|
18
|
-
artist: ArtistSummary;
|
|
19
|
-
artists: ArtistSummary[];
|
|
20
|
-
songartists: ArtistSummary[];
|
|
21
|
-
time: number;
|
|
22
|
-
year: number | string;
|
|
23
|
-
tracks?: SongResponse[];
|
|
24
|
-
songcount: number;
|
|
25
|
-
disccount: number;
|
|
26
|
-
type: string | null;
|
|
27
|
-
genre: GenreSummary[];
|
|
28
|
-
art: string;
|
|
29
|
-
has_art: boolean;
|
|
30
|
-
flag: boolean;
|
|
31
|
-
rating: number | null;
|
|
32
|
-
averagerating: number | null;
|
|
33
|
-
mbid: string | null;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export type AlbumsResponse = {
|
|
37
|
-
total_count: number;
|
|
38
|
-
md5: string;
|
|
39
|
-
album: AlbumResponse[];
|
|
40
|
-
};
|
package/src/artists/index.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import qs from "querystringify";
|
|
2
|
-
import { ArtistResponse, ArtistsResponse } from "./types";
|
|
3
|
-
import { Base, BinaryBoolean, ExtendedPagination, UID } from "../base";
|
|
4
|
-
|
|
5
|
-
export class Artists extends Base {
|
|
6
|
-
/**
|
|
7
|
-
* This takes a collection of inputs and returns artist objects
|
|
8
|
-
* @remarks MINIMUM_API_VERSION=380001
|
|
9
|
-
* @param [params.filter] Filter results to match this string
|
|
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.album_artist] 0, 1 (if true filter for album artists only)
|
|
15
|
-
* @param [params.offset]
|
|
16
|
-
* @param [params.limit]
|
|
17
|
-
* @param [params.cond]
|
|
18
|
-
* @param [params.sort]
|
|
19
|
-
* @see {@link https://ampache.org/api/api-json-methods#artists}
|
|
20
|
-
*/
|
|
21
|
-
artists(
|
|
22
|
-
params?: {
|
|
23
|
-
filter?: string;
|
|
24
|
-
exact?: BinaryBoolean;
|
|
25
|
-
add?: Date;
|
|
26
|
-
update?: Date;
|
|
27
|
-
include?: "albums" | "songs";
|
|
28
|
-
album_artist?: BinaryBoolean;
|
|
29
|
-
} & ExtendedPagination,
|
|
30
|
-
) {
|
|
31
|
-
let query = "artists";
|
|
32
|
-
query += qs.stringify(params, "&");
|
|
33
|
-
return this.request<ArtistsResponse>(query);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* This returns a single artist based on the UID of said artist
|
|
38
|
-
* @remarks MINIMUM_API_VERSION=380001
|
|
39
|
-
* @param params.filter UID to find
|
|
40
|
-
* @param [params.include] (albums | songs) include child objects in the response
|
|
41
|
-
* @see {@link https://ampache.org/api/api-json-methods#artist}
|
|
42
|
-
*/
|
|
43
|
-
artist(params: { filter: UID; include?: "albums" | "songs" }) {
|
|
44
|
-
let query = "artist";
|
|
45
|
-
query += qs.stringify(params, "&");
|
|
46
|
-
return this.request<ArtistResponse>(query);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* This returns the artists associated with the genre in question as defined by the UID
|
|
51
|
-
* @remarks MINIMUM_API_VERSION=380001
|
|
52
|
-
* @param params.filter UID to find
|
|
53
|
-
* @param [params.offset]
|
|
54
|
-
* @param [params.limit]
|
|
55
|
-
* @param [params.cond]
|
|
56
|
-
* @param [params.sort]
|
|
57
|
-
* @see {@link https://ampache.org/api/api-json-methods#genre_artists}
|
|
58
|
-
*/
|
|
59
|
-
genreArtists(
|
|
60
|
-
params: {
|
|
61
|
-
filter: UID;
|
|
62
|
-
} & ExtendedPagination,
|
|
63
|
-
) {
|
|
64
|
-
let query = "genre_artists";
|
|
65
|
-
query += qs.stringify(params, "&");
|
|
66
|
-
return this.request<ArtistsResponse>(query);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* This returns the artists associated with the label in question as defined by the UID
|
|
71
|
-
* @remarks MINIMUM_API_VERSION=420000
|
|
72
|
-
* @param params.filter UID of find
|
|
73
|
-
* @param [params.offset]
|
|
74
|
-
* @param [params.limit]
|
|
75
|
-
* @param [params.cond]
|
|
76
|
-
* @param [params.sort]
|
|
77
|
-
* @see {@link https://ampache.org/api/api-json-methods#label_artists}
|
|
78
|
-
*/
|
|
79
|
-
labelArtists(
|
|
80
|
-
params: {
|
|
81
|
-
filter: UID;
|
|
82
|
-
} & ExtendedPagination,
|
|
83
|
-
) {
|
|
84
|
-
let query = "label_artists";
|
|
85
|
-
query += qs.stringify(params, "&");
|
|
86
|
-
return this.request<ArtistsResponse>(query);
|
|
87
|
-
}
|
|
88
|
-
}
|
package/src/artists/types.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { AlbumResponse } from "../albums/types";
|
|
2
|
-
import { SongsResponse } from "../songs/types";
|
|
3
|
-
import { GenreResponse } from "../genres/types";
|
|
4
|
-
|
|
5
|
-
export type ArtistSummary = {
|
|
6
|
-
id: string;
|
|
7
|
-
name: string;
|
|
8
|
-
prefix: string | null;
|
|
9
|
-
basename: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type ArtistResponse = {
|
|
13
|
-
id: string;
|
|
14
|
-
name: string;
|
|
15
|
-
prefix: string | null;
|
|
16
|
-
basename: string;
|
|
17
|
-
albums: AlbumResponse[];
|
|
18
|
-
albumcount: number;
|
|
19
|
-
songs: SongsResponse[];
|
|
20
|
-
songcount: number;
|
|
21
|
-
genre: GenreResponse[];
|
|
22
|
-
art: string;
|
|
23
|
-
has_art: boolean;
|
|
24
|
-
flag: boolean;
|
|
25
|
-
rating: number | null;
|
|
26
|
-
averagerating: number | null;
|
|
27
|
-
mbid: string | null;
|
|
28
|
-
summary: string;
|
|
29
|
-
time: number;
|
|
30
|
-
yearformed: number;
|
|
31
|
-
placeformed: string;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export type ArtistsResponse = {
|
|
35
|
-
total_count: number;
|
|
36
|
-
md5: string;
|
|
37
|
-
artist: ArtistResponse[];
|
|
38
|
-
};
|
package/src/auth/index.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import JsSHA from "jssha/dist/sha256";
|
|
2
|
-
import qs from "querystringify";
|
|
3
|
-
import fetch from "isomorphic-unfetch";
|
|
4
|
-
import { Base, Success } from "../base";
|
|
5
|
-
import { AuthResponse } from "./types";
|
|
6
|
-
import { outputDebugURL } from "../utils";
|
|
7
|
-
|
|
8
|
-
export class Auth extends Base {
|
|
9
|
-
/**
|
|
10
|
-
* Handles verifying a new handshake
|
|
11
|
-
* @remarks MINIMUM_API_VERSION=380001
|
|
12
|
-
* @param params.auth encrypted apikey OR password if using password auth
|
|
13
|
-
* @param [params.user] username
|
|
14
|
-
* @param [params.timestamp] UNIXTIME()
|
|
15
|
-
* @param [params.version] version of Ampache API to establish connection with
|
|
16
|
-
* @see {@link https://ampache.org/api/api-json-methods#handshake}
|
|
17
|
-
*/
|
|
18
|
-
handshake(params: {
|
|
19
|
-
auth: string;
|
|
20
|
-
user?: string;
|
|
21
|
-
timestamp?: number;
|
|
22
|
-
version?: string;
|
|
23
|
-
}) {
|
|
24
|
-
let token = params.auth;
|
|
25
|
-
|
|
26
|
-
// generate a timestamp if one wasn't provided
|
|
27
|
-
if (!params.timestamp) {
|
|
28
|
-
params.timestamp = Math.floor(new Date().getTime() / 1000);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// override the fallback API version with specified
|
|
32
|
-
if (params.version) {
|
|
33
|
-
this.version = params.version;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// drop timestamp if no user provided (i.e. logging in with API key)
|
|
37
|
-
if (!params.user) {
|
|
38
|
-
delete params.timestamp;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// not needed if using Bearer token
|
|
42
|
-
if (this.useBearerToken) {
|
|
43
|
-
delete params.auth;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
let query = this.url + "/server/json.server.php?action=handshake";
|
|
47
|
-
query += qs.stringify(params, "&");
|
|
48
|
-
|
|
49
|
-
if (this.debug) {
|
|
50
|
-
outputDebugURL(query, this);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return fetch(query, {
|
|
54
|
-
method: "GET",
|
|
55
|
-
headers: this.useBearerToken ? { Authorization: "Bearer " + token } : {},
|
|
56
|
-
})
|
|
57
|
-
.then((response) => response.json())
|
|
58
|
-
.then((data) => {
|
|
59
|
-
if (data.auth) {
|
|
60
|
-
this.sessionKey = data.auth;
|
|
61
|
-
}
|
|
62
|
-
return <AuthResponse>data;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* This can be called without being authenticated, it is useful for determining if what the status
|
|
68
|
-
* of the server is, and what version it is running/compatible with
|
|
69
|
-
* @remarks MINIMUM_API_VERSION=380001
|
|
70
|
-
* @param [params.auth] (Session ID) returns version information and extends the session if passed
|
|
71
|
-
* @param [params.version] API Version that the application understands
|
|
72
|
-
* @see {@link https://ampache.org/api/api-json-methods#ping}
|
|
73
|
-
*/
|
|
74
|
-
ping(params?: { auth?: string; version?: string }) {
|
|
75
|
-
let query = "ping";
|
|
76
|
-
query += qs.stringify(params, "&");
|
|
77
|
-
return this.request<AuthResponse>(query);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Destroy a session using the session auth parameter
|
|
82
|
-
* @remarks MINIMUM_API_VERSION=400001
|
|
83
|
-
* @param params.auth Session ID to destroy
|
|
84
|
-
* @see {@link https://ampache.org/api/api-json-methods#goodbye}
|
|
85
|
-
*/
|
|
86
|
-
goodbye(params: { auth: string }) {
|
|
87
|
-
let query = "goodbye";
|
|
88
|
-
query += qs.stringify(params, "&");
|
|
89
|
-
return this.request<Success>(query);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Email a new password to the user (if allowed) using a reset token.
|
|
94
|
-
* @remarks MINIMUM_API_VERSION=6.1.0
|
|
95
|
-
* @param params.auth Password reset token
|
|
96
|
-
* @see {@link https://ampache.org/api/api-json-methods#lost_password}
|
|
97
|
-
*/
|
|
98
|
-
lostPassword(params: { auth: string }) {
|
|
99
|
-
let query = "lost_password";
|
|
100
|
-
query += qs.stringify(params, "&");
|
|
101
|
-
return this.request<Success>(query);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Encrypt your password into the accepted format.
|
|
106
|
-
*/
|
|
107
|
-
encryptPassword(params: { password: string; time: number }) {
|
|
108
|
-
let key = getSHA256(params.password);
|
|
109
|
-
return getSHA256(params.time + key);
|
|
110
|
-
|
|
111
|
-
function getSHA256(text) {
|
|
112
|
-
let shaObj = new JsSHA("SHA-256", "TEXT", { encoding: "UTF8" });
|
|
113
|
-
shaObj.update(text);
|
|
114
|
-
|
|
115
|
-
return shaObj.getHash("HEX");
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|