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
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# javascript-ampache
|
|
2
|
+
|
|
3
|
+
A JS client for the Ampache API written in Typescript.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install javascript-ampache
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Import `javascript-ampache` module in your project and initialize it with the URL to your server e.g. http://music.com.au
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import AmpacheAPI from 'javascript-ampache';
|
|
17
|
+
|
|
18
|
+
const API = new AmpacheAPI({ url: 'http://pathToYourAmpacheServer' }); // debug: true - will log the final GET to console
|
|
19
|
+
|
|
20
|
+
let allUsers = API.users();
|
|
21
|
+
|
|
22
|
+
let thisAlbum = API.album({ filter: 123 });
|
|
23
|
+
|
|
24
|
+
let results = API.advancedSearch({
|
|
25
|
+
type: "album",
|
|
26
|
+
operator: "and",
|
|
27
|
+
random: 1,
|
|
28
|
+
limit: 20,
|
|
29
|
+
rules: [
|
|
30
|
+
['title', 0, 'monkey'], // Title contains 'monkey'
|
|
31
|
+
['myrating', 2, 4] // Rating is 4 stars
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Build
|
|
37
|
+
```bash
|
|
38
|
+
npm run build
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Special thanks
|
|
42
|
+
https://lyamkin.com/blog/how-to-build-api-client-library-in-js/ & https://github.com/ilyamkin/dev-to-js
|
|
43
|
+
|
|
44
|
+
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Album } from './types';
|
|
2
|
+
import { Base, BinaryBoolean, Pagination, UID } from '../base';
|
|
3
|
+
export declare class Albums extends Base {
|
|
4
|
+
/**
|
|
5
|
+
* This returns albums based on the provided search filters
|
|
6
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
7
|
+
* @param [params.filter] UID to find
|
|
8
|
+
* @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
|
|
9
|
+
* @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
|
|
10
|
+
* @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
|
|
11
|
+
* @param [params.include] albums, songs (include child objects in the response)
|
|
12
|
+
* @param [params.offset]
|
|
13
|
+
* @param [params.limit]
|
|
14
|
+
* @see {@link https://ampache.org/api/api-json-methods#albums}
|
|
15
|
+
*/
|
|
16
|
+
albums(params?: {
|
|
17
|
+
filter?: number;
|
|
18
|
+
exact?: BinaryBoolean;
|
|
19
|
+
add?: Date;
|
|
20
|
+
update?: Date;
|
|
21
|
+
include?: "albums" | "songs";
|
|
22
|
+
} & Pagination): Promise<Album[] | {
|
|
23
|
+
album: Album[];
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* This returns a single album based on the UID provided
|
|
27
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
28
|
+
* @param params.filter UID to find
|
|
29
|
+
* @param [params.include] songs (include child objects in the response)
|
|
30
|
+
* @see {@link https://ampache.org/api/api-json-methods#album}
|
|
31
|
+
*/
|
|
32
|
+
album(params: {
|
|
33
|
+
filter: UID;
|
|
34
|
+
include?: 'songs';
|
|
35
|
+
}): Promise<Album>;
|
|
36
|
+
/**
|
|
37
|
+
* This returns the albums of an artist
|
|
38
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
39
|
+
* @param params.filter UID to find
|
|
40
|
+
* @param [params.offset]
|
|
41
|
+
* @param [params.limit]
|
|
42
|
+
* @see {@link https://ampache.org/api/api-json-methods#artist_albums}
|
|
43
|
+
*/
|
|
44
|
+
artistAlbums(params: {
|
|
45
|
+
filter: UID;
|
|
46
|
+
} & Pagination): Promise<Album[] | {
|
|
47
|
+
album: Album[];
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* This returns the albums associated with the genre in question
|
|
51
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
52
|
+
* @param params.filter UID to find
|
|
53
|
+
* @param [params.offset]
|
|
54
|
+
* @param [params.limit]
|
|
55
|
+
* @see {@link https://ampache.org/api/api-json-methods#genre_albums}
|
|
56
|
+
*/
|
|
57
|
+
genreAlbums(params?: {
|
|
58
|
+
filter: UID;
|
|
59
|
+
} & Pagination): Promise<Album[] | {
|
|
60
|
+
album: Album[];
|
|
61
|
+
}>;
|
|
62
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { UID } from '../base';
|
|
2
|
+
import { GenreSummary } from "../genres/types";
|
|
3
|
+
import { ArtistSummary } from "../artists/types";
|
|
4
|
+
import { Song } from "../songs/types";
|
|
5
|
+
export type AlbumSummary = {
|
|
6
|
+
id: UID;
|
|
7
|
+
name: string;
|
|
8
|
+
prefix: string | null;
|
|
9
|
+
basename: string;
|
|
10
|
+
};
|
|
11
|
+
export type Album = {
|
|
12
|
+
id: UID;
|
|
13
|
+
name: string;
|
|
14
|
+
prefix: string | null;
|
|
15
|
+
basename: string;
|
|
16
|
+
artist: ArtistSummary;
|
|
17
|
+
time: number;
|
|
18
|
+
year: number | string;
|
|
19
|
+
tracks?: Song[];
|
|
20
|
+
songcount: number;
|
|
21
|
+
disccount: number;
|
|
22
|
+
type: string | null;
|
|
23
|
+
genre: GenreSummary[];
|
|
24
|
+
art: string;
|
|
25
|
+
flag: boolean;
|
|
26
|
+
rating: number | null;
|
|
27
|
+
averagerating: number | null;
|
|
28
|
+
mbid: string | null;
|
|
29
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Artist } from './types';
|
|
2
|
+
import { Base, BinaryBoolean, Pagination, UID } from '../base';
|
|
3
|
+
export declare class Artists extends Base {
|
|
4
|
+
/**
|
|
5
|
+
* This takes a collection of inputs and returns artist objects
|
|
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.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
|
|
10
|
+
* @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
|
|
11
|
+
* @param [params.include] (albums | songs) include child objects in the response
|
|
12
|
+
* @param [params.album_artist] 0, 1 (if true filter for album artists only)
|
|
13
|
+
* @param [params.offset]
|
|
14
|
+
* @param [params.limit]
|
|
15
|
+
* @see {@link https://ampache.org/api/api-json-methods#artists}
|
|
16
|
+
*/
|
|
17
|
+
artists(params?: {
|
|
18
|
+
filter?: string;
|
|
19
|
+
exact?: BinaryBoolean;
|
|
20
|
+
add?: Date;
|
|
21
|
+
update?: Date;
|
|
22
|
+
include?: 'albums' | 'songs';
|
|
23
|
+
album_artist?: BinaryBoolean;
|
|
24
|
+
} & Pagination): Promise<Artist[] | {
|
|
25
|
+
artist: Artist[];
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* This returns a single artist based on the UID of said artist
|
|
29
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
30
|
+
* @param params.filter UID to find
|
|
31
|
+
* @param [params.include] (albums | songs) include child objects in the response
|
|
32
|
+
* @see {@link https://ampache.org/api/api-json-methods#artist}
|
|
33
|
+
*/
|
|
34
|
+
artist(params: {
|
|
35
|
+
filter: UID;
|
|
36
|
+
include?: 'albums' | 'songs';
|
|
37
|
+
}): Promise<Artist>;
|
|
38
|
+
/**
|
|
39
|
+
* This returns the artists associated with the genre in question as defined by the UID
|
|
40
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
41
|
+
* @param params.filter UID to find
|
|
42
|
+
* @param [params.offset]
|
|
43
|
+
* @param [params.limit]
|
|
44
|
+
* @see {@link https://ampache.org/api/api-json-methods#genre_artists}
|
|
45
|
+
*/
|
|
46
|
+
genreArtists(params: {
|
|
47
|
+
filter: UID;
|
|
48
|
+
} & Pagination): Promise<Artist[] | {
|
|
49
|
+
artist: Artist[];
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* This returns the artists associated with the label in question as defined by the UID
|
|
53
|
+
* @remarks MINIMUM_API_VERSION=420000
|
|
54
|
+
* @param params.filter UID of find
|
|
55
|
+
* @param [params.offset]
|
|
56
|
+
* @param [params.limit]
|
|
57
|
+
* @see {@link https://ampache.org/api/api-json-methods#label_artists}
|
|
58
|
+
*/
|
|
59
|
+
labelArtists(params: {
|
|
60
|
+
filter: UID;
|
|
61
|
+
} & Pagination): Promise<Artist[] | {
|
|
62
|
+
artist: Artist[];
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Album } from "../albums/types";
|
|
2
|
+
import { Song } from "../songs/types";
|
|
3
|
+
import { Genre } from "../genres/types";
|
|
4
|
+
export type ArtistSummary = {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
prefix: string | null;
|
|
8
|
+
basename: string;
|
|
9
|
+
};
|
|
10
|
+
export type Artist = {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
prefix: string | null;
|
|
14
|
+
basename: string;
|
|
15
|
+
albums: Album[];
|
|
16
|
+
albumcount: number;
|
|
17
|
+
songs: Song[];
|
|
18
|
+
songcount: number;
|
|
19
|
+
genre: Genre[];
|
|
20
|
+
art: string;
|
|
21
|
+
flag: boolean;
|
|
22
|
+
rating: number | null;
|
|
23
|
+
averagerating: number | null;
|
|
24
|
+
mbid: string | null;
|
|
25
|
+
summary: string;
|
|
26
|
+
time: number;
|
|
27
|
+
yearformed: number;
|
|
28
|
+
placeformed: string;
|
|
29
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Base, Success } from "../base";
|
|
2
|
+
import { AuthResponse } from './types';
|
|
3
|
+
export declare class Auth extends Base {
|
|
4
|
+
/**
|
|
5
|
+
* Handles verifying a new handshake
|
|
6
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
7
|
+
* @param params.auth encrypted apikey OR password if using password auth
|
|
8
|
+
* @param [params.user] username
|
|
9
|
+
* @param [params.timestamp] UNIXTIME()
|
|
10
|
+
* @param [params.version] version of Ampache API to establish connection with
|
|
11
|
+
* @see {@link https://ampache.org/api/api-json-methods#handshake}
|
|
12
|
+
*/
|
|
13
|
+
handshake(params: {
|
|
14
|
+
auth: string;
|
|
15
|
+
user?: string;
|
|
16
|
+
timestamp?: number;
|
|
17
|
+
version?: string;
|
|
18
|
+
}): Promise<AuthResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* This can be called without being authenticated, it is useful for determining if what the status
|
|
21
|
+
* of the server is, and what version it is running/compatible with
|
|
22
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
23
|
+
* @param [params.auth] (Session ID) returns version information and extends the session if passed
|
|
24
|
+
* @param [params.version] API Version that the application understands
|
|
25
|
+
* @see {@link https://ampache.org/api/api-json-methods#ping}
|
|
26
|
+
*/
|
|
27
|
+
ping(params?: {
|
|
28
|
+
auth?: string;
|
|
29
|
+
version?: string;
|
|
30
|
+
}): Promise<AuthResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* Destroy a session using the session auth parameter
|
|
33
|
+
* @remarks MINIMUM_API_VERSION=400001
|
|
34
|
+
* @param params.auth Session ID to destroy
|
|
35
|
+
* @see {@link https://ampache.org/api/api-json-methods#goodbye}
|
|
36
|
+
*/
|
|
37
|
+
goodbye(params: {
|
|
38
|
+
auth: any;
|
|
39
|
+
}): Promise<Success>;
|
|
40
|
+
/**
|
|
41
|
+
* Encrypt your password into the accepted format.
|
|
42
|
+
*/
|
|
43
|
+
encryptPassword(params: {
|
|
44
|
+
password: string;
|
|
45
|
+
time: number;
|
|
46
|
+
}): string;
|
|
47
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type AuthResponse = {
|
|
2
|
+
auth: string;
|
|
3
|
+
api: string;
|
|
4
|
+
session_expire: string;
|
|
5
|
+
update: string;
|
|
6
|
+
add: string;
|
|
7
|
+
clean: string;
|
|
8
|
+
songs: number;
|
|
9
|
+
albums: number;
|
|
10
|
+
artists: number;
|
|
11
|
+
genres: number;
|
|
12
|
+
playlists: number;
|
|
13
|
+
user: number;
|
|
14
|
+
catalogs: number;
|
|
15
|
+
videos: number;
|
|
16
|
+
podcasts: number;
|
|
17
|
+
podcast_episodes: number;
|
|
18
|
+
shares: number;
|
|
19
|
+
licenses: number;
|
|
20
|
+
live_streams: number;
|
|
21
|
+
labels: number;
|
|
22
|
+
};
|
package/dist/base.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type Config = {
|
|
2
|
+
url: string;
|
|
3
|
+
sessionKey?: string;
|
|
4
|
+
debug?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type Success = {
|
|
7
|
+
success: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* @param [offset] Return results starting from this index position
|
|
11
|
+
* @param [limit] Maximum number of results to return
|
|
12
|
+
*/
|
|
13
|
+
export type Pagination = {
|
|
14
|
+
offset?: number;
|
|
15
|
+
limit?: number;
|
|
16
|
+
};
|
|
17
|
+
export type BinaryBoolean = 0 | 1;
|
|
18
|
+
export type UID = string | number;
|
|
19
|
+
export declare abstract class Base {
|
|
20
|
+
sessionKey: string;
|
|
21
|
+
url: string;
|
|
22
|
+
version: string;
|
|
23
|
+
debug: boolean;
|
|
24
|
+
constructor(config: Config);
|
|
25
|
+
protected request<T>(endpoint: string, includeAuth?: boolean): Promise<T>;
|
|
26
|
+
setSessionKey(sessionKey: string): void;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Bookmark } from './types';
|
|
2
|
+
import { Base, Success, UID } from '../base';
|
|
3
|
+
export declare class Bookmarks extends Base {
|
|
4
|
+
/**
|
|
5
|
+
* Get information about bookmarked media this user is allowed to manage
|
|
6
|
+
* @remarks MINIMUM_API_VERSION=5.0.0
|
|
7
|
+
* @see {@link https://ampache.org/api/api-json-methods#bookmarks}
|
|
8
|
+
*/
|
|
9
|
+
bookmarks(): Promise<Bookmark[] | {
|
|
10
|
+
bookmark: Bookmark[];
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Get the bookmark from it's object_id and object_type.
|
|
14
|
+
* @remarks MINIMUM_API_VERSION=5.0.0
|
|
15
|
+
* @param params.filter UID to find
|
|
16
|
+
* @param params.type Object type
|
|
17
|
+
* @see {@link https://ampache.org/api/api-json-methods#get_bookmark}
|
|
18
|
+
*/
|
|
19
|
+
getBookmark(params: {
|
|
20
|
+
filter: UID;
|
|
21
|
+
type: 'song' | 'video' | 'podcast_episode';
|
|
22
|
+
}): Promise<Bookmark>;
|
|
23
|
+
/**
|
|
24
|
+
* Create a placeholder for the current media that you can return to later.
|
|
25
|
+
* @remarks MINIMUM_API_VERSION=5.0.0
|
|
26
|
+
* @param params.filter UID to find
|
|
27
|
+
* @param params.type Object type
|
|
28
|
+
* @param params.position current track time in seconds
|
|
29
|
+
* @param [params.client] Agent string. (Default: 'AmpacheAPI')
|
|
30
|
+
* @param [params.date] update time (Default: UNIXTIME())
|
|
31
|
+
* @see {@link https://ampache.org/api/api-json-methods#bookmark_create}
|
|
32
|
+
*/
|
|
33
|
+
bookmarkCreate(params: {
|
|
34
|
+
filter: UID;
|
|
35
|
+
type: 'song' | 'video' | 'podcast_episode';
|
|
36
|
+
position: number;
|
|
37
|
+
client?: string;
|
|
38
|
+
date?: number;
|
|
39
|
+
}): Promise<Bookmark>;
|
|
40
|
+
/**
|
|
41
|
+
* Edit a placeholder for the current media that you can return to later.
|
|
42
|
+
* @remarks MINIMUM_API_VERSION=5.0.0
|
|
43
|
+
* @param params.filter UID to find
|
|
44
|
+
* @param params.type Object type
|
|
45
|
+
* @param params.position current track time in seconds
|
|
46
|
+
* @param [params.client] Agent string. (Default: 'AmpacheAPI')
|
|
47
|
+
* @param [params.date] update time (Default: UNIXTIME())
|
|
48
|
+
* @see {@link https://ampache.org/api/api-json-methods#bookmark_edit}
|
|
49
|
+
*/
|
|
50
|
+
bookmarkEdit(params: {
|
|
51
|
+
filter: UID;
|
|
52
|
+
type: 'song' | 'video' | 'podcast_episode';
|
|
53
|
+
position: number;
|
|
54
|
+
client?: string;
|
|
55
|
+
date?: number;
|
|
56
|
+
}): Promise<Bookmark>;
|
|
57
|
+
/**
|
|
58
|
+
* Delete an existing bookmark. (if it exists)
|
|
59
|
+
* @remarks MINIMUM_API_VERSION=5.0.0
|
|
60
|
+
* @param params.filter UID to find
|
|
61
|
+
* @param params.type Object type
|
|
62
|
+
* @param [params.client] Agent string. (Default: 'AmpacheAPI')
|
|
63
|
+
@see {@link https://ampache.org/api/api-json-methods#bookmark_delete}
|
|
64
|
+
*/
|
|
65
|
+
bookmarkDelete(params: {
|
|
66
|
+
filter: UID;
|
|
67
|
+
type: 'song' | 'video' | 'podcast_episode';
|
|
68
|
+
client?: string;
|
|
69
|
+
}): Promise<Success>;
|
|
70
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Catalog } from './types';
|
|
2
|
+
import { Base, Success, UID } from '../base';
|
|
3
|
+
export declare class Catalogs extends Base {
|
|
4
|
+
/**
|
|
5
|
+
* This searches the catalogs and returns... catalogs
|
|
6
|
+
* @remarks MINIMUM_API_VERSION=420000
|
|
7
|
+
* @param [params.filter] Catalog type
|
|
8
|
+
* @see {@link https://ampache.org/api/api-json-methods#catalogs}
|
|
9
|
+
*/
|
|
10
|
+
catalogs(params?: {
|
|
11
|
+
filter?: 'music' | 'clip' | 'tvshow' | 'movie' | 'personal_video' | 'podcast';
|
|
12
|
+
}): Promise<Catalog[] | {
|
|
13
|
+
catalog: Catalog[];
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Return catalog by UID
|
|
17
|
+
* @remarks MINIMUM_API_VERSION=420000
|
|
18
|
+
* @param params.filter UID to find
|
|
19
|
+
* @see {@link https://ampache.org/api/api-json-methods#catalog}
|
|
20
|
+
*/
|
|
21
|
+
catalog(params: {
|
|
22
|
+
filter: UID;
|
|
23
|
+
}): Promise<Catalog>;
|
|
24
|
+
/**
|
|
25
|
+
* Kick off a catalog update or clean for the selected catalog
|
|
26
|
+
* ACCESS REQUIRED: 75 (Catalog Manager)
|
|
27
|
+
* @remarks MINIMUM_API_VERSION=400001
|
|
28
|
+
* @param params.task add_to_catalog, clean_catalog
|
|
29
|
+
* @param params.catalog UID of catalog
|
|
30
|
+
* @see {@link https://ampache.org/api/api-json-methods#catalog_action}
|
|
31
|
+
*/
|
|
32
|
+
catalogAction(params: {
|
|
33
|
+
task: 'add_to_catalog' | 'clean_catalog';
|
|
34
|
+
catalog: UID;
|
|
35
|
+
}): Promise<Success>;
|
|
36
|
+
/**
|
|
37
|
+
* Perform actions on local catalog files. Single file versions of catalog add, clean, verify and remove (delete).
|
|
38
|
+
* Make sure you remember to urlencode those file names!
|
|
39
|
+
* ACCESS REQUIRED: 50 (Content Manager)
|
|
40
|
+
* @remarks MINIMUM_API_VERSION=420000
|
|
41
|
+
* @param params.file FULL path to local file
|
|
42
|
+
* @param params.task add, clean, verify, remove, (can include comma-separated values)
|
|
43
|
+
* @param params.catalog UID of catalog
|
|
44
|
+
* @see {@link https://ampache.org/api/api-json-methods#catalog_file}
|
|
45
|
+
*/
|
|
46
|
+
catalogFile(params: {
|
|
47
|
+
file: string;
|
|
48
|
+
task: string;
|
|
49
|
+
catalog: UID;
|
|
50
|
+
}): Promise<Success>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { UID } from "../base";
|
|
2
|
+
export type Catalog = {
|
|
3
|
+
id: UID;
|
|
4
|
+
name: string;
|
|
5
|
+
type: 'local' | 'remote';
|
|
6
|
+
gather_types: 'podcast' | 'clip' | 'tvshow' | 'movie' | 'personal_video' | 'music';
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
last_add: number;
|
|
9
|
+
last_clean: number;
|
|
10
|
+
last_update: number;
|
|
11
|
+
path: string;
|
|
12
|
+
rename_pattern: string;
|
|
13
|
+
sort_pattern: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Genre } from './types';
|
|
2
|
+
import { Base, BinaryBoolean, Pagination, UID } from '../base';
|
|
3
|
+
export declare class Genres extends Base {
|
|
4
|
+
/**
|
|
5
|
+
* This returns the genres (Tags) based on the specified filter
|
|
6
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
7
|
+
* @param [params.filter] UID to find
|
|
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#genres}
|
|
12
|
+
*/
|
|
13
|
+
genres(params?: {
|
|
14
|
+
filter?: string;
|
|
15
|
+
exact?: BinaryBoolean;
|
|
16
|
+
} & Pagination): Promise<Genre[] | {
|
|
17
|
+
genre: Genre[];
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* This returns a single genre based on UID
|
|
21
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
22
|
+
* @param params.filter UID to find
|
|
23
|
+
* @see {@link https://ampache.org/api/api-json-methods#genre}
|
|
24
|
+
*/
|
|
25
|
+
genre(params: {
|
|
26
|
+
filter: UID;
|
|
27
|
+
}): Promise<Genre[] | {
|
|
28
|
+
genre: Genre[];
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UID } from "../base";
|
|
2
|
+
export type GenreSummary = {
|
|
3
|
+
id: UID;
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
export type Genre = {
|
|
7
|
+
id: UID;
|
|
8
|
+
name: string;
|
|
9
|
+
albums: number;
|
|
10
|
+
artists: number;
|
|
11
|
+
songs: number;
|
|
12
|
+
videos: number;
|
|
13
|
+
playlists: number;
|
|
14
|
+
live_streams: number;
|
|
15
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Albums } from './albums';
|
|
2
|
+
import { Artists } from './artists';
|
|
3
|
+
import { Auth } from './auth';
|
|
4
|
+
import { Bookmarks } from './bookmarks';
|
|
5
|
+
import { Catalogs } from './catalogs';
|
|
6
|
+
import { Genres } from './genres';
|
|
7
|
+
import { Labels } from './labels';
|
|
8
|
+
import { Licenses } from './licenses';
|
|
9
|
+
import { LiveStreams } from './live-streams';
|
|
10
|
+
import { Playlists } from './playlists';
|
|
11
|
+
import { Podcasts } from './podcasts';
|
|
12
|
+
import { Preferences } from './preferences';
|
|
13
|
+
import { Shares } from './shares';
|
|
14
|
+
import { Shouts } from './shouts';
|
|
15
|
+
import { Songs } from './songs';
|
|
16
|
+
import { System } from './system';
|
|
17
|
+
import { Users } from './users';
|
|
18
|
+
import { Videos } from './videos';
|
|
19
|
+
import { Base } from './base';
|
|
20
|
+
declare class AmpacheAPI extends Base {
|
|
21
|
+
}
|
|
22
|
+
interface AmpacheAPI extends Albums, Artists, Auth, Bookmarks, Catalogs, Genres, Labels, Licenses, LiveStreams, Playlists, Podcasts, Preferences, Shares, Shouts, Songs, System, Users, Videos {
|
|
23
|
+
}
|
|
24
|
+
export default AmpacheAPI;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=require("querystringify"),t=require("isomorphic-unfetch"),r=require("jssha/dist/sha256");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=n(e),i=n(t),u=n(r);function o(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,a(e,t)}function a(e,t){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},a(e,t)}var c,f=function(){function e(e){this.sessionKey=void 0,this.url=void 0,this.version="6.0.0",this.debug=void 0,this.sessionKey=e.sessionKey||null,this.url=e.url,this.debug=e.debug||!1}var t=e.prototype;return t.request=function(e,t){void 0===t&&(t=!0);var r=this.url+"/server/json.server.php?action="+e;return t&&(r+="&auth="+this.sessionKey+"&version="+this.version),this.debug&&console.debug("javascript-ampache query URL %c"+r,"color: black; font-style: italic; background-color: orange;padding: 2px"),i.default(r).then(function(e){if(e.ok)return e.json();throw new Error(e.statusText)})},t.setSessionKey=function(e){this.sessionKey=e},e}(),l=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.albums=function(e){try{var t="albums";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.album?e.album:e})}catch(e){return Promise.reject(e)}},r.album=function(e){var t="album";return t+=s.default.stringify(e,"&"),this.request(t)},r.artistAlbums=function(e){try{var t="artist_albums";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.album?e.album:e})}catch(e){return Promise.reject(e)}},r.genreAlbums=function(e){try{var t="genre_albums";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.album?e.album:e})}catch(e){return Promise.reject(e)}},t}(f),h=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.artists=function(e){try{var t="artists";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.artist?e.artist:e})}catch(e){return Promise.reject(e)}},r.artist=function(e){var t="artist";return t+=s.default.stringify(e,"&"),this.request(t)},r.genreArtists=function(e){try{var t="genre_artists";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.artist?e.artist:e})}catch(e){return Promise.reject(e)}},r.labelArtists=function(e){try{var t="label_artists";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.artist?e.artist:e})}catch(e){return Promise.reject(e)}},t}(f),d=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.handshake=function(e){var t=this;e.timestamp||(e.timestamp=Math.floor((new Date).getTime()/1e3)),e.version&&(this.version=e.version),e.user||delete e.timestamp;var r=this.url+"/server/json.server.php?action=handshake";return r+=s.default.stringify(e,"&"),i.default(r).then(function(e){return e.json()}).then(function(e){return e.auth&&(t.sessionKey=e.auth),e})},r.ping=function(e){var t="ping";return t+=s.default.stringify(e,"&"),this.request(t,!1)},r.goodbye=function(e){var t="goodbye";return t+=s.default.stringify(e,"&"),this.request(t,!1)},r.encryptPassword=function(e){var t=r(e.password);return r(e.time+t);function r(e){var t=new u.default("SHA-256","TEXT",{encoding:"UTF8"});return t.update(e),t.getHash("HEX")}},t}(f),y=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.bookmarks=function(){try{return Promise.resolve(this.request("bookmarks")).then(function(e){return e.bookmark?e.bookmark:e})}catch(e){return Promise.reject(e)}},r.getBookmark=function(e){var t="get_bookmark";return t+=s.default.stringify(e,"&"),this.request(t)},r.bookmarkCreate=function(e){var t="bookmark_create";return t+=s.default.stringify(e,"&"),this.request(t)},r.bookmarkEdit=function(e){var t="bookmark_edit";return t+=s.default.stringify(e,"&"),this.request(t)},r.bookmarkDelete=function(e){var t="bookmark_delete";return t+=s.default.stringify(e,"&"),this.request(t)},t}(f),p=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.catalogs=function(e){try{var t="catalogs";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.catalog?e.catalog:e})}catch(e){return Promise.reject(e)}},r.catalog=function(e){var t="catalog";return t+=s.default.stringify(e,"&"),this.request(t)},r.catalogAction=function(e){var t="catalog_action";return t+=s.default.stringify(e,"&"),this.request(t)},r.catalogFile=function(e){var t="catalog_file";return t+=s.default.stringify(e,"&"),this.request(t)},t}(f),v=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.genres=function(e){try{var t="genres";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.genre?e.genre:e})}catch(e){return Promise.reject(e)}},r.genre=function(e){try{var t="genre";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.genre?e.genre:e})}catch(e){return Promise.reject(e)}},t}(f),g=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.labels=function(e){try{var t="labels";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.label?e.label:e})}catch(e){return Promise.reject(e)}},r.label=function(e){var t="label";return t+=s.default.stringify(e,"&"),this.request(t)},t}(f),m=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.licenses=function(e){try{var t="licenses";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.license?e.license:e})}catch(e){return Promise.reject(e)}},r.license=function(e){var t="license";return t+=s.default.stringify(e,"&"),this.request(t)},t}(f),P=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.liveStreams=function(e){try{var t="live_streams";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.live_stream?e.live_stream:e})}catch(e){return Promise.reject(e)}},r.liveStream=function(e){var t="live_stream";return t+=s.default.stringify(e,"&"),this.request(t)},t}(f),q=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.playlists=function(e){try{var t="playlists";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.playlist?e.playlist:e})}catch(e){return Promise.reject(e)}},r.smartlists=function(e){try{var t="playlists";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){var t=e.playlist?e.playlist:e;return Array.isArray(t)&&(t=t.filter(function(e){return e.id.toString().match(/^smart_/)})),t})}catch(e){return Promise.reject(e)}},r.playlist=function(e){var t="playlist";return t+=s.default.stringify(e,"&"),this.request(t)},r.playlistCreate=function(e){var t="playlist_create";return t+=s.default.stringify(e,"&"),this.request(t)},r.playlistEdit=function(e){var t="playlist_edit";return t+=s.default.stringify(e,"&"),this.request(t)},r.playlistDelete=function(e){var t="playlist_delete";return t+=s.default.stringify(e,"&"),this.request(t)},r.playlistAddSong=function(e){var t="playlist_add_song";return t+=s.default.stringify(e,"&"),this.request(t)},r.playlistRemoveSong=function(e){var t="playlist_remove_song";return t+=s.default.stringify(e,"&"),this.request(t)},r.playlistGenerate=function(e){try{var t="playlist_generate";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},t}(f),_=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.podcasts=function(e){try{var t="podcasts";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.podcast?e.podcast:e})}catch(e){return Promise.reject(e)}},r.podcast=function(e){try{var t="podcast";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.podcast?e.podcast:e})}catch(e){return Promise.reject(e)}},r.podcastCreate=function(e){var t="podcast_create";return t+=s.default.stringify(e,"&"),this.request(t)},r.podcastEdit=function(e){var t="podcast_edit";return t+=s.default.stringify(e,"&"),this.request(t)},r.podcastDelete=function(e){var t="podcast_delete";return t+=s.default.stringify(e,"&"),this.request(t)},r.podcastEpisodes=function(e){try{var t="podcast_episodes";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.podcast_episode?e.podcast_episode:e})}catch(e){return Promise.reject(e)}},r.podcastEpisode=function(e){var t="podcast_episode";return t+=s.default.stringify(e,"&"),this.request(t)},r.podcastEpisodeDelete=function(e){var t="podcast_episode_delete";return t+=s.default.stringify(e,"&"),this.request(t)},r.updatePodcast=function(e){var t="update_podcast";return t+=s.default.stringify(e,"&"),this.request(t)},r.deletedPodcastEpisodes=function(e){try{var t="deleted_podcast_episodes";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.deleted_podcast_episode?e.deleted_podcast_episode:e})}catch(e){return Promise.reject(e)}},t}(f),b=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.systemPreferences=function(){try{return Promise.resolve(this.request("system_preferences")).then(function(e){return e.preference?e.preference:e})}catch(e){return Promise.reject(e)}},r.systemPreference=function(e){try{var t="system_preference";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e[0]})}catch(e){return Promise.reject(e)}},r.userPreferences=function(){try{return Promise.resolve(this.request("user_preferences")).then(function(e){return e.preference?e.preference:e})}catch(e){return Promise.reject(e)}},r.userPreference=function(e){try{var t="user_preference";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e[0]})}catch(e){return Promise.reject(e)}},r.preferenceCreate=function(e){var t="preference_create";return t+=s.default.stringify(e,"&"),this.request(t)},r.preferenceEdit=function(e){var t="preference_edit";return t+=s.default.stringify(e,"&"),this.request(t)},r.preferenceDelete=function(e){var t="preference_delete";return t+=s.default.stringify(e,"&"),this.request(t)},t}(f),j=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.shares=function(e){try{var t="shares";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.share?e.share:e})}catch(e){return Promise.reject(e)}},r.share=function(e){var t="share";return t+=s.default.stringify(e,"&"),this.request(t)},r.shareCreate=function(e){var t="share_create";return t+=s.default.stringify(e,"&"),this.request(t)},r.shareEdit=function(e){var t="share_edit";return t+=s.default.stringify(e,"&"),this.request(t)},r.shareDelete=function(e){var t="share_delete";return t+=s.default.stringify(e,"&"),this.request(t)},t}(f),k=function(e){function t(){return e.apply(this,arguments)||this}return o(t,e),t.prototype.last_shouts=function(e){try{var t="last_shouts";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.shout?e.shout:e})}catch(e){return Promise.reject(e)}},t}(f),w=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.songs=function(e){try{var t="songs";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},r.song=function(e){var t="song";return t+=s.default.stringify(e,"&"),this.request(t)},r.artistSongs=function(e){try{var t="artist_songs";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},r.albumSongs=function(e){try{var t="album_songs";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},r.genreSongs=function(e){try{var t="genre_songs";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},r.playlistSongs=function(e){try{var t="playlist_songs";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},r.licenseSongs=function(e){try{var t="license_songs";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},r.songDelete=function(e){var t="song_delete";return t+=s.default.stringify(e,"&"),this.request(t)},r.urlToSong=function(e){var t="url_to_song";return e.url=encodeURIComponent(e.url),t+=s.default.stringify(e,"&"),this.request(t)},r.searchSongs=function(e){try{var t="search_songs";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.song?e.song:e})}catch(e){return Promise.reject(e)}},r.deletedSongs=function(e){try{var t="deleted_songs";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.deleted_song?e.deleted_song:e})}catch(e){return Promise.reject(e)}},t}(f),S=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.systemUpdate=function(){return this.request("system_update")},r.getIndexes=function(e){try{var t,r=this,n="get_indexes";switch(n+=s.default.stringify(e,"&"),e.type){case"song":return Promise.resolve(r.request(n)).then(function(e){return(t=e).song?t.song:t});case"album":return Promise.resolve(r.request(n)).then(function(e){return(t=e).album?t.album:t});case"artist":case"album_artist":return Promise.resolve(r.request(n)).then(function(e){return(t=e).artist?t.artist:t});case"playlist":return Promise.resolve(r.request(n)).then(function(e){return(t=e).playlist?t.playlist:t});case"podcast":return Promise.resolve(r.request(n)).then(function(e){return(t=e).podcast?t.podcast:t});case"podcast_episode":return Promise.resolve(r.request(n)).then(function(e){return(t=e).podcast_episode?t.podcast_episode:t});case"live_stream":return Promise.resolve(r.request(n)).then(function(e){return(t=e).live_stream?t.live_stream:t});default:return Promise.resolve(!1)}}catch(e){return Promise.reject(e)}},r.getSimilar=function(e){try{var t,r="get_similar";switch(r+=s.default.stringify(e,"&"),e.type){case"song":return Promise.resolve(this.request(r)).then(function(e){return(t=e).song?t.song:t});case"artist":return Promise.resolve(this.request(r)).then(function(e){return(t=e).artist?t.artist:t});default:return Promise.resolve(!1)}}catch(e){return Promise.reject(e)}},r.stats=function(e){try{var t,r=this,n="stats";switch(n+=s.default.stringify(e,"&"),e.type){case"song":return Promise.resolve(r.request(n)).then(function(e){return(t=e).song?t.song:t});case"album":return Promise.resolve(r.request(n)).then(function(e){return(t=e).album?t.album:t});case"artist":return Promise.resolve(r.request(n)).then(function(e){return(t=e).artist?t.artist:t});case"video":return Promise.resolve(r.request(n)).then(function(e){return(t=e).video?t.video:t});case"playlist":return Promise.resolve(r.request(n)).then(function(e){return(t=e).playlist?t.playlist:t});case"podcast":return Promise.resolve(r.request(n)).then(function(e){return(t=e).podcast?t.podcast:t});case"podcast_episode":return Promise.resolve(r.request(n)).then(function(e){return(t=e).podcast_episode?t.podcast_episode:t});default:return Promise.resolve(!1)}}catch(e){return Promise.reject(e)}},r.rate=function(e){var t="rate";return t+=s.default.stringify(e,"&"),this.request(t)},r.flag=function(e){var t="flag";return t+=s.default.stringify(e,"&"),this.request(t)},r.recordPlay=function(e){var t="record_play";return t+=s.default.stringify(e,"&"),this.request(t)},r.scrobble=function(e){var t="scrobble";return t+=s.default.stringify(e,"&"),this.request(t)},r.updateFromTags=function(e){var t="update_from_tags";return t+=s.default.stringify(e,"&"),this.request(t)},r.updateArtistInfo=function(e){var t="update_artist_info";return t+=s.default.stringify(e,"&"),this.request(t)},r.updateArt=function(e){var t="update_art";return t+=s.default.stringify(e,"&"),this.request(t)},r.stream=function(e){var t="stream";return t+=s.default.stringify(e,"&"),this.request(t)},r.download=function(e){var t="download";return t+=s.default.stringify(e,"&"),this.request(t)},r.getArt=function(e){var t="get_art";return t+=s.default.stringify(e,"&"),this.request(t)},r.localplay=function(e){var t="localplay";return t+=s.default.stringify(e,"&"),this.request(t)},r.localplaySongs=function(){return this.request("localplay_songs")},r.democratic=function(e){var t="democratic";return t+=s.default.stringify(e,"&"),this.request(t)},r.advancedSearch=function(e){try{for(var t,r=this,n="advanced_search",i=0;i<e.rules.length;i++){var u=e.rules[i],o=i+1;e["rule_"+o]=u[0],e["rule_"+o+"_operator"]=u[1],e["rule_"+o+"_input"]=u[2],"metadata"===u[0]&&(e["rule_"+o+"_subtype"]=u[3])}switch(delete e.rules,n+=s.default.stringify(e,"&"),e.type){case"song":return Promise.resolve(r.request(n)).then(function(e){return(t=e).song?t.song:t});case"album":return Promise.resolve(r.request(n)).then(function(e){return(t=e).album?t.album:t});case"artist":return Promise.resolve(r.request(n)).then(function(e){return(t=e).artist?t.artist:t});case"label":return Promise.resolve(r.request(n)).then(function(e){return(t=e).label?t.label:t});case"playlist":return Promise.resolve(r.request(n)).then(function(e){return(t=e).playlist?t.playlist:t});case"podcast":return Promise.resolve(r.request(n)).then(function(e){return(t=e).podcast?t.podcast:t});case"podcast_episode":return Promise.resolve(r.request(n)).then(function(e){return(t=e).podcast_episode?t.podcast_episode:t});case"genre":return Promise.resolve(r.request(n)).then(function(e){return(t=e).genre?t.genre:t});case"user":return Promise.resolve(r.request(n)).then(function(e){return(t=e).user?t.user:t});case"video":return Promise.resolve(r.request(n)).then(function(e){return(t=e).video?t.video:t});default:return Promise.resolve(!1)}}catch(e){return Promise.reject(e)}},t}(f),E=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.users=function(){try{return Promise.resolve(this.request("users")).then(function(e){return e.user?e.user:e})}catch(e){return Promise.reject(e)}},r.user=function(e){try{var t="user";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t))}catch(e){return Promise.reject(e)}},r.userCreate=function(e){var t="user_create";return t+=s.default.stringify(e,"&"),this.request(t)},r.userUpdate=function(e){var t="user_update";return t+=s.default.stringify(e,"&"),this.request(t)},r.userDelete=function(e){var t="user_delete";return t+=s.default.stringify(e,"&"),this.request(t)},r.followers=function(e){try{var t="followers";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.user?e.user:e})}catch(e){return Promise.reject(e)}},r.following=function(e){try{var t="following";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.user?e.user:e})}catch(e){return Promise.reject(e)}},r.toggleFollow=function(e){var t="toggle_follow";return t+=s.default.stringify(e,"&"),this.request(t)},r.timeline=function(e){try{var t="timeline";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.activity?e.activity:e})}catch(e){return Promise.reject(e)}},r.friendsTimeline=function(e){try{var t="friends_timeline";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.activity?e.activity:e})}catch(e){return Promise.reject(e)}},t}(f),A=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.videos=function(e){try{var t="videos";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.video?e.video:e})}catch(e){return Promise.reject(e)}},r.video=function(e){var t="video";return t+=s.default.stringify(e,"&"),this.request(t)},r.deletedVideos=function(e){try{var t="deleted_videos";return t+=s.default.stringify(e,"&"),Promise.resolve(this.request(t)).then(function(e){return e.deleted_video?e.deleted_video:e})}catch(e){return Promise.reject(e)}},t}(f),D=function(e){function t(){return e.apply(this,arguments)||this}return o(t,e),t}(f);c=D,[l,h,d,y,p,v,g,m,P,q,_,b,j,k,w,S,E,A].forEach(function(e){Object.getOwnPropertyNames(e.prototype).forEach(function(t){Object.defineProperty(c.prototype,t,Object.getOwnPropertyDescriptor(e.prototype,t))})}),module.exports=D;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|