lastfm-nodejs-client 1.4.1 → 1.4.2
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/CHANGELOG.md +4 -0
- package/dist/@types/index.d.ts +392 -0
- package/dist/auth.d.ts +13 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +23 -0
- package/dist/config.d.ts +21 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +49 -0
- package/dist/createOptions.d.ts +7 -0
- package/dist/createOptions.d.ts.map +1 -0
- package/dist/createOptions.js +12 -0
- package/dist/getInfo.d.ts +9 -0
- package/dist/getInfo.d.ts.map +1 -0
- package/dist/getInfo.js +19 -0
- package/dist/getLovedTracks.d.ts +9 -0
- package/dist/getLovedTracks.d.ts.map +1 -0
- package/dist/getLovedTracks.js +19 -0
- package/dist/getRecentTracks.d.ts +9 -0
- package/dist/getRecentTracks.d.ts.map +1 -0
- package/dist/getRecentTracks.js +19 -0
- package/dist/getTopAlbums.d.ts +9 -0
- package/dist/getTopAlbums.d.ts.map +1 -0
- package/dist/getTopAlbums.js +19 -0
- package/dist/getTopArtists.d.ts +9 -0
- package/dist/getTopArtists.d.ts.map +1 -0
- package/dist/getTopArtists.js +19 -0
- package/dist/getTopTracks.d.ts +9 -0
- package/dist/getTopTracks.d.ts.map +1 -0
- package/dist/getTopTracks.js +19 -0
- package/dist/getWeeklyAlbumChart.d.ts +9 -0
- package/dist/getWeeklyAlbumChart.d.ts.map +1 -0
- package/dist/getWeeklyAlbumChart.js +19 -0
- package/dist/getWeeklyArtistChart.d.ts +9 -0
- package/dist/getWeeklyArtistChart.d.ts.map +1 -0
- package/dist/getWeeklyArtistChart.js +19 -0
- package/dist/getWeeklyChartList.d.ts +9 -0
- package/dist/getWeeklyChartList.d.ts.map +1 -0
- package/dist/getWeeklyChartList.js +19 -0
- package/dist/getWeeklyTrackChart.d.ts +9 -0
- package/dist/getWeeklyTrackChart.d.ts.map +1 -0
- package/dist/getWeeklyTrackChart.js +19 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/method.d.ts +33 -0
- package/dist/method.d.ts.map +1 -0
- package/dist/method.js +20 -0
- package/dist/request.d.ts +9 -0
- package/dist/request.d.ts.map +1 -0
- package/dist/request.js +132 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
export interface AuthResponse {
|
|
2
|
+
token: string;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface LovedTracksResponse {
|
|
6
|
+
lovedtracks: LovedTracks;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface LovedTracks {
|
|
10
|
+
track: Track[];
|
|
11
|
+
'@attr': Attr;
|
|
12
|
+
}
|
|
13
|
+
export interface TopAlbumsResponse {
|
|
14
|
+
topalbums: TopAlbums;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface TopTrackResponse {
|
|
18
|
+
toptracks: TopTracks;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface TopTracks {
|
|
22
|
+
track: Track[];
|
|
23
|
+
'@attr': Attr2;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface UserResponse {
|
|
27
|
+
user: User;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface RecentTracksResponse {
|
|
31
|
+
recenttracks: RecentTracks;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface RecentTracks {
|
|
35
|
+
track: Track[];
|
|
36
|
+
'@attr': Attr2;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface LoveTracksResponse {
|
|
40
|
+
lovedtracks: LovedTracks;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface LovedTracks {
|
|
44
|
+
track: Track[];
|
|
45
|
+
'@attr': Attr;
|
|
46
|
+
}
|
|
47
|
+
export interface FriendsResponse {
|
|
48
|
+
friends: Friends;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface Friends {
|
|
52
|
+
'@attr': Attr;
|
|
53
|
+
user: User[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface TopArtistsResponse {
|
|
57
|
+
topartists: TopArtists;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface TopArtists {
|
|
61
|
+
artist: Artist[];
|
|
62
|
+
'@attr': Attr2;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface WeeklyArtistChartResponse {
|
|
66
|
+
weeklyartistchart: WeeklyArtistChart;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface WeeklyArtistChart {
|
|
70
|
+
artist: Artist[];
|
|
71
|
+
'@attr': Attr2;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface WeeklyAlbumChartResponse {
|
|
75
|
+
weeklyalbumchart: WeeklyAlbumChart;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface WeeklyAlbumChart {
|
|
79
|
+
album: WeeklyAlbum[];
|
|
80
|
+
'@attr': WeeklyalbumChartAttr;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export type WeeklyAlbum = {
|
|
84
|
+
artist: {
|
|
85
|
+
mbid: string;
|
|
86
|
+
'#text': string;
|
|
87
|
+
};
|
|
88
|
+
mbid: string;
|
|
89
|
+
url: string;
|
|
90
|
+
name: string;
|
|
91
|
+
'@attr': { rank: string };
|
|
92
|
+
playcount: string;
|
|
93
|
+
image?: string;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export interface WeeklyalbumChartAttr {
|
|
97
|
+
from: string;
|
|
98
|
+
to: string;
|
|
99
|
+
user: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface AlbumAttr {
|
|
103
|
+
rank: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type Artist = {
|
|
107
|
+
'@attr': {
|
|
108
|
+
rank: number;
|
|
109
|
+
};
|
|
110
|
+
cover: ArtistImage;
|
|
111
|
+
image?: Image[];
|
|
112
|
+
mbid: string;
|
|
113
|
+
name: string;
|
|
114
|
+
playcount: number;
|
|
115
|
+
streamable: number;
|
|
116
|
+
url: string;
|
|
117
|
+
'#text': string;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export interface Attribs {
|
|
121
|
+
page: number;
|
|
122
|
+
perPage: number;
|
|
123
|
+
user: string;
|
|
124
|
+
total: number;
|
|
125
|
+
totalPages: number;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface ArtistImage {
|
|
129
|
+
name: string;
|
|
130
|
+
photo: string;
|
|
131
|
+
attribution: string;
|
|
132
|
+
playcount: number;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface Album {
|
|
136
|
+
mbid: string;
|
|
137
|
+
'#text': string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface Attr {
|
|
141
|
+
nowplaying: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface Date {
|
|
145
|
+
uts: string;
|
|
146
|
+
'#text': string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface Track {
|
|
150
|
+
artist: Artist;
|
|
151
|
+
streamable: string;
|
|
152
|
+
image: Image[];
|
|
153
|
+
mbid: string;
|
|
154
|
+
album: Album;
|
|
155
|
+
name: string;
|
|
156
|
+
'@attr': Attr;
|
|
157
|
+
url: string;
|
|
158
|
+
date: Date;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface Attr2 {
|
|
162
|
+
user: string;
|
|
163
|
+
totalPages: string;
|
|
164
|
+
page: string;
|
|
165
|
+
perPage: string;
|
|
166
|
+
total: string;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface RecentTracks {
|
|
170
|
+
track: Track[];
|
|
171
|
+
'@attr': Attr2;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface Image {
|
|
175
|
+
size: string;
|
|
176
|
+
'#text': string;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface Registered {
|
|
180
|
+
unixtime: string;
|
|
181
|
+
'#text': number;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface User {
|
|
185
|
+
name: string;
|
|
186
|
+
age: string;
|
|
187
|
+
subscriber: string;
|
|
188
|
+
realname: string;
|
|
189
|
+
bootstrap: string;
|
|
190
|
+
playcount: string;
|
|
191
|
+
artist_count: string;
|
|
192
|
+
playlists: string;
|
|
193
|
+
track_count: string;
|
|
194
|
+
album_count: string;
|
|
195
|
+
image: Image[];
|
|
196
|
+
registered: Registered;
|
|
197
|
+
country: string;
|
|
198
|
+
gender: string;
|
|
199
|
+
url: string;
|
|
200
|
+
type: string;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface TopAlbums {
|
|
204
|
+
album: Album[];
|
|
205
|
+
'@attr': Attr2;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface WeeklyArtistChartResponse {
|
|
209
|
+
weeklyartistchart: WeeklyArtistChart;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface WeeklyArtistChart {
|
|
213
|
+
artist: Artist[];
|
|
214
|
+
'@attr': Attr2;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface Attr1 {
|
|
218
|
+
rank: string;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export interface Attr2 {
|
|
222
|
+
from: string;
|
|
223
|
+
user: string;
|
|
224
|
+
to: string;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export interface WeeklyChartListResponse {
|
|
228
|
+
weeklychartlist: WeeklyChartList;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface WeeklyChartList {
|
|
232
|
+
chart: WeeklyChartListChart[];
|
|
233
|
+
'@attr': WeeklyChartListAttr;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface WeeklyChartListChart {
|
|
237
|
+
'#text': string;
|
|
238
|
+
from: string;
|
|
239
|
+
to: string;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export interface WeeklyChartListAttr {
|
|
243
|
+
user: string;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface WeeklyTrackChartResponse {
|
|
247
|
+
weeklytrackchart: WeeklyTrackChart;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface WeeklyTrackChart {
|
|
251
|
+
track: Track[];
|
|
252
|
+
'@attr': WeeklyTrackChartAttr2;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface WeeklyTrackChartTrack {
|
|
256
|
+
artist: WeeklyTrackChartArtist;
|
|
257
|
+
image: Image[];
|
|
258
|
+
mbid: string;
|
|
259
|
+
url: string;
|
|
260
|
+
name: string;
|
|
261
|
+
'@attr': Attr;
|
|
262
|
+
playcount: string;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface WeeklyTrackChartArtist {
|
|
266
|
+
mbid: string;
|
|
267
|
+
'#text': string;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface WeeklyTrackChartAttr {
|
|
271
|
+
rank: string;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export interface WeeklyTrackChartAttr2 {
|
|
275
|
+
from: string;
|
|
276
|
+
user: string;
|
|
277
|
+
to: string;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export const LastFmApi: () => {
|
|
281
|
+
auth: (method: string, user: string) => Promise<AuthResponse>;
|
|
282
|
+
config: {
|
|
283
|
+
api_key: string;
|
|
284
|
+
app_name: string;
|
|
285
|
+
base_url: string;
|
|
286
|
+
format: {
|
|
287
|
+
json: string;
|
|
288
|
+
xml: string;
|
|
289
|
+
};
|
|
290
|
+
share_secret: string;
|
|
291
|
+
username: string;
|
|
292
|
+
};
|
|
293
|
+
getInfo: (method: string, user: string) => Promise<UserResponse>;
|
|
294
|
+
getLovedTracks: (
|
|
295
|
+
method: string,
|
|
296
|
+
user: string,
|
|
297
|
+
period: string,
|
|
298
|
+
limit: number,
|
|
299
|
+
) => Promise<LovedTracksResponse>;
|
|
300
|
+
getRecentTracks: (
|
|
301
|
+
method: string,
|
|
302
|
+
user: string,
|
|
303
|
+
period: string,
|
|
304
|
+
limit: number,
|
|
305
|
+
) => Promise<RecentTracksResponse>;
|
|
306
|
+
getTopAlbums: (
|
|
307
|
+
method: string,
|
|
308
|
+
user: string,
|
|
309
|
+
period: string,
|
|
310
|
+
limit: number,
|
|
311
|
+
) => Promise<TopAlbumsResponse>;
|
|
312
|
+
getTopArtists: (
|
|
313
|
+
method: string,
|
|
314
|
+
user: string,
|
|
315
|
+
period: string,
|
|
316
|
+
limit: number,
|
|
317
|
+
) => Promise<TopArtistsResponse>;
|
|
318
|
+
getTopTracks: (
|
|
319
|
+
method: string,
|
|
320
|
+
user: string,
|
|
321
|
+
period: string,
|
|
322
|
+
limit: number,
|
|
323
|
+
) => Promise<TopTrackResponse>;
|
|
324
|
+
getWeeklyAlbumChart: (
|
|
325
|
+
method: string,
|
|
326
|
+
user: string,
|
|
327
|
+
period: string,
|
|
328
|
+
limit: number,
|
|
329
|
+
) => Promise<WeeklyAlbumChartResponse>;
|
|
330
|
+
getWeeklyArtistChart: (
|
|
331
|
+
method: string,
|
|
332
|
+
user: string,
|
|
333
|
+
period: string,
|
|
334
|
+
limit: number,
|
|
335
|
+
) => Promise<WeeklyArtistChartResponse>;
|
|
336
|
+
getWeeklyChartList: (
|
|
337
|
+
method: string,
|
|
338
|
+
user: string,
|
|
339
|
+
period: string,
|
|
340
|
+
limit: number,
|
|
341
|
+
) => Promise<WeeklyChartListResponse>;
|
|
342
|
+
getWeeklyTrackChart: (
|
|
343
|
+
method: string,
|
|
344
|
+
user: string,
|
|
345
|
+
period: string,
|
|
346
|
+
limit: number,
|
|
347
|
+
) => Promise<WeeklyTrackChartResponse>;
|
|
348
|
+
};
|
|
349
|
+
export interface config {
|
|
350
|
+
api_key: string;
|
|
351
|
+
app_name: string;
|
|
352
|
+
base_url: string;
|
|
353
|
+
format: {
|
|
354
|
+
json: string;
|
|
355
|
+
xml: string;
|
|
356
|
+
};
|
|
357
|
+
share_secret: string;
|
|
358
|
+
username: string;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export interface method {
|
|
362
|
+
auth: string;
|
|
363
|
+
user: {
|
|
364
|
+
getInfo: string;
|
|
365
|
+
loved_tracks: string;
|
|
366
|
+
recent_tracks: string;
|
|
367
|
+
top_albums: string;
|
|
368
|
+
top_artists: string;
|
|
369
|
+
top_tracks: string;
|
|
370
|
+
weekly_album_chart: string;
|
|
371
|
+
weekly_artist_chart: string;
|
|
372
|
+
weekly_chart_list: string;
|
|
373
|
+
weekly_track_chart: string;
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export enum ErrorResponse {
|
|
378
|
+
InvalidService = 2,
|
|
379
|
+
InvalidMethod = 3,
|
|
380
|
+
AuthenticationFailed = 4,
|
|
381
|
+
InvalidFormat = 5,
|
|
382
|
+
InvalidParameters = 6,
|
|
383
|
+
InvalidResource = 7,
|
|
384
|
+
OperationFailed = 8,
|
|
385
|
+
InvalidSessionKey = 9,
|
|
386
|
+
InvalidAPIKey = 10,
|
|
387
|
+
ServiceOffline = 11,
|
|
388
|
+
InvalidMethodSignature = 13,
|
|
389
|
+
TemporaryError = 16,
|
|
390
|
+
SuspendedAPIKey = 26,
|
|
391
|
+
RateLimitExceeded = 29
|
|
392
|
+
}
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AuthResponse } from '../@types';
|
|
2
|
+
/**
|
|
3
|
+
* POST: Auth - LastFM
|
|
4
|
+
*
|
|
5
|
+
* https://www.last.fm/api/show/auth.getToken
|
|
6
|
+
*
|
|
7
|
+
* Authentication tokens are API account specific.
|
|
8
|
+
* They are valid for 60 minutes from the moment they are granted.
|
|
9
|
+
* Can only used once (they are consumed when a session is created).
|
|
10
|
+
* @returns Auth token
|
|
11
|
+
*/
|
|
12
|
+
export declare function auth(method: string, user: string, period: string, limit: string): Promise<AuthResponse>;
|
|
13
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAIzC;;;;;;;;;EASE;AACF,wBAAgB,IAAI,CAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,YAAY,CAAC,CAGvB"}
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.auth = void 0;
|
|
7
|
+
const createOptions_1 = require("./createOptions");
|
|
8
|
+
const request_1 = __importDefault(require("./request"));
|
|
9
|
+
/**
|
|
10
|
+
* POST: Auth - LastFM
|
|
11
|
+
*
|
|
12
|
+
* https://www.last.fm/api/show/auth.getToken
|
|
13
|
+
*
|
|
14
|
+
* Authentication tokens are API account specific.
|
|
15
|
+
* They are valid for 60 minutes from the moment they are granted.
|
|
16
|
+
* Can only used once (they are consumed when a session is created).
|
|
17
|
+
* @returns Auth token
|
|
18
|
+
*/
|
|
19
|
+
function auth(method, user, period, limit) {
|
|
20
|
+
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
21
|
+
return (0, request_1.default)(options);
|
|
22
|
+
}
|
|
23
|
+
exports.auth = auth;
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Stores the Last.fm API key, app name, base url, format, shared secret, and username.
|
|
3
|
+
* Simply add a .env file to the root of the project and add the following:
|
|
4
|
+
* LASTFM_API_KEY=your_api_key
|
|
5
|
+
* LASTFM_APPNAME=your_app_name
|
|
6
|
+
* LASTFM_API_BASE_URL=your_base_url
|
|
7
|
+
* LASTFM_SHARED_SECRET=your_shared_secret
|
|
8
|
+
* LASTFM_USER=your_username
|
|
9
|
+
*/
|
|
10
|
+
export declare const config: {
|
|
11
|
+
api_key: string;
|
|
12
|
+
app_name: string;
|
|
13
|
+
base_url: string;
|
|
14
|
+
format: {
|
|
15
|
+
json: string;
|
|
16
|
+
xml: string;
|
|
17
|
+
};
|
|
18
|
+
share_secret: string;
|
|
19
|
+
username: string;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAcA;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;CAUD,CAAC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.config = void 0;
|
|
27
|
+
const dotenv = __importStar(require("dotenv"));
|
|
28
|
+
dotenv.config();
|
|
29
|
+
;
|
|
30
|
+
/**
|
|
31
|
+
* @description Stores the Last.fm API key, app name, base url, format, shared secret, and username.
|
|
32
|
+
* Simply add a .env file to the root of the project and add the following:
|
|
33
|
+
* LASTFM_API_KEY=your_api_key
|
|
34
|
+
* LASTFM_APPNAME=your_app_name
|
|
35
|
+
* LASTFM_API_BASE_URL=your_base_url
|
|
36
|
+
* LASTFM_SHARED_SECRET=your_shared_secret
|
|
37
|
+
* LASTFM_USER=your_username
|
|
38
|
+
*/
|
|
39
|
+
exports.config = {
|
|
40
|
+
api_key: `${process.env.LASTFM_API_KEY}`,
|
|
41
|
+
app_name: `${process.env.LASTFM_APPNAME}`,
|
|
42
|
+
base_url: `${process.env.LASTFM_API_BASE_URL}`,
|
|
43
|
+
format: {
|
|
44
|
+
json: 'json',
|
|
45
|
+
xml: 'xml',
|
|
46
|
+
},
|
|
47
|
+
share_secret: `${process.env.LASTFM_SHARED_SECRET}`,
|
|
48
|
+
username: `${process.env.LASTFM_USER}`,
|
|
49
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOptions.d.ts","sourceRoot":"","sources":["../src/createOptions.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM;;;;;EAOf"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createOptions = void 0;
|
|
4
|
+
function createOptions(method, user, period, limit) {
|
|
5
|
+
return {
|
|
6
|
+
method,
|
|
7
|
+
user,
|
|
8
|
+
period,
|
|
9
|
+
limit,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
exports.createOptions = createOptions;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UserResponse } from '../@types';
|
|
2
|
+
/**
|
|
3
|
+
* GET: User profile information - LastFM
|
|
4
|
+
*
|
|
5
|
+
* https://www.last.fm/api/show/user.getInfo
|
|
6
|
+
* @returns User profile information
|
|
7
|
+
*/
|
|
8
|
+
export declare function getInfo(method: string, user: string): Promise<UserResponse>;
|
|
9
|
+
//# sourceMappingURL=getInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getInfo.d.ts","sourceRoot":"","sources":["../src/getInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAIzC;;;;;GAKG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,CAAC,CAGvB"}
|
package/dist/getInfo.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getInfo = void 0;
|
|
7
|
+
const createOptions_1 = require("./createOptions");
|
|
8
|
+
const request_1 = __importDefault(require("./request"));
|
|
9
|
+
/**
|
|
10
|
+
* GET: User profile information - LastFM
|
|
11
|
+
*
|
|
12
|
+
* https://www.last.fm/api/show/user.getInfo
|
|
13
|
+
* @returns User profile information
|
|
14
|
+
*/
|
|
15
|
+
function getInfo(method, user) {
|
|
16
|
+
const options = (0, createOptions_1.createOptions)(method, user);
|
|
17
|
+
return (0, request_1.default)(options);
|
|
18
|
+
}
|
|
19
|
+
exports.getInfo = getInfo;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LovedTracksResponse } from '../@types';
|
|
2
|
+
/**
|
|
3
|
+
* GET: Love Tracks - LastFM
|
|
4
|
+
*
|
|
5
|
+
* https://www.last.fm/api/show/user.getLovedTracks
|
|
6
|
+
* @returns Loved Tracks;
|
|
7
|
+
*/
|
|
8
|
+
export declare function getLovedTracks(method: string, user: string, period: string, limit: string): Promise<LovedTracksResponse>;
|
|
9
|
+
//# sourceMappingURL=getLovedTracks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLovedTracks.d.ts","sourceRoot":"","sources":["../src/getLovedTracks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAIhD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,mBAAmB,CAAC,CAG9B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getLovedTracks = void 0;
|
|
7
|
+
const createOptions_1 = require("./createOptions");
|
|
8
|
+
const request_1 = __importDefault(require("./request"));
|
|
9
|
+
/**
|
|
10
|
+
* GET: Love Tracks - LastFM
|
|
11
|
+
*
|
|
12
|
+
* https://www.last.fm/api/show/user.getLovedTracks
|
|
13
|
+
* @returns Loved Tracks;
|
|
14
|
+
*/
|
|
15
|
+
function getLovedTracks(method, user, period, limit) {
|
|
16
|
+
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
+
return (0, request_1.default)(options);
|
|
18
|
+
}
|
|
19
|
+
exports.getLovedTracks = getLovedTracks;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RecentTracksResponse } from '../@types';
|
|
2
|
+
/**
|
|
3
|
+
* GET: Recent Tracks - LastFM
|
|
4
|
+
*
|
|
5
|
+
* https://www.last.fm/api/show/user.getRecentTracks
|
|
6
|
+
* @returns Recent Tracks
|
|
7
|
+
*/
|
|
8
|
+
export declare function getRecentTracks(method: string, user: string, period: string, limit: string): Promise<RecentTracksResponse>;
|
|
9
|
+
//# sourceMappingURL=getRecentTracks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRecentTracks.d.ts","sourceRoot":"","sources":["../src/getRecentTracks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAIjD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,oBAAoB,CAAC,CAG/B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getRecentTracks = void 0;
|
|
7
|
+
const createOptions_1 = require("./createOptions");
|
|
8
|
+
const request_1 = __importDefault(require("./request"));
|
|
9
|
+
/**
|
|
10
|
+
* GET: Recent Tracks - LastFM
|
|
11
|
+
*
|
|
12
|
+
* https://www.last.fm/api/show/user.getRecentTracks
|
|
13
|
+
* @returns Recent Tracks
|
|
14
|
+
*/
|
|
15
|
+
function getRecentTracks(method, user, period, limit) {
|
|
16
|
+
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
+
return (0, request_1.default)(options);
|
|
18
|
+
}
|
|
19
|
+
exports.getRecentTracks = getRecentTracks;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TopAlbumsResponse } from '../@types';
|
|
2
|
+
/**
|
|
3
|
+
* GET: Top Albums - LastFM
|
|
4
|
+
*
|
|
5
|
+
* https://www.last.fm/api/show/user.getTopAlbums
|
|
6
|
+
* @returns Top Albums
|
|
7
|
+
*/
|
|
8
|
+
export declare function getTopAlbums(method: string, user: string, period: string, limit: string): Promise<TopAlbumsResponse>;
|
|
9
|
+
//# sourceMappingURL=getTopAlbums.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTopAlbums.d.ts","sourceRoot":"","sources":["../src/getTopAlbums.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAI9C;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,iBAAiB,CAAC,CAG5B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getTopAlbums = void 0;
|
|
7
|
+
const createOptions_1 = require("./createOptions");
|
|
8
|
+
const request_1 = __importDefault(require("./request"));
|
|
9
|
+
/**
|
|
10
|
+
* GET: Top Albums - LastFM
|
|
11
|
+
*
|
|
12
|
+
* https://www.last.fm/api/show/user.getTopAlbums
|
|
13
|
+
* @returns Top Albums
|
|
14
|
+
*/
|
|
15
|
+
function getTopAlbums(method, user, period, limit) {
|
|
16
|
+
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
+
return (0, request_1.default)(options);
|
|
18
|
+
}
|
|
19
|
+
exports.getTopAlbums = getTopAlbums;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TopArtistsResponse } from '../@types';
|
|
2
|
+
/**
|
|
3
|
+
* GET: Top Artist - LastFM
|
|
4
|
+
*
|
|
5
|
+
* https://www.last.fm/api/show/user.getTopArtists
|
|
6
|
+
* @returns Top Artists
|
|
7
|
+
*/
|
|
8
|
+
export declare function getTopArtists(method: string, user: string, period: string, limit: string): Promise<TopArtistsResponse>;
|
|
9
|
+
//# sourceMappingURL=getTopArtists.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTopArtists.d.ts","sourceRoot":"","sources":["../src/getTopArtists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAI/C;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,kBAAkB,CAAC,CAG7B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getTopArtists = void 0;
|
|
7
|
+
const createOptions_1 = require("./createOptions");
|
|
8
|
+
const request_1 = __importDefault(require("./request"));
|
|
9
|
+
/**
|
|
10
|
+
* GET: Top Artist - LastFM
|
|
11
|
+
*
|
|
12
|
+
* https://www.last.fm/api/show/user.getTopArtists
|
|
13
|
+
* @returns Top Artists
|
|
14
|
+
*/
|
|
15
|
+
function getTopArtists(method, user, period, limit) {
|
|
16
|
+
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
+
return (0, request_1.default)(options);
|
|
18
|
+
}
|
|
19
|
+
exports.getTopArtists = getTopArtists;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TopTrackResponse } from '../@types';
|
|
2
|
+
/**
|
|
3
|
+
* GET: Top Tracks - LastFM
|
|
4
|
+
*
|
|
5
|
+
* https://www.last.fm/api/show/user.getTopTracks
|
|
6
|
+
* @returns Top Tracks
|
|
7
|
+
*/
|
|
8
|
+
export declare function getTopTracks(method: string, user: string, period: string, limit: string): Promise<TopTrackResponse>;
|
|
9
|
+
//# sourceMappingURL=getTopTracks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTopTracks.d.ts","sourceRoot":"","sources":["../src/getTopTracks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAI7C;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,gBAAgB,CAAC,CAG3B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getTopTracks = void 0;
|
|
7
|
+
const createOptions_1 = require("./createOptions");
|
|
8
|
+
const request_1 = __importDefault(require("./request"));
|
|
9
|
+
/**
|
|
10
|
+
* GET: Top Tracks - LastFM
|
|
11
|
+
*
|
|
12
|
+
* https://www.last.fm/api/show/user.getTopTracks
|
|
13
|
+
* @returns Top Tracks
|
|
14
|
+
*/
|
|
15
|
+
function getTopTracks(method, user, period, limit) {
|
|
16
|
+
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
+
return (0, request_1.default)(options);
|
|
18
|
+
}
|
|
19
|
+
exports.getTopTracks = getTopTracks;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WeeklyAlbumChartResponse } from '../@types';
|
|
2
|
+
/**
|
|
3
|
+
* GET: Weekly album chart - LastFM
|
|
4
|
+
*
|
|
5
|
+
* https://www.last.fm/api/show/user.getWeeklyAlbumChart
|
|
6
|
+
* @returns Weekly album chart
|
|
7
|
+
*/
|
|
8
|
+
export declare function getWeeklyAlbumChart(method: string, user: string, period: string, limit: string): Promise<WeeklyAlbumChartResponse>;
|
|
9
|
+
//# sourceMappingURL=getWeeklyAlbumChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getWeeklyAlbumChart.d.ts","sourceRoot":"","sources":["../src/getWeeklyAlbumChart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAIrD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,wBAAwB,CAAC,CAGnC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getWeeklyAlbumChart = void 0;
|
|
7
|
+
const createOptions_1 = require("./createOptions");
|
|
8
|
+
const request_1 = __importDefault(require("./request"));
|
|
9
|
+
/**
|
|
10
|
+
* GET: Weekly album chart - LastFM
|
|
11
|
+
*
|
|
12
|
+
* https://www.last.fm/api/show/user.getWeeklyAlbumChart
|
|
13
|
+
* @returns Weekly album chart
|
|
14
|
+
*/
|
|
15
|
+
function getWeeklyAlbumChart(method, user, period, limit) {
|
|
16
|
+
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
+
return (0, request_1.default)(options);
|
|
18
|
+
}
|
|
19
|
+
exports.getWeeklyAlbumChart = getWeeklyAlbumChart;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WeeklyArtistChartResponse } from '../@types';
|
|
2
|
+
/**
|
|
3
|
+
* GET: Weekly artist chart - LastFM
|
|
4
|
+
*
|
|
5
|
+
* https://www.last.fm/api/show/user.getWeeklyArtistChart
|
|
6
|
+
* @returns Weekly artist chart
|
|
7
|
+
*/
|
|
8
|
+
export declare function getWeeklyArtistChart(method: string, user: string, period: string, limit: string): Promise<WeeklyArtistChartResponse>;
|
|
9
|
+
//# sourceMappingURL=getWeeklyArtistChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getWeeklyArtistChart.d.ts","sourceRoot":"","sources":["../src/getWeeklyArtistChart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAItD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,yBAAyB,CAAC,CAGpC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getWeeklyArtistChart = void 0;
|
|
7
|
+
const createOptions_1 = require("./createOptions");
|
|
8
|
+
const request_1 = __importDefault(require("./request"));
|
|
9
|
+
/**
|
|
10
|
+
* GET: Weekly artist chart - LastFM
|
|
11
|
+
*
|
|
12
|
+
* https://www.last.fm/api/show/user.getWeeklyArtistChart
|
|
13
|
+
* @returns Weekly artist chart
|
|
14
|
+
*/
|
|
15
|
+
function getWeeklyArtistChart(method, user, period, limit) {
|
|
16
|
+
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
+
return (0, request_1.default)(options);
|
|
18
|
+
}
|
|
19
|
+
exports.getWeeklyArtistChart = getWeeklyArtistChart;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WeeklyChartListResponse } from '../@types';
|
|
2
|
+
/**
|
|
3
|
+
* GET: Weekly chart list - LastFM
|
|
4
|
+
*
|
|
5
|
+
* https://www.last.fm/api/show/user.getWeeklyChartList
|
|
6
|
+
* @returns Weekly chart list
|
|
7
|
+
*/
|
|
8
|
+
export declare function getWeeklyChartList(method: string, user: string, period: string, limit: string): Promise<WeeklyChartListResponse>;
|
|
9
|
+
//# sourceMappingURL=getWeeklyChartList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getWeeklyChartList.d.ts","sourceRoot":"","sources":["../src/getWeeklyChartList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAIpD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,uBAAuB,CAAC,CAGlC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getWeeklyChartList = void 0;
|
|
7
|
+
const createOptions_1 = require("./createOptions");
|
|
8
|
+
const request_1 = __importDefault(require("./request"));
|
|
9
|
+
/**
|
|
10
|
+
* GET: Weekly chart list - LastFM
|
|
11
|
+
*
|
|
12
|
+
* https://www.last.fm/api/show/user.getWeeklyChartList
|
|
13
|
+
* @returns Weekly chart list
|
|
14
|
+
*/
|
|
15
|
+
function getWeeklyChartList(method, user, period, limit) {
|
|
16
|
+
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
+
return (0, request_1.default)(options);
|
|
18
|
+
}
|
|
19
|
+
exports.getWeeklyChartList = getWeeklyChartList;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WeeklyTrackChartResponse } from '../@types';
|
|
2
|
+
/**
|
|
3
|
+
* GET: Weekly track chart - LastFM
|
|
4
|
+
*
|
|
5
|
+
* https://www.last.fm/api/show/user.getWeeklyTrackChart
|
|
6
|
+
* @returns Weekly track chart
|
|
7
|
+
*/
|
|
8
|
+
export declare function getWeeklyTrackChart(method: string, user: string, period: string, limit: string): Promise<WeeklyTrackChartResponse>;
|
|
9
|
+
//# sourceMappingURL=getWeeklyTrackChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getWeeklyTrackChart.d.ts","sourceRoot":"","sources":["../src/getWeeklyTrackChart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAKrD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,wBAAwB,CAAC,CAGnC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getWeeklyTrackChart = void 0;
|
|
7
|
+
const createOptions_1 = require("./createOptions");
|
|
8
|
+
const request_1 = __importDefault(require("./request"));
|
|
9
|
+
/**
|
|
10
|
+
* GET: Weekly track chart - LastFM
|
|
11
|
+
*
|
|
12
|
+
* https://www.last.fm/api/show/user.getWeeklyTrackChart
|
|
13
|
+
* @returns Weekly track chart
|
|
14
|
+
*/
|
|
15
|
+
function getWeeklyTrackChart(method, user, period, limit) {
|
|
16
|
+
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
+
return (0, request_1.default)(options);
|
|
18
|
+
}
|
|
19
|
+
exports.getWeeklyTrackChart = getWeeklyTrackChart;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { auth } from './auth';
|
|
2
|
+
import { getInfo } from './getInfo';
|
|
3
|
+
import { getLovedTracks } from './getLovedTracks';
|
|
4
|
+
import { getRecentTracks } from './getRecentTracks';
|
|
5
|
+
import { getTopAlbums } from './getTopAlbums';
|
|
6
|
+
import { getTopArtists } from './getTopArtists';
|
|
7
|
+
import { getTopTracks } from './getTopTracks';
|
|
8
|
+
import { getWeeklyAlbumChart } from './getWeeklyAlbumChart';
|
|
9
|
+
import { getWeeklyArtistChart } from './getWeeklyArtistChart';
|
|
10
|
+
import { getWeeklyChartList } from './getWeeklyChartList';
|
|
11
|
+
import { getWeeklyTrackChart } from './getWeeklyTrackChart';
|
|
12
|
+
declare const LastFmApi: () => {
|
|
13
|
+
auth: typeof auth;
|
|
14
|
+
config: {
|
|
15
|
+
api_key: string;
|
|
16
|
+
app_name: string;
|
|
17
|
+
base_url: string;
|
|
18
|
+
format: {
|
|
19
|
+
json: string;
|
|
20
|
+
xml: string;
|
|
21
|
+
};
|
|
22
|
+
share_secret: string;
|
|
23
|
+
username: string;
|
|
24
|
+
};
|
|
25
|
+
getInfo: typeof getInfo;
|
|
26
|
+
getLovedTracks: typeof getLovedTracks;
|
|
27
|
+
getRecentTracks: typeof getRecentTracks;
|
|
28
|
+
getTopAlbums: typeof getTopAlbums;
|
|
29
|
+
getTopArtists: typeof getTopArtists;
|
|
30
|
+
getTopTracks: typeof getTopTracks;
|
|
31
|
+
getWeeklyAlbumChart: typeof getWeeklyAlbumChart;
|
|
32
|
+
getWeeklyArtistChart: typeof getWeeklyArtistChart;
|
|
33
|
+
getWeeklyChartList: typeof getWeeklyChartList;
|
|
34
|
+
getWeeklyTrackChart: typeof getWeeklyTrackChart;
|
|
35
|
+
method: {
|
|
36
|
+
auth: string;
|
|
37
|
+
user: {
|
|
38
|
+
getInfo: string;
|
|
39
|
+
getLovedTracks: string;
|
|
40
|
+
getRecentTracks: string;
|
|
41
|
+
getTopAlbums: string;
|
|
42
|
+
getTopArtists: string;
|
|
43
|
+
getTopTracks: string;
|
|
44
|
+
getWeeklyAlbumChart: string;
|
|
45
|
+
getWeeklyArtistChart: string;
|
|
46
|
+
getWeeklyChartList: string;
|
|
47
|
+
getWeeklyTrackChart: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export default LastFmApi;
|
|
52
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAcb,CAAA;AAEF,eAAe,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const auth_1 = require("./auth");
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const getInfo_1 = require("./getInfo");
|
|
6
|
+
const getLovedTracks_1 = require("./getLovedTracks");
|
|
7
|
+
const getRecentTracks_1 = require("./getRecentTracks");
|
|
8
|
+
const getTopAlbums_1 = require("./getTopAlbums");
|
|
9
|
+
const getTopArtists_1 = require("./getTopArtists");
|
|
10
|
+
const getTopTracks_1 = require("./getTopTracks");
|
|
11
|
+
const getWeeklyAlbumChart_1 = require("./getWeeklyAlbumChart");
|
|
12
|
+
const getWeeklyArtistChart_1 = require("./getWeeklyArtistChart");
|
|
13
|
+
const getWeeklyChartList_1 = require("./getWeeklyChartList");
|
|
14
|
+
const getWeeklyTrackChart_1 = require("./getWeeklyTrackChart");
|
|
15
|
+
const method_1 = require("./method");
|
|
16
|
+
const LastFmApi = () => ({
|
|
17
|
+
auth: auth_1.auth,
|
|
18
|
+
config: config_1.config,
|
|
19
|
+
getInfo: getInfo_1.getInfo,
|
|
20
|
+
getLovedTracks: getLovedTracks_1.getLovedTracks,
|
|
21
|
+
getRecentTracks: getRecentTracks_1.getRecentTracks,
|
|
22
|
+
getTopAlbums: getTopAlbums_1.getTopAlbums,
|
|
23
|
+
getTopArtists: getTopArtists_1.getTopArtists,
|
|
24
|
+
getTopTracks: getTopTracks_1.getTopTracks,
|
|
25
|
+
getWeeklyAlbumChart: getWeeklyAlbumChart_1.getWeeklyAlbumChart,
|
|
26
|
+
getWeeklyArtistChart: getWeeklyArtistChart_1.getWeeklyArtistChart,
|
|
27
|
+
getWeeklyChartList: getWeeklyChartList_1.getWeeklyChartList,
|
|
28
|
+
getWeeklyTrackChart: getWeeklyTrackChart_1.getWeeklyTrackChart,
|
|
29
|
+
method: method_1.method,
|
|
30
|
+
});
|
|
31
|
+
exports.default = LastFmApi;
|
package/dist/method.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
interface UserMethod {
|
|
2
|
+
getInfo: string;
|
|
3
|
+
getLovedTracks: string;
|
|
4
|
+
getRecentTracks: string;
|
|
5
|
+
getTopAlbums: string;
|
|
6
|
+
getTopArtists: string;
|
|
7
|
+
getTopTracks: string;
|
|
8
|
+
getWeeklyAlbumChart: string;
|
|
9
|
+
getWeeklyArtistChart: string;
|
|
10
|
+
getWeeklyChartList: string;
|
|
11
|
+
getWeeklyTrackChart: string;
|
|
12
|
+
}
|
|
13
|
+
export interface Method {
|
|
14
|
+
auth: string;
|
|
15
|
+
user: UserMethod;
|
|
16
|
+
}
|
|
17
|
+
export declare const method: {
|
|
18
|
+
auth: string;
|
|
19
|
+
user: {
|
|
20
|
+
getInfo: string;
|
|
21
|
+
getLovedTracks: string;
|
|
22
|
+
getRecentTracks: string;
|
|
23
|
+
getTopAlbums: string;
|
|
24
|
+
getTopArtists: string;
|
|
25
|
+
getTopTracks: string;
|
|
26
|
+
getWeeklyAlbumChart: string;
|
|
27
|
+
getWeeklyArtistChart: string;
|
|
28
|
+
getWeeklyChartList: string;
|
|
29
|
+
getWeeklyTrackChart: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=method.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"method.d.ts","sourceRoot":"","sources":["../src/method.ts"],"names":[],"mappings":"AAAA,UAAU,UAAU;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,eAAO,MAAM,MAAM;;;;;;;;;;;;;;CAcD,CAAC"}
|
package/dist/method.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.method = void 0;
|
|
4
|
+
;
|
|
5
|
+
;
|
|
6
|
+
exports.method = {
|
|
7
|
+
auth: 'auth.getToken',
|
|
8
|
+
user: {
|
|
9
|
+
getInfo: 'user.getInfo',
|
|
10
|
+
getLovedTracks: 'user.getLovedTracks',
|
|
11
|
+
getRecentTracks: 'user.getRecentTracks',
|
|
12
|
+
getTopAlbums: 'user.getTopAlbums',
|
|
13
|
+
getTopArtists: 'user.getTopArtists',
|
|
14
|
+
getTopTracks: 'user.getTopTracks',
|
|
15
|
+
getWeeklyAlbumChart: 'user.getWeeklyAlbumChart',
|
|
16
|
+
getWeeklyArtistChart: 'user.getWeeklyArtistChart',
|
|
17
|
+
getWeeklyChartList: 'user.getWeeklyChartList',
|
|
18
|
+
getWeeklyTrackChart: 'user.getWeeklyTrackChart',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAGA,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAkCD,QAAA,MAAM,OAAO,wBAA6B,cAAc,wBAwFvD,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/dist/request.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
16
|
+
const config_1 = require("./config");
|
|
17
|
+
var ErrorResponse;
|
|
18
|
+
(function (ErrorResponse) {
|
|
19
|
+
ErrorResponse[ErrorResponse["InvalidService"] = 2] = "InvalidService";
|
|
20
|
+
ErrorResponse[ErrorResponse["InvalidMethod"] = 3] = "InvalidMethod";
|
|
21
|
+
ErrorResponse[ErrorResponse["AuthenticationFailed"] = 4] = "AuthenticationFailed";
|
|
22
|
+
ErrorResponse[ErrorResponse["InvalidFormat"] = 5] = "InvalidFormat";
|
|
23
|
+
ErrorResponse[ErrorResponse["InvalidParameters"] = 6] = "InvalidParameters";
|
|
24
|
+
ErrorResponse[ErrorResponse["InvalidResource"] = 7] = "InvalidResource";
|
|
25
|
+
ErrorResponse[ErrorResponse["OperationFailed"] = 8] = "OperationFailed";
|
|
26
|
+
ErrorResponse[ErrorResponse["InvalidSessionKey"] = 9] = "InvalidSessionKey";
|
|
27
|
+
ErrorResponse[ErrorResponse["InvalidAPIKey"] = 10] = "InvalidAPIKey";
|
|
28
|
+
ErrorResponse[ErrorResponse["ServiceOffline"] = 11] = "ServiceOffline";
|
|
29
|
+
ErrorResponse[ErrorResponse["InvalidMethodSignature"] = 13] = "InvalidMethodSignature";
|
|
30
|
+
ErrorResponse[ErrorResponse["TemporaryError"] = 16] = "TemporaryError";
|
|
31
|
+
ErrorResponse[ErrorResponse["SuspendedAPIKey"] = 26] = "SuspendedAPIKey";
|
|
32
|
+
ErrorResponse[ErrorResponse["RateLimitExceeded"] = 29] = "RateLimitExceeded";
|
|
33
|
+
})(ErrorResponse || (ErrorResponse = {}));
|
|
34
|
+
const buildUrl = (options) => {
|
|
35
|
+
const params = new URLSearchParams();
|
|
36
|
+
params.append('method', options.method);
|
|
37
|
+
if (options.user)
|
|
38
|
+
params.append('user', options.user);
|
|
39
|
+
if (options.period)
|
|
40
|
+
params.append('period', options.period);
|
|
41
|
+
if (options.limit)
|
|
42
|
+
params.append('limit', options.limit);
|
|
43
|
+
params.append('api_key', config_1.config.api_key);
|
|
44
|
+
params.append('format', config_1.config.format.json);
|
|
45
|
+
return `${config_1.config.base_url}?${params.toString()}`;
|
|
46
|
+
};
|
|
47
|
+
const request = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
const url = buildUrl(options);
|
|
49
|
+
return (yield (0, cross_fetch_1.default)(url, {
|
|
50
|
+
headers: {
|
|
51
|
+
'Content-Type': 'application/json',
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
.then((res) => {
|
|
55
|
+
if (!res.ok) {
|
|
56
|
+
throw new Error(res.statusText);
|
|
57
|
+
}
|
|
58
|
+
switch (res.status) {
|
|
59
|
+
case 200: {
|
|
60
|
+
return res.json();
|
|
61
|
+
}
|
|
62
|
+
case 400: {
|
|
63
|
+
throw new Error('Bad request');
|
|
64
|
+
}
|
|
65
|
+
case 401: {
|
|
66
|
+
throw new Error('Unauthorized');
|
|
67
|
+
}
|
|
68
|
+
case 403: {
|
|
69
|
+
throw new Error('Forbidden');
|
|
70
|
+
}
|
|
71
|
+
case 404: {
|
|
72
|
+
throw new Error('Not found');
|
|
73
|
+
}
|
|
74
|
+
case 500: {
|
|
75
|
+
throw new Error('Internal server error');
|
|
76
|
+
}
|
|
77
|
+
case 503: {
|
|
78
|
+
throw new Error('Service unavailable');
|
|
79
|
+
}
|
|
80
|
+
case ErrorResponse.InvalidAPIKey: {
|
|
81
|
+
throw new Error('Invalid API key');
|
|
82
|
+
}
|
|
83
|
+
case ErrorResponse.InvalidMethod: {
|
|
84
|
+
throw new Error('Invalid method');
|
|
85
|
+
}
|
|
86
|
+
case ErrorResponse.InvalidParameters: {
|
|
87
|
+
throw new Error('Invalid parameters');
|
|
88
|
+
}
|
|
89
|
+
case ErrorResponse.InvalidResource: {
|
|
90
|
+
throw new Error('Invalid resource');
|
|
91
|
+
}
|
|
92
|
+
case ErrorResponse.InvalidSessionKey: {
|
|
93
|
+
throw new Error('Invalid session key');
|
|
94
|
+
}
|
|
95
|
+
case ErrorResponse.InvalidService: {
|
|
96
|
+
throw new Error('Invalid service');
|
|
97
|
+
}
|
|
98
|
+
case ErrorResponse.OperationFailed: {
|
|
99
|
+
throw new Error('Operation failed');
|
|
100
|
+
}
|
|
101
|
+
case ErrorResponse.RateLimitExceeded: {
|
|
102
|
+
throw new Error('Rate limit exceeded');
|
|
103
|
+
}
|
|
104
|
+
case ErrorResponse.ServiceOffline: {
|
|
105
|
+
throw new Error('Service offline');
|
|
106
|
+
}
|
|
107
|
+
case ErrorResponse.SuspendedAPIKey: {
|
|
108
|
+
throw new Error('Suspended API key');
|
|
109
|
+
}
|
|
110
|
+
case ErrorResponse.TemporaryError: {
|
|
111
|
+
throw new Error('Temporary error');
|
|
112
|
+
}
|
|
113
|
+
case ErrorResponse.AuthenticationFailed: {
|
|
114
|
+
throw new Error('Authentication failed');
|
|
115
|
+
}
|
|
116
|
+
case ErrorResponse.InvalidFormat: {
|
|
117
|
+
throw new Error('Invalid format');
|
|
118
|
+
}
|
|
119
|
+
case ErrorResponse.InvalidMethodSignature: {
|
|
120
|
+
throw new Error('Invalid method signature');
|
|
121
|
+
}
|
|
122
|
+
default: {
|
|
123
|
+
throw new Error('Unknown error');
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
.then((json) => json)
|
|
128
|
+
.catch((error) => {
|
|
129
|
+
console.log('🚨 error:', error);
|
|
130
|
+
}));
|
|
131
|
+
});
|
|
132
|
+
exports.default = request;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lastfm-nodejs-client",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "A NodeJS wrapper client for LastFm API. Fetching public data by username using the LastFm public API",
|
|
5
5
|
"main": "./dist",
|
|
6
6
|
"keywords": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/mannuelf/lastfm-nodejs-client#readme",
|
|
36
36
|
"scripts": {
|
|
37
|
-
"build": "rimraf dist && tsc
|
|
37
|
+
"build": "rimraf dist && tsc",
|
|
38
38
|
"clean": "rimraf dist",
|
|
39
39
|
"dev": "npm run clean && tsc --watch --project tsconfig.dev.json",
|
|
40
40
|
"test": "npx playwright test --reporter=list"
|