musicbrainz-api 0.12.0 → 0.13.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 +3 -15
- package/lib/coverartarchive-api.js +3 -7
- package/lib/digest-auth.js +4 -8
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -18
- package/lib/musicbrainz-api.d.ts +7 -7
- package/lib/musicbrainz-api.js +69 -63
- package/lib/musicbrainz.types.d.ts +1 -1
- package/lib/musicbrainz.types.js +2 -5
- package/lib/rate-limiter.js +3 -7
- package/lib/xml/xml-isrc-list.d.ts +1 -1
- package/lib/xml/xml-isrc-list.js +3 -7
- package/lib/xml/xml-isrc.js +1 -5
- package/lib/xml/xml-metadata.d.ts +1 -1
- package/lib/xml/xml-metadata.js +4 -8
- package/lib/xml/xml-recording.d.ts +1 -1
- package/lib/xml/xml-recording.js +3 -7
- package/package.json +15 -14
package/README.md
CHANGED
|
@@ -34,32 +34,20 @@ If you plan to use this module for submitting metadata, please ensure you comply
|
|
|
34
34
|
|
|
35
35
|
## Example
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
JavaScript example, how to import 'musicbrainz-api:
|
|
39
|
-
```js
|
|
40
|
-
const MusicBrainzApi = require('musicbrainz-api').MusicBrainzApi;
|
|
41
|
-
|
|
42
|
-
const mbApi = new MusicBrainzApi({
|
|
43
|
-
appName: 'my-app',
|
|
44
|
-
appVersion: '0.1.0',
|
|
45
|
-
appContactInfo: 'user@mail.org'
|
|
46
|
-
});
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
In TypeScript it would look like this:
|
|
37
|
+
Example, how to import 'musicbrainz-api:
|
|
50
38
|
```js
|
|
51
39
|
import {MusicBrainzApi} from 'musicbrainz-api';
|
|
52
40
|
|
|
53
41
|
const mbApi = new MusicBrainzApi({
|
|
54
42
|
appName: 'my-app',
|
|
55
43
|
appVersion: '0.1.0',
|
|
56
|
-
appContactInfo: 'user@mail.org'
|
|
44
|
+
appContactInfo: 'user@mail.org'
|
|
57
45
|
});
|
|
58
46
|
```
|
|
59
47
|
|
|
60
48
|
The following configuration settings can be passed
|
|
61
49
|
```js
|
|
62
|
-
import {MusicBrainzApi} from '
|
|
50
|
+
import {MusicBrainzApi} from 'musicbrainz-api';
|
|
63
51
|
|
|
64
52
|
const config = {
|
|
65
53
|
// MusicBrainz bot account username & password (optional)
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CoverArtArchiveApi = void 0;
|
|
4
1
|
/* eslint-disable-next-line */
|
|
5
|
-
|
|
6
|
-
class CoverArtArchiveApi {
|
|
2
|
+
import got from 'got';
|
|
3
|
+
export class CoverArtArchiveApi {
|
|
7
4
|
constructor() {
|
|
8
5
|
this.host = 'coverartarchive.org';
|
|
9
6
|
}
|
|
10
7
|
async getJson(path) {
|
|
11
|
-
const response = await
|
|
8
|
+
const response = await got.get('https://' + this.host + path, {
|
|
12
9
|
headers: {
|
|
13
10
|
Accept: `application/json`
|
|
14
11
|
},
|
|
@@ -33,5 +30,4 @@ class CoverArtArchiveApi {
|
|
|
33
30
|
return info;
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
|
-
exports.CoverArtArchiveApi = CoverArtArchiveApi;
|
|
37
33
|
//# sourceMappingURL=coverartarchive-api.js.map
|
package/lib/digest-auth.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.DigestAuth = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
|
-
const crypto = require("crypto");
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import * as crypto from 'crypto';
|
|
6
3
|
function md5(str) {
|
|
7
4
|
return crypto.createHash('md5').update(str).digest('hex'); // lgtm [js/insufficient-password-hash]
|
|
8
5
|
}
|
|
9
|
-
class DigestAuth {
|
|
6
|
+
export class DigestAuth {
|
|
10
7
|
/**
|
|
11
8
|
* RFC 2617: handle both MD5 and MD5-sess algorithms.
|
|
12
9
|
*
|
|
@@ -45,7 +42,7 @@ class DigestAuth {
|
|
|
45
42
|
}
|
|
46
43
|
const qop = /(^|,)\s*auth\s*($|,)/.test(challenge.qop) && 'auth';
|
|
47
44
|
const nc = qop && '00000001';
|
|
48
|
-
const cnonce = qop && (
|
|
45
|
+
const cnonce = qop && uuidv4().replace(/-/g, '');
|
|
49
46
|
const ha1 = DigestAuth.ha1Compute(challenge.algorithm, this.credentials.username, challenge.realm, this.credentials.password, challenge.nonce, cnonce);
|
|
50
47
|
const ha2 = md5(method + ':' + path); // lgtm [js/insufficient-password-hash]
|
|
51
48
|
const digestResponse = qop
|
|
@@ -79,5 +76,4 @@ class DigestAuth {
|
|
|
79
76
|
return authHeader;
|
|
80
77
|
}
|
|
81
78
|
}
|
|
82
|
-
exports.DigestAuth = DigestAuth;
|
|
83
79
|
//# sourceMappingURL=digest-auth.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './coverartarchive-api';
|
|
2
|
-
export * from './musicbrainz-api';
|
|
1
|
+
export * from './coverartarchive-api.js';
|
|
2
|
+
export * from './musicbrainz-api.js';
|
package/lib/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./coverartarchive-api"), exports);
|
|
18
|
-
__exportStar(require("./musicbrainz-api"), exports);
|
|
1
|
+
export * from './coverartarchive-api.js';
|
|
2
|
+
export * from './musicbrainz-api.js';
|
|
19
3
|
//# sourceMappingURL=index.js.map
|
package/lib/musicbrainz-api.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { XmlMetadata } from './xml/xml-metadata';
|
|
2
|
-
export { XmlIsrc } from './xml/xml-isrc';
|
|
3
|
-
export { XmlIsrcList } from './xml/xml-isrc-list';
|
|
4
|
-
export { XmlRecording } from './xml/xml-recording';
|
|
5
|
-
import { XmlMetadata } from './xml/xml-metadata';
|
|
6
|
-
import * as mb from './musicbrainz.types';
|
|
7
|
-
export * from './musicbrainz.types';
|
|
1
|
+
export { XmlMetadata } from './xml/xml-metadata.js';
|
|
2
|
+
export { XmlIsrc } from './xml/xml-isrc.js';
|
|
3
|
+
export { XmlIsrcList } from './xml/xml-isrc-list.js';
|
|
4
|
+
export { XmlRecording } from './xml/xml-recording.js';
|
|
5
|
+
import { XmlMetadata } from './xml/xml-metadata.js';
|
|
6
|
+
import * as mb from './musicbrainz.types.js';
|
|
7
|
+
export * from './musicbrainz.types.js';
|
|
8
8
|
export type RelationsIncludes = 'area-rels' | 'artist-rels' | 'event-rels' | 'instrument-rels' | 'label-rels' | 'place-rels' | 'recording-rels' | 'release-rels' | 'release-group-rels' | 'series-rels' | 'url-rels' | 'work-rels';
|
|
9
9
|
export type SubQueryIncludes =
|
|
10
10
|
/**
|
package/lib/musicbrainz-api.js
CHANGED
|
@@ -1,42 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.makeAndQueryString = exports.MusicBrainzApi = exports.XmlRecording = exports.XmlIsrcList = exports.XmlIsrc = exports.XmlMetadata = void 0;
|
|
18
|
-
const assert = require("assert");
|
|
19
|
-
const http_status_codes_1 = require("http-status-codes");
|
|
20
|
-
const Url = require("url");
|
|
21
|
-
const Debug = require("debug");
|
|
22
|
-
var xml_metadata_1 = require("./xml/xml-metadata");
|
|
23
|
-
Object.defineProperty(exports, "XmlMetadata", { enumerable: true, get: function () { return xml_metadata_1.XmlMetadata; } });
|
|
24
|
-
var xml_isrc_1 = require("./xml/xml-isrc");
|
|
25
|
-
Object.defineProperty(exports, "XmlIsrc", { enumerable: true, get: function () { return xml_isrc_1.XmlIsrc; } });
|
|
26
|
-
var xml_isrc_list_1 = require("./xml/xml-isrc-list");
|
|
27
|
-
Object.defineProperty(exports, "XmlIsrcList", { enumerable: true, get: function () { return xml_isrc_list_1.XmlIsrcList; } });
|
|
28
|
-
var xml_recording_1 = require("./xml/xml-recording");
|
|
29
|
-
Object.defineProperty(exports, "XmlRecording", { enumerable: true, get: function () { return xml_recording_1.XmlRecording; } });
|
|
30
|
-
const digest_auth_1 = require("./digest-auth");
|
|
31
|
-
const rate_limiter_1 = require("./rate-limiter");
|
|
32
|
-
const mb = require("./musicbrainz.types");
|
|
33
|
-
/* eslint-disable-next-line */
|
|
34
|
-
const got_1 = require("got");
|
|
35
|
-
const tough_cookie_1 = require("tough-cookie");
|
|
36
|
-
__exportStar(require("./musicbrainz.types"), exports);
|
|
37
|
-
const util_1 = require("util");
|
|
1
|
+
import * as assert from 'assert';
|
|
2
|
+
import { StatusCodes as HttpStatus } from 'http-status-codes';
|
|
3
|
+
import Debug from 'debug';
|
|
4
|
+
export { XmlMetadata } from './xml/xml-metadata.js';
|
|
5
|
+
export { XmlIsrc } from './xml/xml-isrc.js';
|
|
6
|
+
export { XmlIsrcList } from './xml/xml-isrc-list.js';
|
|
7
|
+
export { XmlRecording } from './xml/xml-recording.js';
|
|
8
|
+
import { DigestAuth } from './digest-auth.js';
|
|
9
|
+
import { RateLimiter } from './rate-limiter.js';
|
|
10
|
+
import * as mb from './musicbrainz.types.js';
|
|
11
|
+
import got from 'got';
|
|
12
|
+
import { CookieJar } from 'tough-cookie';
|
|
13
|
+
export * from './musicbrainz.types.js';
|
|
14
|
+
import { promisify } from 'util';
|
|
38
15
|
const debug = Debug('musicbrainz-api');
|
|
39
|
-
class MusicBrainzApi {
|
|
16
|
+
export class MusicBrainzApi {
|
|
40
17
|
static escapeText(text) {
|
|
41
18
|
let str = '';
|
|
42
19
|
for (const chr of text) {
|
|
@@ -90,24 +67,32 @@ class MusicBrainzApi {
|
|
|
90
67
|
botAccount: {}
|
|
91
68
|
};
|
|
92
69
|
Object.assign(this.config, _config);
|
|
93
|
-
const cookieJar = new
|
|
94
|
-
this.getCookies =
|
|
70
|
+
const cookieJar = new CookieJar();
|
|
71
|
+
this.getCookies = promisify(cookieJar.getCookies.bind(cookieJar));
|
|
72
|
+
// @ts-ignore
|
|
95
73
|
this.options = {
|
|
96
74
|
prefixUrl: this.config.baseUrl,
|
|
97
|
-
timeout:
|
|
75
|
+
timeout: {
|
|
76
|
+
read: 20 * 1000
|
|
77
|
+
},
|
|
98
78
|
headers: {
|
|
99
79
|
'User-Agent': `${this.config.appName}/${this.config.appVersion} ( ${this.config.appContactInfo} )`
|
|
100
80
|
},
|
|
101
81
|
cookieJar: cookieJar
|
|
102
82
|
};
|
|
103
|
-
this.rateLimiter = new
|
|
83
|
+
this.rateLimiter = new RateLimiter(15, 18);
|
|
104
84
|
}
|
|
105
85
|
async restGet(relUrl, query = {}, attempt = 1) {
|
|
106
86
|
query.fmt = 'json';
|
|
107
87
|
await this.rateLimiter.limit();
|
|
108
|
-
const response = await
|
|
88
|
+
const response = await got.get('ws/2' + relUrl, {
|
|
89
|
+
...this.options,
|
|
90
|
+
searchParams: query,
|
|
91
|
+
responseType: 'json',
|
|
92
|
+
retry: {
|
|
109
93
|
limit: 10
|
|
110
|
-
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
111
96
|
return response.body;
|
|
112
97
|
}
|
|
113
98
|
// -----------------------------------------------------------------------------------------------------------------
|
|
@@ -346,14 +331,20 @@ class MusicBrainzApi {
|
|
|
346
331
|
const postData = xmlMetadata.toXml();
|
|
347
332
|
do {
|
|
348
333
|
await this.rateLimiter.limit();
|
|
349
|
-
const response = await
|
|
334
|
+
const response = await got.post(path, {
|
|
335
|
+
...this.options,
|
|
336
|
+
searchParams: { client: clientId },
|
|
337
|
+
headers: {
|
|
350
338
|
authorization: digest,
|
|
351
339
|
'Content-Type': 'application/xml'
|
|
352
|
-
},
|
|
353
|
-
|
|
340
|
+
},
|
|
341
|
+
body: postData,
|
|
342
|
+
throwHttpErrors: false
|
|
343
|
+
});
|
|
344
|
+
if (response.statusCode === HttpStatus.UNAUTHORIZED) {
|
|
354
345
|
// Respond to digest challenge
|
|
355
|
-
const auth = new
|
|
356
|
-
const relPath =
|
|
346
|
+
const auth = new DigestAuth(this.config.botAccount);
|
|
347
|
+
const relPath = response.requestUrl.pathname; // Ensure path is relative
|
|
357
348
|
digest = auth.digest(response.request.method, relPath, response.headers['www-authenticate']);
|
|
358
349
|
++n;
|
|
359
350
|
}
|
|
@@ -381,10 +372,15 @@ class MusicBrainzApi {
|
|
|
381
372
|
csrf_token: this.session.csrf.token,
|
|
382
373
|
remember_me: 1
|
|
383
374
|
};
|
|
384
|
-
const response = await
|
|
375
|
+
const response = await got.post('login', {
|
|
376
|
+
...this.options,
|
|
377
|
+
followRedirect: false,
|
|
378
|
+
searchParams: {
|
|
385
379
|
returnto: redirectUri
|
|
386
|
-
},
|
|
387
|
-
|
|
380
|
+
},
|
|
381
|
+
form: formData
|
|
382
|
+
});
|
|
383
|
+
const success = response.statusCode === HttpStatus.MOVED_TEMPORARILY && response.headers.location === redirectUri;
|
|
388
384
|
if (success) {
|
|
389
385
|
this.session.loggedIn = true;
|
|
390
386
|
}
|
|
@@ -395,10 +391,14 @@ class MusicBrainzApi {
|
|
|
395
391
|
*/
|
|
396
392
|
async logout() {
|
|
397
393
|
const redirectUri = '/success';
|
|
398
|
-
const response = await
|
|
394
|
+
const response = await got.get('logout', {
|
|
395
|
+
...this.options,
|
|
396
|
+
followRedirect: false,
|
|
397
|
+
searchParams: {
|
|
399
398
|
returnto: redirectUri
|
|
400
|
-
}
|
|
401
|
-
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
const success = response.statusCode === HttpStatus.MOVED_TEMPORARILY && response.headers.location === redirectUri;
|
|
402
402
|
if (success && this.session) {
|
|
403
403
|
this.session.loggedIn = true;
|
|
404
404
|
}
|
|
@@ -418,10 +418,14 @@ class MusicBrainzApi {
|
|
|
418
418
|
formData.username = this.config.botAccount.username;
|
|
419
419
|
formData.password = this.config.botAccount.password;
|
|
420
420
|
formData.remember_me = 1;
|
|
421
|
-
const response = await
|
|
422
|
-
|
|
421
|
+
const response = await got.post(`${entity}/${mbid}/edit`, {
|
|
422
|
+
...this.options,
|
|
423
|
+
form: formData,
|
|
424
|
+
followRedirect: false
|
|
425
|
+
});
|
|
426
|
+
if (response.statusCode === HttpStatus.OK)
|
|
423
427
|
throw new Error(`Failed to submit form data`);
|
|
424
|
-
if (response.statusCode ===
|
|
428
|
+
if (response.statusCode === HttpStatus.MOVED_TEMPORARILY)
|
|
425
429
|
return;
|
|
426
430
|
throw new Error(`Unexpected status code: ${response.statusCode}`);
|
|
427
431
|
}
|
|
@@ -475,7 +479,7 @@ class MusicBrainzApi {
|
|
|
475
479
|
* @param query Arguments
|
|
476
480
|
*/
|
|
477
481
|
search(entity, query) {
|
|
478
|
-
const urlQuery =
|
|
482
|
+
const urlQuery = { ...query };
|
|
479
483
|
if (typeof query.query === 'object') {
|
|
480
484
|
urlQuery.query = makeAndQueryString(query.query);
|
|
481
485
|
}
|
|
@@ -517,15 +521,17 @@ class MusicBrainzApi {
|
|
|
517
521
|
return this.search('url', query);
|
|
518
522
|
}
|
|
519
523
|
async getSession() {
|
|
520
|
-
const response = await
|
|
524
|
+
const response = await got.get('login', {
|
|
525
|
+
...this.options,
|
|
526
|
+
followRedirect: false,
|
|
527
|
+
responseType: 'text'
|
|
528
|
+
});
|
|
521
529
|
return {
|
|
522
530
|
csrf: MusicBrainzApi.fetchCsrf(response.body)
|
|
523
531
|
};
|
|
524
532
|
}
|
|
525
533
|
}
|
|
526
|
-
|
|
527
|
-
function makeAndQueryString(keyValuePairs) {
|
|
534
|
+
export function makeAndQueryString(keyValuePairs) {
|
|
528
535
|
return Object.keys(keyValuePairs).map(key => `${key}:"${keyValuePairs[key]}"`).join(' AND ');
|
|
529
536
|
}
|
|
530
|
-
exports.makeAndQueryString = makeAndQueryString;
|
|
531
537
|
//# sourceMappingURL=musicbrainz-api.js.map
|
package/lib/musicbrainz.types.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LinkType = void 0;
|
|
4
|
-
var LinkType;
|
|
1
|
+
export var LinkType;
|
|
5
2
|
(function (LinkType) {
|
|
6
3
|
LinkType[LinkType["license"] = 302] = "license";
|
|
7
4
|
LinkType[LinkType["production"] = 256] = "production";
|
|
@@ -13,5 +10,5 @@ var LinkType;
|
|
|
13
10
|
LinkType[LinkType["crowdfunding_page"] = 905] = "crowdfunding_page";
|
|
14
11
|
LinkType[LinkType["other_databases"] = 306] = "other_databases";
|
|
15
12
|
LinkType[LinkType["Allmusic"] = 285] = "Allmusic";
|
|
16
|
-
})(LinkType =
|
|
13
|
+
})(LinkType = LinkType || (LinkType = {}));
|
|
17
14
|
//# sourceMappingURL=musicbrainz.types.js.map
|
package/lib/rate-limiter.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const debug_1 = require("debug");
|
|
5
|
-
const debug = (0, debug_1.default)('musicbrainz-api:rate-limiter');
|
|
6
|
-
class RateLimiter {
|
|
1
|
+
import Debug from 'debug';
|
|
2
|
+
const debug = Debug('musicbrainz-api:rate-limiter');
|
|
3
|
+
export class RateLimiter {
|
|
7
4
|
static sleep(ms) {
|
|
8
5
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
9
6
|
}
|
|
@@ -30,5 +27,4 @@ class RateLimiter {
|
|
|
30
27
|
// const ratePerSec = 1000 * this.queue.length / (now - this.queue[0]);
|
|
31
28
|
}
|
|
32
29
|
}
|
|
33
|
-
exports.RateLimiter = RateLimiter;
|
|
34
30
|
//# sourceMappingURL=rate-limiter.js.map
|
package/lib/xml/xml-isrc-list.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.XmlIsrcList = void 0;
|
|
4
|
-
const xml_isrc_1 = require("./xml-isrc");
|
|
5
|
-
class XmlIsrcList {
|
|
1
|
+
import { XmlIsrc } from './xml-isrc.js';
|
|
2
|
+
export class XmlIsrcList {
|
|
6
3
|
constructor() {
|
|
7
4
|
this.items = [];
|
|
8
5
|
}
|
|
9
6
|
pushIsrc(isrc) {
|
|
10
|
-
this.items.push(new
|
|
7
|
+
this.items.push(new XmlIsrc(isrc));
|
|
11
8
|
}
|
|
12
9
|
toXml() {
|
|
13
10
|
return this.items.length === 0 ? null : {
|
|
@@ -19,5 +16,4 @@ class XmlIsrcList {
|
|
|
19
16
|
};
|
|
20
17
|
}
|
|
21
18
|
}
|
|
22
|
-
exports.XmlIsrcList = XmlIsrcList;
|
|
23
19
|
//# sourceMappingURL=xml-isrc-list.js.map
|
package/lib/xml/xml-isrc.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.XmlIsrc = void 0;
|
|
4
|
-
class XmlIsrc {
|
|
1
|
+
export class XmlIsrc {
|
|
5
2
|
constructor(isrc) {
|
|
6
3
|
this.isrc = isrc;
|
|
7
4
|
}
|
|
@@ -14,5 +11,4 @@ class XmlIsrc {
|
|
|
14
11
|
};
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
|
-
exports.XmlIsrc = XmlIsrc;
|
|
18
14
|
//# sourceMappingURL=xml-isrc.js.map
|
package/lib/xml/xml-metadata.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2#ISRC_submission
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const jsontoxml = require("jsontoxml");
|
|
6
|
-
const xml_recording_1 = require("./xml-recording");
|
|
2
|
+
import jsontoxml from 'jsontoxml';
|
|
3
|
+
import { XmlRecording } from './xml-recording.js';
|
|
7
4
|
const ns_metadata = 'http://musicbrainz.org/ns/mmd-2.0#';
|
|
8
|
-
class XmlMetadata {
|
|
5
|
+
export class XmlMetadata {
|
|
9
6
|
constructor() {
|
|
10
7
|
this.recordings = [];
|
|
11
8
|
}
|
|
12
9
|
pushRecording(id) {
|
|
13
|
-
const rec = new
|
|
10
|
+
const rec = new XmlRecording(id);
|
|
14
11
|
this.recordings.push(rec);
|
|
15
12
|
return rec;
|
|
16
13
|
}
|
|
@@ -26,5 +23,4 @@ class XmlMetadata {
|
|
|
26
23
|
}], { prettyPrint: false, escape: true, xmlHeader: true });
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
|
-
exports.XmlMetadata = XmlMetadata;
|
|
30
26
|
//# sourceMappingURL=xml-metadata.js.map
|
package/lib/xml/xml-recording.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.XmlRecording = void 0;
|
|
4
|
-
const xml_isrc_list_1 = require("./xml-isrc-list");
|
|
5
|
-
class XmlRecording {
|
|
1
|
+
import { XmlIsrcList } from './xml-isrc-list.js';
|
|
2
|
+
export class XmlRecording {
|
|
6
3
|
constructor(id) {
|
|
7
4
|
this.id = id;
|
|
8
|
-
this.isrcList = new
|
|
5
|
+
this.isrcList = new XmlIsrcList();
|
|
9
6
|
}
|
|
10
7
|
toXml() {
|
|
11
8
|
return {
|
|
@@ -17,5 +14,4 @@ class XmlRecording {
|
|
|
17
14
|
};
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
|
-
exports.XmlRecording = XmlRecording;
|
|
21
17
|
//# sourceMappingURL=xml-recording.js.map
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "musicbrainz-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "MusicBrainz API client for reading and submitting metadata",
|
|
5
|
-
"
|
|
6
|
-
"types": "lib/index",
|
|
5
|
+
"exports": "./lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib/**/*.js",
|
|
9
|
+
"lib/**/*.d.ts"
|
|
10
|
+
],
|
|
11
|
+
"type": "module",
|
|
7
12
|
"author": {
|
|
8
13
|
"name": "Borewit",
|
|
9
14
|
"url": "https://github.com/Borewit"
|
|
@@ -31,7 +36,7 @@
|
|
|
31
36
|
"license": "MIT",
|
|
32
37
|
"private": false,
|
|
33
38
|
"engines": {
|
|
34
|
-
"node": "
|
|
39
|
+
"node": "^14.13.1 || >=16.0.0"
|
|
35
40
|
},
|
|
36
41
|
"repository": {
|
|
37
42
|
"type": "git",
|
|
@@ -45,8 +50,8 @@
|
|
|
45
50
|
"@types/request-promise-native": "^1.0.17",
|
|
46
51
|
"@types/uuid": "^9.0.0",
|
|
47
52
|
"caseless": "^0.12.0",
|
|
48
|
-
"debug": "^4.
|
|
49
|
-
"got": "^
|
|
53
|
+
"debug": "^4.3.4",
|
|
54
|
+
"got": "^13.0.0",
|
|
50
55
|
"http-status-codes": "^2.1.4",
|
|
51
56
|
"json-stringify-safe": "^5.0.1",
|
|
52
57
|
"jsontoxml": "^1.0.1",
|
|
@@ -61,6 +66,7 @@
|
|
|
61
66
|
"@types/node": "^20.8.10",
|
|
62
67
|
"@typescript-eslint/eslint-plugin": "^5.13.0",
|
|
63
68
|
"@typescript-eslint/parser": "^5.13.0",
|
|
69
|
+
"c8": "^8.0.1",
|
|
64
70
|
"chai": "^4.2.0",
|
|
65
71
|
"del-cli": "^5.0.0",
|
|
66
72
|
"eslint": "^8.10.0",
|
|
@@ -70,18 +76,13 @@
|
|
|
70
76
|
"eslint-plugin-jsdoc": "^46.8.2",
|
|
71
77
|
"eslint-plugin-node": "^11.1.0",
|
|
72
78
|
"eslint-plugin-unicorn": "^46.0.0",
|
|
73
|
-
"mocha": "^
|
|
74
|
-
"nyc": "^15.0.0",
|
|
79
|
+
"mocha": "^10.1.0",
|
|
75
80
|
"remark-cli": "^11.0.0",
|
|
76
81
|
"remark-preset-lint-recommended": "^6.1.2",
|
|
77
82
|
"ts-node": "^10.0.0",
|
|
78
83
|
"tslint": "^6.1.1",
|
|
79
84
|
"typescript": "^5.0.2"
|
|
80
85
|
},
|
|
81
|
-
"files": [
|
|
82
|
-
"lib/**/*.js",
|
|
83
|
-
"lib/**/*.d.ts"
|
|
84
|
-
],
|
|
85
86
|
"scripts": {
|
|
86
87
|
"clean": "del-cli lib/**/*.js lib/**/*.js.map lib/**/*.d.ts test/**/*.js test/**/*.js.map",
|
|
87
88
|
"compile-lib": "tsc -p lib",
|
|
@@ -90,10 +91,10 @@
|
|
|
90
91
|
"eslint": "eslint lib/**/*.ts --ignore-pattern lib/**/*.d.ts test/**/*.ts",
|
|
91
92
|
"lint-md": "remark -u preset-lint-recommended .",
|
|
92
93
|
"lint": "npm run lint-md && npm run eslint",
|
|
93
|
-
"test": "mocha
|
|
94
|
+
"test": "mocha",
|
|
94
95
|
"build": "npm run clean && npm run compile",
|
|
95
96
|
"start": "npm-run-all compile lint cover-test",
|
|
96
|
-
"test-coverage": "
|
|
97
|
+
"test-coverage": "c8 npm run test",
|
|
97
98
|
"send-codacy": "nyc report --reporter=text-lcov | codacy-coverage"
|
|
98
99
|
},
|
|
99
100
|
"nyc": {
|