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,42 @@
|
|
|
1
|
+
import qs from 'querystringify';
|
|
2
|
+
import { LiveStream } from './types';
|
|
3
|
+
import { Base, BinaryBoolean, Pagination, UID } from '../base';
|
|
4
|
+
|
|
5
|
+
export class LiveStreams extends Base {
|
|
6
|
+
/**
|
|
7
|
+
* This returns live_streams based on the specified filter
|
|
8
|
+
* @remarks MINIMUM_API_VERSION=5.1.0
|
|
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.offset]
|
|
14
|
+
* @param [params.limit]
|
|
15
|
+
* @see {@link https://ampache.org/api/api-json-methods#live_streams}
|
|
16
|
+
*/
|
|
17
|
+
async liveStreams (params?: {
|
|
18
|
+
filter?: string,
|
|
19
|
+
exact?: BinaryBoolean,
|
|
20
|
+
add?: Date,
|
|
21
|
+
update?: Date,
|
|
22
|
+
} & Pagination) {
|
|
23
|
+
let query = 'live_streams';
|
|
24
|
+
query += qs.stringify(params, '&');
|
|
25
|
+
let data = await this.request<{live_stream: LiveStream[]}>(query);
|
|
26
|
+
return (data.live_stream) ? data.live_stream : data;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* This returns a single live_stream
|
|
31
|
+
* @remarks MINIMUM_API_VERSION=5.1.0
|
|
32
|
+
* @param params.filter UID to find
|
|
33
|
+
* @see {@link https://ampache.org/api/api-json-methods#live_stream}
|
|
34
|
+
*/
|
|
35
|
+
liveStream (params: {
|
|
36
|
+
filter: UID,
|
|
37
|
+
}) {
|
|
38
|
+
let query = 'live_stream';
|
|
39
|
+
query += qs.stringify(params, '&');
|
|
40
|
+
return this.request<LiveStream>(query);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import qs from 'querystringify';
|
|
2
|
+
import { Playlist } from './types';
|
|
3
|
+
import { Song } from "../songs/types";
|
|
4
|
+
import { Base, BinaryBoolean, Pagination, Success, UID } from '../base';
|
|
5
|
+
|
|
6
|
+
export class Playlists extends Base {
|
|
7
|
+
/**
|
|
8
|
+
* This returns playlists based on the specified filter
|
|
9
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
10
|
+
* @param [params.filter] Filter results to match this string
|
|
11
|
+
* @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
|
|
12
|
+
* @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
|
|
13
|
+
* @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
|
|
14
|
+
* @param [params.hide_search] 0, 1 (if true do not include searches/smartlists in the result)
|
|
15
|
+
* @param [params.show_dupes] 0, 1 (if true ignore 'api_hide_dupe_searches' setting)
|
|
16
|
+
* @param [params.offset]
|
|
17
|
+
* @param [params.limit]
|
|
18
|
+
* @see {@link https://ampache.org/api/api-json-methods#playlists}
|
|
19
|
+
*/
|
|
20
|
+
async playlists (params?: {
|
|
21
|
+
filter?: string,
|
|
22
|
+
exact?: BinaryBoolean,
|
|
23
|
+
add?: Date,
|
|
24
|
+
update?: Date,
|
|
25
|
+
hide_search?: BinaryBoolean,
|
|
26
|
+
show_dupes?: BinaryBoolean,
|
|
27
|
+
} & Pagination) {
|
|
28
|
+
let query = 'playlists';
|
|
29
|
+
query += qs.stringify(params, '&');
|
|
30
|
+
let data = await this.request<{playlist: Playlist[]}>(query);
|
|
31
|
+
return (data.playlist) ? data.playlist : data;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* This returns smartlists based on the specified filter. NOTE: Filtered from Playlists() so pagination is invalid.
|
|
36
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
37
|
+
* @param [params.filter] Filter results to match this string
|
|
38
|
+
* @param [params.exact] 0, 1 (if true filter is exact = rather than fuzzy LIKE)
|
|
39
|
+
* @param [params.add] ISO 8601 Date Format (2020-09-16) Find objects with an 'add' date newer than the specified date
|
|
40
|
+
* @param [params.update] ISO 8601 Date Format (2020-09-16) Find objects with an 'update' time newer than the specified date
|
|
41
|
+
* @param [params.show_dupes] 0, 1 (if true ignore 'api_hide_dupe_searches' setting)
|
|
42
|
+
* @see {@link https://ampache.org/api/api-json-methods#playlists}
|
|
43
|
+
*/
|
|
44
|
+
async smartlists (params?: {
|
|
45
|
+
filter?: string,
|
|
46
|
+
exact?: BinaryBoolean,
|
|
47
|
+
add?: Date,
|
|
48
|
+
update?: Date,
|
|
49
|
+
show_dupes?: BinaryBoolean,
|
|
50
|
+
}) {
|
|
51
|
+
let query = 'playlists';
|
|
52
|
+
query += qs.stringify(params, '&');
|
|
53
|
+
let data = await this.request<{playlist: Playlist[]}>(query);
|
|
54
|
+
|
|
55
|
+
let results = (data.playlist) ? data.playlist : data;
|
|
56
|
+
|
|
57
|
+
// filter out regular playlists
|
|
58
|
+
if (Array.isArray(results)) {
|
|
59
|
+
results = results.filter(function(item) {
|
|
60
|
+
return item.id.toString().match(/^smart_/);
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return results;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* This returns a single playlist
|
|
69
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
70
|
+
* @param params.filter UID to find
|
|
71
|
+
* @see {@link https://ampache.org/api/api-json-methods#playlist}
|
|
72
|
+
*/
|
|
73
|
+
playlist (params: {
|
|
74
|
+
filter: UID
|
|
75
|
+
}) {
|
|
76
|
+
let query = 'playlist';
|
|
77
|
+
query += qs.stringify(params, '&');
|
|
78
|
+
return this.request<Playlist>(query);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* This creates a new playlist and returns it
|
|
83
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
84
|
+
* @param params.name Playlist name
|
|
85
|
+
* @param [params.type] public, private (Playlist type)
|
|
86
|
+
* @see {@link https://ampache.org/api/api-json-methods#playlist_create}
|
|
87
|
+
*/
|
|
88
|
+
playlistCreate (params: {
|
|
89
|
+
name: string,
|
|
90
|
+
type?: 'public' | 'private',
|
|
91
|
+
}) {
|
|
92
|
+
let query = 'playlist_create';
|
|
93
|
+
query += qs.stringify(params, '&');
|
|
94
|
+
return this.request<Playlist>(query);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* This modifies name and type of a playlist.
|
|
99
|
+
* NOTE items and tracks must be sent together and be of equal length.
|
|
100
|
+
* @remarks MINIMUM_API_VERSION=400001
|
|
101
|
+
* @param params.filter UID to find
|
|
102
|
+
* @param [params.name] Playlist name
|
|
103
|
+
* @param [params.type] public, private (Playlist type)
|
|
104
|
+
* @param [params.owner] Change playlist owner to the user id (-1 = System playlist)
|
|
105
|
+
* @param [params.items] comma-separated song_id's (replaces existing items with a new id)
|
|
106
|
+
* @param [params.tracks] comma-separated playlisttrack numbers matched to 'items' in order
|
|
107
|
+
* @see {@link https://ampache.org/api/api-json-methods#playlist_edit}
|
|
108
|
+
*/
|
|
109
|
+
playlistEdit (params: {
|
|
110
|
+
filter: UID,
|
|
111
|
+
name?: string,
|
|
112
|
+
type?: 'public' | 'private',
|
|
113
|
+
owner?: string,
|
|
114
|
+
items?: string,
|
|
115
|
+
tracks?: string,
|
|
116
|
+
}) {
|
|
117
|
+
let query = 'playlist_edit';
|
|
118
|
+
query += qs.stringify(params, '&');
|
|
119
|
+
return this.request<Success>(query);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* This deletes a playlist
|
|
124
|
+
* @remarks MINIMUM_API_VERSION=380001
|
|
125
|
+
* @param params.filter UID of playlist to delete
|
|
126
|
+
* @see {@link https://ampache.org/api/api-json-methods#playlist_delete}
|
|
127
|
+
*/
|
|
128
|
+
playlistDelete (params: {
|
|
129
|
+
filter: UID,
|
|
130
|
+
}) {
|
|
131
|
+
let query = 'playlist_delete';
|
|
132
|
+
query += qs.stringify(params, '&');
|
|
133
|
+
return this.request<Success>(query);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* This adds a song to a playlist
|
|
138
|
+
* @remarks MINIMUM_API_VERSION=380001; CHANGED_IN_API_VERSION=400003
|
|
139
|
+
* @param params.filter UID of Playlist
|
|
140
|
+
* @param params.song UID of song to add to playlist
|
|
141
|
+
* @param [params.check] 0, 1 Whether to check and ignore duplicates (default = 0)
|
|
142
|
+
* @see {@link https://ampache.org/api/api-json-methods#playlist_add_song}
|
|
143
|
+
*/
|
|
144
|
+
playlistAddSong (params: {
|
|
145
|
+
filter: UID,
|
|
146
|
+
song: UID,
|
|
147
|
+
check?: BinaryBoolean,
|
|
148
|
+
}) {
|
|
149
|
+
let query = 'playlist_add_song';
|
|
150
|
+
query += qs.stringify(params, '&');
|
|
151
|
+
return this.request<Success>(query);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* This remove a song from a playlist
|
|
156
|
+
* @remarks MINIMUM_API_VERSION=380001; CHANGED_IN_API_VERSION=400001
|
|
157
|
+
* @param params.filter UID of Playlist
|
|
158
|
+
* @param [params.song] UID of song to remove from playlist
|
|
159
|
+
* @param [params.track] Track number to remove from playlist
|
|
160
|
+
* @see {@link https://ampache.org/api/api-json-methods#playlist_remove_song}
|
|
161
|
+
*/
|
|
162
|
+
playlistRemoveSong (params: {
|
|
163
|
+
filter: UID,
|
|
164
|
+
song?: UID,
|
|
165
|
+
track?: number,
|
|
166
|
+
}) {
|
|
167
|
+
let query = 'playlist_remove_song';
|
|
168
|
+
query += qs.stringify(params, '&');
|
|
169
|
+
return this.request<Success>(query);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Get a list of song JSON, indexes or id's based on some simple search criteria
|
|
174
|
+
* @remarks MINIMUM_API_VERSION=400001; CHANGED_IN_API_VERSION=400002; 'recent' will search for tracks played after 'Popular Threshold' days; 'forgotten' will search for tracks played before 'Popular Threshold' days; 'unplayed' added in 400002 for searching unplayed tracks
|
|
175
|
+
* @param [params.mode] (default = 'random')
|
|
176
|
+
* @param [params.filter] string LIKE matched to song title
|
|
177
|
+
* @param [params.album] UID of album
|
|
178
|
+
* @param [params.artist] UID of artist
|
|
179
|
+
* @param [params.flag] 0, 1 (get flagged songs only. default = 0)
|
|
180
|
+
* @param [params.format] song, index, id (default = 'song')
|
|
181
|
+
* @param [params.offset]
|
|
182
|
+
* @param [params.limit]
|
|
183
|
+
* @see {@link https://ampache.org/api/api-json-methods#playlist_generate}
|
|
184
|
+
*/
|
|
185
|
+
async playlistGenerate (params?: {
|
|
186
|
+
mode?: 'recent' | 'forgotten' | 'unplayed' | 'random',
|
|
187
|
+
filter?: string,
|
|
188
|
+
album?: number,
|
|
189
|
+
artist?: number,
|
|
190
|
+
flag?: BinaryBoolean,
|
|
191
|
+
format?: 'song' | 'index' | 'id',
|
|
192
|
+
} & Pagination) {
|
|
193
|
+
let query = 'playlist_generate';
|
|
194
|
+
query += qs.stringify(params, '&');
|
|
195
|
+
let data = await this.request<{song: Song[]}>(query);
|
|
196
|
+
return (data.song) ? data.song : data;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import qs from 'querystringify';
|
|
2
|
+
import { Podcast, PodcastEpisode, DeletedPodcastEpisode } from './types';
|
|
3
|
+
import { Base, Pagination, Success, UID } from '../base';
|
|
4
|
+
|
|
5
|
+
export class Podcasts extends Base {
|
|
6
|
+
/**
|
|
7
|
+
* Get information about podcasts
|
|
8
|
+
* @remarks MINIMUM_API_VERSION=420000
|
|
9
|
+
* @param [params.filter] Value is Alpha Match for returned results, may be more than one letter/number
|
|
10
|
+
* @param [params.include] episodes (include podcast_episodes in the response)
|
|
11
|
+
* @param [params.offset]
|
|
12
|
+
* @param [params.limit]
|
|
13
|
+
* @see {@link https://ampache.org/api/api-json-methods#podcasts}
|
|
14
|
+
*/
|
|
15
|
+
async podcasts (params?: {
|
|
16
|
+
filter?: string,
|
|
17
|
+
include?: 'episodes',
|
|
18
|
+
} & Pagination) {
|
|
19
|
+
let query = 'podcasts';
|
|
20
|
+
query += qs.stringify(params, '&');
|
|
21
|
+
let data = await this.request<{podcast: Podcast[]}>(query);
|
|
22
|
+
return (data.podcast) ? data.podcast : data;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get information about podcasts
|
|
27
|
+
* @remarks MINIMUM_API_VERSION=420000
|
|
28
|
+
* @param params.filter UID to find
|
|
29
|
+
* @param [params.include] episodes (include podcast_episodes in the response)
|
|
30
|
+
* @param [params.offset]
|
|
31
|
+
* @param [params.limit]
|
|
32
|
+
* @see {@link https://ampache.org/api/api-json-methods#podcast}
|
|
33
|
+
*/
|
|
34
|
+
async podcast (params?: {
|
|
35
|
+
filter: UID,
|
|
36
|
+
include?: 'episodes',
|
|
37
|
+
} & Pagination) {
|
|
38
|
+
let query = 'podcast';
|
|
39
|
+
query += qs.stringify(params, '&');
|
|
40
|
+
let data = await this.request<{podcast: Podcast[]}>(query);
|
|
41
|
+
return (data.podcast) ? data.podcast : data;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Create a podcast that can be used by anyone to stream media.
|
|
46
|
+
* @remarks MINIMUM_API_VERSION=420000
|
|
47
|
+
* @param params.url RSS url for podcast
|
|
48
|
+
* @param params.catalog UID of podcast catalog
|
|
49
|
+
* @see {@link https://ampache.org/api/api-json-methods#podcast_create}
|
|
50
|
+
*/
|
|
51
|
+
podcastCreate (params: {
|
|
52
|
+
url: string,
|
|
53
|
+
catalog: UID,
|
|
54
|
+
}) {
|
|
55
|
+
let query = 'podcast_create';
|
|
56
|
+
query += qs.stringify(params, '&');
|
|
57
|
+
return this.request<Podcast>(query);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Update the description and/or expiration date for an existing podcast.
|
|
62
|
+
* @remarks MINIMUM_API_VERSION=420000
|
|
63
|
+
* @param params.filter UID to find
|
|
64
|
+
* @param [params.feed] RSS url for podcast
|
|
65
|
+
* @param [params.title] Podcast title
|
|
66
|
+
* @param [params.website] Source website URL
|
|
67
|
+
* @param [params.description] Podcast description
|
|
68
|
+
* @param [params.generator] Podcast generator
|
|
69
|
+
* @param [params.copyright] Podcast copyright
|
|
70
|
+
* @see {@link https://ampache.org/api/api-json-methods#podcast_edit}
|
|
71
|
+
*/
|
|
72
|
+
podcastEdit (params: {
|
|
73
|
+
filter: UID,
|
|
74
|
+
feed?: string,
|
|
75
|
+
title?: string,
|
|
76
|
+
website?: string,
|
|
77
|
+
description?: string,
|
|
78
|
+
generator?: string,
|
|
79
|
+
copyright?: string,
|
|
80
|
+
}) {
|
|
81
|
+
let query = 'podcast_edit';
|
|
82
|
+
query += qs.stringify(params, '&');
|
|
83
|
+
return this.request<Success>(query);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Delete an existing podcast
|
|
88
|
+
* @remarks MINIMUM_API_VERSION=420000
|
|
89
|
+
* @param params.filter UID of podcast to delete
|
|
90
|
+
* @see {@link https://ampache.org/api/api-json-methods#podcast_delete}
|
|
91
|
+
*/
|
|
92
|
+
podcastDelete (params: {
|
|
93
|
+
filter: UID
|
|
94
|
+
}) {
|
|
95
|
+
let query = 'podcast_delete';
|
|
96
|
+
query += qs.stringify(params, '&');
|
|
97
|
+
return this.request<Success>(query);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* This returns the episodes for a podcast
|
|
102
|
+
* @remarks MINIMUM_API_VERSION=420000
|
|
103
|
+
* @param params.filter UID of podcast
|
|
104
|
+
* @param [params.offset]
|
|
105
|
+
* @param [params.limit]
|
|
106
|
+
* @see {@link https://ampache.org/api/api-json-methods#podcast_episodes}
|
|
107
|
+
*/
|
|
108
|
+
async podcastEpisodes (params: {
|
|
109
|
+
filter: UID,
|
|
110
|
+
} & Pagination) {
|
|
111
|
+
let query = 'podcast_episodes';
|
|
112
|
+
query += qs.stringify(params, '&');
|
|
113
|
+
let data = await this.request<{podcast_episode: PodcastEpisode[]}>(query);
|
|
114
|
+
return (data.podcast_episode) ? data.podcast_episode : data;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Get the podcast_episode from a UID
|
|
119
|
+
* @remarks MINIMUM_API_VERSION=420000
|
|
120
|
+
* @param params.filter UID of podcast
|
|
121
|
+
* @see {@link https://ampache.org/api/api-json-methods#podcast_episode}
|
|
122
|
+
*/
|
|
123
|
+
podcastEpisode (params: {
|
|
124
|
+
filter: UID,
|
|
125
|
+
}) {
|
|
126
|
+
let query = 'podcast_episode';
|
|
127
|
+
query += qs.stringify(params, '&');
|
|
128
|
+
return this.request<PodcastEpisode>(query);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Delete an existing podcast_episode
|
|
133
|
+
* @remarks MINIMUM_API_VERSION=420000
|
|
134
|
+
* @param params.filter UID of podcast episode to delete
|
|
135
|
+
* @see {@link https://ampache.org/api/api-json-methods#podcast_episode_delete}
|
|
136
|
+
*/
|
|
137
|
+
podcastEpisodeDelete (params: {
|
|
138
|
+
filter: UID,
|
|
139
|
+
}) {
|
|
140
|
+
let query = 'podcast_episode_delete';
|
|
141
|
+
query += qs.stringify(params, '&');
|
|
142
|
+
return this.request<Success>(query);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Sync and download new podcast episodes
|
|
147
|
+
* ACCESS REQUIRED: 50 (Content Manager)
|
|
148
|
+
* @remarks MINIMUM_API_VERSION=420000
|
|
149
|
+
* @param params.id UID of podcast
|
|
150
|
+
* @see {@link https://ampache.org/api/api-json-methods#update_podcast}
|
|
151
|
+
*/
|
|
152
|
+
updatePodcast (params: {
|
|
153
|
+
id: UID,
|
|
154
|
+
}) {
|
|
155
|
+
let query = 'update_podcast';
|
|
156
|
+
query += qs.stringify(params, '&');
|
|
157
|
+
return this.request<Success>(query);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* This returns the episodes for a podcast that have been deleted
|
|
162
|
+
* @param [params.offset]
|
|
163
|
+
* @param [params.limit]
|
|
164
|
+
* @see {@link https://ampache.org/api/api-json-methods#deleted_podcast_episodes}
|
|
165
|
+
*/
|
|
166
|
+
async deletedPodcastEpisodes (params?: {
|
|
167
|
+
|
|
168
|
+
} & Pagination) {
|
|
169
|
+
let query = 'deleted_podcast_episodes';
|
|
170
|
+
query += qs.stringify(params, '&');
|
|
171
|
+
let data = await this.request<{deleted_podcast_episode: DeletedPodcastEpisode[]}>(query);
|
|
172
|
+
return (data.deleted_podcast_episode) ? data.deleted_podcast_episode : data;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { UID } from "../base";
|
|
2
|
+
|
|
3
|
+
export type Podcast = {
|
|
4
|
+
id: UID,
|
|
5
|
+
name: string,
|
|
6
|
+
description: string,
|
|
7
|
+
language: string,
|
|
8
|
+
copyright: string,
|
|
9
|
+
feed_url: string,
|
|
10
|
+
generator: string,
|
|
11
|
+
website: string,
|
|
12
|
+
build_date: string,
|
|
13
|
+
sync_date: string,
|
|
14
|
+
public_url: string,
|
|
15
|
+
art: string,
|
|
16
|
+
flag: boolean,
|
|
17
|
+
rating: number | null,
|
|
18
|
+
averaterating: number | null,
|
|
19
|
+
podcast_episode: PodcastEpisode[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type PodcastEpisode = {
|
|
23
|
+
id: UID,
|
|
24
|
+
title: string,
|
|
25
|
+
name: string,
|
|
26
|
+
description: string,
|
|
27
|
+
category: string,
|
|
28
|
+
author: string,
|
|
29
|
+
author_full: string,
|
|
30
|
+
website: string,
|
|
31
|
+
pubdate: string,
|
|
32
|
+
state: 'completed' | 'pending'
|
|
33
|
+
filelength: string,
|
|
34
|
+
filesize: string,
|
|
35
|
+
filename: string,
|
|
36
|
+
mime: string,
|
|
37
|
+
time: number,
|
|
38
|
+
size: number,
|
|
39
|
+
public_url: string,
|
|
40
|
+
url: string,
|
|
41
|
+
catalog: UID,
|
|
42
|
+
art: string,
|
|
43
|
+
flag: boolean,
|
|
44
|
+
rating: number | null,
|
|
45
|
+
averagerating: number | null,
|
|
46
|
+
playcount: number,
|
|
47
|
+
played: string,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type DeletedPodcastEpisode = {
|
|
51
|
+
id: UID,
|
|
52
|
+
addition_time: number,
|
|
53
|
+
delete_time: number,
|
|
54
|
+
title: string,
|
|
55
|
+
file: string,
|
|
56
|
+
catalog: UID,
|
|
57
|
+
total_count: number,
|
|
58
|
+
total_skip: number,
|
|
59
|
+
podcast: UID,
|
|
60
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import qs from 'querystringify';
|
|
2
|
+
import { Base, BinaryBoolean, Success } from '../base';
|
|
3
|
+
import { Preference } from "./types";
|
|
4
|
+
|
|
5
|
+
export class Preferences extends Base {
|
|
6
|
+
/**
|
|
7
|
+
* Get your server preferences
|
|
8
|
+
* ACCESS REQUIRED: 100 (Admin)
|
|
9
|
+
* @remarks MINIMUM_API_VERSION=5.0.0
|
|
10
|
+
* @see {@link https://ampache.org/api/api-json-methods#system_preferences}
|
|
11
|
+
*/
|
|
12
|
+
async systemPreferences () {
|
|
13
|
+
let query = 'system_preferences';
|
|
14
|
+
let data = await this.request<{preference: Preference[]}>(query);
|
|
15
|
+
return (data.preference) ? data.preference : data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get your system preference by name
|
|
20
|
+
* ACCESS REQUIRED: 100 (Admin)
|
|
21
|
+
* @remarks MINIMUM_API_VERSION=5.0.0
|
|
22
|
+
* @param params.systemPreference Preference name e.g ('notify_email', 'ajax_load')
|
|
23
|
+
* @see {@link https://ampache.org/api/api-json-methods#system_preference}
|
|
24
|
+
*/
|
|
25
|
+
async systemPreference (params: {
|
|
26
|
+
filter: string,
|
|
27
|
+
}) {
|
|
28
|
+
let query = 'system_preference';
|
|
29
|
+
query += qs.stringify(params, '&');
|
|
30
|
+
let data = await this.request<{Preference}>(query);
|
|
31
|
+
return data[0];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get your user preferences
|
|
36
|
+
* @remarks MINIMUM_API_VERSION=5.0.0
|
|
37
|
+
* @see {@link https://ampache.org/api/api-json-methods#user_preferences}
|
|
38
|
+
*/
|
|
39
|
+
async userPreferences () {
|
|
40
|
+
let query = 'user_preferences';
|
|
41
|
+
let data = await this.request<{preference: Preference[]}>(query);
|
|
42
|
+
return (data.preference) ? data.preference : data;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get your user preference by name
|
|
47
|
+
* @remarks MINIMUM_API_VERSION=5.0.0
|
|
48
|
+
* @param params.filter Preference name e.g ('notify_email', 'ajax_load')
|
|
49
|
+
* @see {@link https://ampache.org/api/api-json-methods#user_preference}
|
|
50
|
+
*/
|
|
51
|
+
async userPreference (params: {
|
|
52
|
+
filter: string,
|
|
53
|
+
}) {
|
|
54
|
+
let query = 'user_preference';
|
|
55
|
+
query += qs.stringify(params, '&');
|
|
56
|
+
let data = await this.request<{Preference}>(query);
|
|
57
|
+
return data[0];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Add a new preference to your server
|
|
62
|
+
* ACCESS REQUIRED: 100 (Admin)
|
|
63
|
+
* @param params.filter Preference name e.g ('notify_email', 'ajax_load')
|
|
64
|
+
* @param params.type boolean, integer, string, special
|
|
65
|
+
* @param params.default string or integer default value
|
|
66
|
+
* @param params.category Category type
|
|
67
|
+
* @param [params.description]
|
|
68
|
+
* @param [params.subcategory]
|
|
69
|
+
* @param [params.level] access level required to change the value (default 100)
|
|
70
|
+
* @see {@link https://ampache.org/api/api-json-methods#preference_create}
|
|
71
|
+
*/
|
|
72
|
+
preferenceCreate(params: {
|
|
73
|
+
filter: string,
|
|
74
|
+
type: 'boolean' | 'integer' | 'string' | 'special',
|
|
75
|
+
default: string | number,
|
|
76
|
+
category: 'interface' | 'internal' | 'options' | 'playlist' | 'plugins' | 'streaming' | 'system',
|
|
77
|
+
description?: string,
|
|
78
|
+
subcategory?: string,
|
|
79
|
+
level?: number,
|
|
80
|
+
}) {
|
|
81
|
+
let query = 'preference_create';
|
|
82
|
+
query += qs.stringify(params, '&');
|
|
83
|
+
return this.request<Success>(query);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Edit a preference value and apply to all users if allowed
|
|
88
|
+
* ACCESS REQUIRED: 100 (Admin)
|
|
89
|
+
* @remarks MINIMUM_API_VERSION=5.0.0
|
|
90
|
+
* @param params.filter Preference name e.g ('notify_email', 'ajax_load')
|
|
91
|
+
* @param params.value (string/integer) Preference value
|
|
92
|
+
* @param [params.all] 0, 1 apply to all users
|
|
93
|
+
* @see {@link https://ampache.org/api/api-json-methods#preference_edit}
|
|
94
|
+
*/
|
|
95
|
+
preferenceEdit(params: {
|
|
96
|
+
filter: string,
|
|
97
|
+
value: string | number,
|
|
98
|
+
all?: BinaryBoolean,
|
|
99
|
+
}) {
|
|
100
|
+
let query = 'preference_edit';
|
|
101
|
+
query += qs.stringify(params, '&');
|
|
102
|
+
return this.request<Success>(query);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Delete a non-system preference by name
|
|
107
|
+
* ACCESS REQUIRED: 100 (Admin)
|
|
108
|
+
* @param params.filter Preference name e.g ('notify_email', 'ajax_load')
|
|
109
|
+
* @see {@link https://ampache.org/api/api-json-methods#preference_delete}
|
|
110
|
+
*/
|
|
111
|
+
preferenceDelete(params: {
|
|
112
|
+
filter: string,
|
|
113
|
+
}) {
|
|
114
|
+
let query = 'preference_delete';
|
|
115
|
+
query += qs.stringify(params, '&');
|
|
116
|
+
return this.request<Success>(query);
|
|
117
|
+
}
|
|
118
|
+
}
|