lastfm-nodejs-client 1.4.0 → 1.4.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/CHANGELOG.md +6 -0
- package/package.json +8 -9
- package/src/index.ts +17 -17
- package/tsconfig.json +14 -14
- package/dist/auth.js +0 -23
- package/dist/config.js +0 -49
- package/dist/createOptions.js +0 -12
- package/dist/getInfo.js +0 -19
- package/dist/getLovedTracks.js +0 -19
- package/dist/getRecentTracks.js +0 -19
- package/dist/getTopAlbums.js +0 -19
- package/dist/getTopArtists.js +0 -19
- package/dist/getTopTracks.js +0 -19
- package/dist/getWeeklyAlbumChart.js +0 -19
- package/dist/getWeeklyArtistChart.js +0 -19
- package/dist/getWeeklyChartList.js +0 -19
- package/dist/getWeeklyTrackChart.js +0 -19
- package/dist/index.js +0 -33
- package/dist/method.js +0 -20
- package/dist/request.js +0 -132
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lastfm-nodejs-client",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
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
|
-
"scripts": {
|
|
7
|
-
"build": "rimraf dist && tsc",
|
|
8
|
-
"clean": "rimraf dist",
|
|
9
|
-
"dev": "npm run clean && tsc --watch --project tsconfig.dev.json",
|
|
10
|
-
"publish": "npm run build && npm publish --access public",
|
|
11
|
-
"test": "npx playwright test --reporter=list"
|
|
12
|
-
},
|
|
13
6
|
"keywords": [
|
|
14
7
|
"client",
|
|
15
8
|
"lastFm",
|
|
@@ -39,5 +32,11 @@
|
|
|
39
32
|
"bugs": {
|
|
40
33
|
"url": "https://github.com/mannuelf/lastfm-nodejs-client/issues"
|
|
41
34
|
},
|
|
42
|
-
"homepage": "https://github.com/mannuelf/lastfm-nodejs-client#readme"
|
|
35
|
+
"homepage": "https://github.com/mannuelf/lastfm-nodejs-client#readme",
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "rimraf dist && tsc && cp -r @types/ dist/@types/",
|
|
38
|
+
"clean": "rimraf dist",
|
|
39
|
+
"dev": "npm run clean && tsc --watch --project tsconfig.dev.json",
|
|
40
|
+
"test": "npx playwright test --reporter=list"
|
|
41
|
+
}
|
|
43
42
|
}
|
package/src/index.ts
CHANGED
|
@@ -12,20 +12,20 @@ import { getWeeklyChartList } from './getWeeklyChartList';
|
|
|
12
12
|
import { getWeeklyTrackChart } from './getWeeklyTrackChart';
|
|
13
13
|
import { method } from './method';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
const LastFmApi = () => ({
|
|
16
|
+
auth,
|
|
17
|
+
config,
|
|
18
|
+
getInfo,
|
|
19
|
+
getLovedTracks,
|
|
20
|
+
getRecentTracks,
|
|
21
|
+
getTopAlbums,
|
|
22
|
+
getTopArtists,
|
|
23
|
+
getTopTracks,
|
|
24
|
+
getWeeklyAlbumChart,
|
|
25
|
+
getWeeklyArtistChart,
|
|
26
|
+
getWeeklyChartList,
|
|
27
|
+
getWeeklyTrackChart,
|
|
28
|
+
method,
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
export default LastFmApi;
|
package/tsconfig.json
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
13
13
|
|
|
14
14
|
/* Language and Environment */
|
|
15
|
-
"target": "
|
|
16
|
-
|
|
15
|
+
"target": "ES6" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
16
|
+
"lib": ["DOM", "ESNext"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
17
17
|
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
18
18
|
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
|
19
19
|
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
27
27
|
|
|
28
28
|
/* Modules */
|
|
29
|
-
"module": "NodeNext"
|
|
30
|
-
"rootDir": "./src"
|
|
31
|
-
"moduleResolution": "NodeNext"
|
|
29
|
+
"module": "NodeNext" /* Specify what module code is generated. */,
|
|
30
|
+
"rootDir": "./src" /* Specify the root folder within your source files. */,
|
|
31
|
+
"moduleResolution": "NodeNext" /* Specify how TypeScript looks up a file from a given module specifier. */,
|
|
32
32
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
33
33
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
34
34
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
@@ -45,17 +45,17 @@
|
|
|
45
45
|
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
46
46
|
|
|
47
47
|
/* Emit */
|
|
48
|
-
"declaration":
|
|
49
|
-
"declarationMap":
|
|
48
|
+
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
|
|
49
|
+
"declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
50
50
|
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
51
51
|
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
52
52
|
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
53
|
-
"outDir": "./dist"
|
|
54
|
-
"removeComments": false,
|
|
53
|
+
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
|
54
|
+
"removeComments": false, /* Disable emitting comments. */
|
|
55
55
|
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
56
56
|
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
57
57
|
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
58
|
-
"downlevelIteration": false,
|
|
58
|
+
"downlevelIteration": false, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
59
59
|
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
60
60
|
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
61
61
|
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
@@ -70,11 +70,11 @@
|
|
|
70
70
|
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
71
71
|
|
|
72
72
|
/* Interop Constraints */
|
|
73
|
-
"isolatedModules": true
|
|
74
|
-
|
|
75
|
-
"esModuleInterop": true
|
|
73
|
+
"isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */,
|
|
74
|
+
"allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
75
|
+
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
76
76
|
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
77
|
-
"forceConsistentCasingInFileNames": true
|
|
77
|
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
78
78
|
|
|
79
79
|
/* Type Checking */
|
|
80
80
|
"strict": true /* Enable all strict type-checking options. */,
|
package/dist/auth.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/createOptions.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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;
|
package/dist/getInfo.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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;
|
package/dist/getLovedTracks.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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;
|
package/dist/getRecentTracks.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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;
|
package/dist/getTopAlbums.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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;
|
package/dist/getTopArtists.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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;
|
package/dist/getTopTracks.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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;
|
|
@@ -1,19 +0,0 @@
|
|
|
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;
|
|
@@ -1,19 +0,0 @@
|
|
|
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;
|
|
@@ -1,19 +0,0 @@
|
|
|
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;
|
|
@@ -1,19 +0,0 @@
|
|
|
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.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
function LastFmApi() {
|
|
17
|
-
return {
|
|
18
|
-
auth: auth_1.auth,
|
|
19
|
-
config: config_1.config,
|
|
20
|
-
getInfo: getInfo_1.getInfo,
|
|
21
|
-
getLovedTracks: getLovedTracks_1.getLovedTracks,
|
|
22
|
-
getRecentTracks: getRecentTracks_1.getRecentTracks,
|
|
23
|
-
getTopAlbums: getTopAlbums_1.getTopAlbums,
|
|
24
|
-
getTopArtists: getTopArtists_1.getTopArtists,
|
|
25
|
-
getTopTracks: getTopTracks_1.getTopTracks,
|
|
26
|
-
getWeeklyAlbumChart: getWeeklyAlbumChart_1.getWeeklyAlbumChart,
|
|
27
|
-
getWeeklyArtistChart: getWeeklyArtistChart_1.getWeeklyArtistChart,
|
|
28
|
-
getWeeklyChartList: getWeeklyChartList_1.getWeeklyChartList,
|
|
29
|
-
getWeeklyTrackChart: getWeeklyTrackChart_1.getWeeklyTrackChart,
|
|
30
|
-
method: method_1.method,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
exports.default = LastFmApi;
|
package/dist/method.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/request.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
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;
|