musicbrainz-api 0.18.1 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -1
- package/lib/default.cjs +5 -0
- package/lib/index.d.ts +4 -0
- package/lib/musicbrainz-api.d.ts +5 -2
- package/lib/musicbrainz-api.js +4 -2
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
# musicbrainz-api
|
|
13
13
|
|
|
14
|
-
A MusicBrainz-API-client for reading and submitting metadata
|
|
14
|
+
A MusicBrainz-API-client for reading and submitting metadata.
|
|
15
|
+
|
|
16
|
+
<img src="doc/musicbrainz-api-logo.png" width="40%" style="center"></img>
|
|
15
17
|
|
|
16
18
|
## Features
|
|
17
19
|
- **Access Metadata**: Retrieve detailed metadata from the [MusicBrainz database](https://musicbrainz.org/).
|
|
@@ -24,6 +26,9 @@ A MusicBrainz-API-client for reading and submitting metadata
|
|
|
24
26
|
Module: version 8 migrated from [CommonJS](https://en.wikipedia.org/wiki/CommonJS) to [pure ECMAScript Module (ESM)](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
|
|
25
27
|
The distributed JavaScript codebase is compliant with the [ECMAScript 2020 (11th Edition)](https://en.wikipedia.org/wiki/ECMAScript_version_history#11th_Edition_%E2%80%93_ECMAScript_2020) standard.
|
|
26
28
|
|
|
29
|
+
> [!NOTE]
|
|
30
|
+
> See also [CommonJS backward compatibility](#commonjs-backward-compatibility)
|
|
31
|
+
|
|
27
32
|
### Requirements
|
|
28
33
|
- Node.js: Requires [Node.js version 16](https://nodejs.org/en/about/previous-releases) or higher.
|
|
29
34
|
- Browser: Can be used in browser environments when bundled with a module bundler (not actively tested).
|
|
@@ -66,6 +71,9 @@ const mbApi = new MusicBrainzApi({
|
|
|
66
71
|
});
|
|
67
72
|
```
|
|
68
73
|
|
|
74
|
+
> [!NOTE]
|
|
75
|
+
> See also [CommonJS backward compatibility](#commonjs-backward-compatibility)
|
|
76
|
+
|
|
69
77
|
### Configuration Options
|
|
70
78
|
|
|
71
79
|
```js
|
|
@@ -463,3 +471,29 @@ async function getCoverArt(releaseGroupMbid, coverType = '') {
|
|
|
463
471
|
|
|
464
472
|
```
|
|
465
473
|
|
|
474
|
+
## CommonJS backward compatibility
|
|
475
|
+
|
|
476
|
+
For legacy CommonJS projects needing to load the `music-metadata` ESM module, you can use the `loadMusicMetadata` function:
|
|
477
|
+
```js
|
|
478
|
+
const { loadMusicBrainzApi } = require('musicbrainz-api');
|
|
479
|
+
|
|
480
|
+
(async () => {
|
|
481
|
+
|
|
482
|
+
// Dynamically loads the ESM module in a CommonJS project
|
|
483
|
+
const {MusicBrainzApi} = await loadMusicBrainzApi();
|
|
484
|
+
|
|
485
|
+
const mbApi = new MusicBrainzApi({
|
|
486
|
+
appName: 'my-app',
|
|
487
|
+
appVersion: '0.1.0',
|
|
488
|
+
appContactInfo: 'user@mail.org',
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
const releaseList = await mbApi.search('release', {query: {barcode: 602537479870}});
|
|
492
|
+
for(const release of releaseList.releases) {
|
|
493
|
+
console.log(release.title);
|
|
494
|
+
}
|
|
495
|
+
})();
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
> [!NOTE]
|
|
499
|
+
> The `loadMusicMetadata` function is experimental.
|
package/lib/default.cjs
ADDED
package/lib/index.d.ts
CHANGED
package/lib/musicbrainz-api.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export interface IMusicBrainzConfig {
|
|
|
50
50
|
username?: string;
|
|
51
51
|
password?: string;
|
|
52
52
|
};
|
|
53
|
-
baseUrl
|
|
53
|
+
baseUrl?: string;
|
|
54
54
|
appName?: string;
|
|
55
55
|
appVersion?: string;
|
|
56
56
|
/**
|
|
@@ -63,6 +63,9 @@ export interface IMusicBrainzConfig {
|
|
|
63
63
|
appContactInfo?: string;
|
|
64
64
|
disableRateLimiting?: boolean;
|
|
65
65
|
}
|
|
66
|
+
interface IInternalConfig extends IMusicBrainzConfig {
|
|
67
|
+
baseUrl: string;
|
|
68
|
+
}
|
|
66
69
|
export interface ICsrfSession {
|
|
67
70
|
sessionKey: string;
|
|
68
71
|
token: string;
|
|
@@ -72,7 +75,7 @@ export interface ISessionInformation {
|
|
|
72
75
|
loggedIn?: boolean;
|
|
73
76
|
}
|
|
74
77
|
export declare class MusicBrainzApi {
|
|
75
|
-
readonly config:
|
|
78
|
+
readonly config: IInternalConfig;
|
|
76
79
|
private rateLimiter;
|
|
77
80
|
private httpClient;
|
|
78
81
|
private session?;
|
package/lib/musicbrainz-api.js
CHANGED
|
@@ -30,9 +30,11 @@ export class MusicBrainzApi {
|
|
|
30
30
|
}
|
|
31
31
|
constructor(_config) {
|
|
32
32
|
this.config = {
|
|
33
|
-
|
|
33
|
+
...{
|
|
34
|
+
baseUrl: 'https://musicbrainz.org'
|
|
35
|
+
},
|
|
36
|
+
..._config
|
|
34
37
|
};
|
|
35
|
-
Object.assign(this.config, _config);
|
|
36
38
|
this.httpClient = new HttpClient({
|
|
37
39
|
baseUrl: this.config.baseUrl,
|
|
38
40
|
timeout: 20 * 1000,
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "musicbrainz-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "MusicBrainz API client for reading and submitting metadata",
|
|
5
|
-
"exports":
|
|
5
|
+
"exports": {
|
|
6
|
+
"import": "./lib/index.js",
|
|
7
|
+
"require": "./lib/default.cjs"
|
|
8
|
+
},
|
|
6
9
|
"types": "lib/index.d.ts",
|
|
7
10
|
"files": [
|
|
8
11
|
"lib/**/*.js",
|
|
9
|
-
"lib/**/*.d.ts"
|
|
12
|
+
"lib/**/*.d.ts",
|
|
13
|
+
"lib/default.cjs"
|
|
10
14
|
],
|
|
11
15
|
"type": "module",
|
|
12
16
|
"author": {
|