musicbrainz-api 0.7.0 → 0.8.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/.idea/shelf/Uncommitted_changes_before_Checkout_at_28-2-2022_22_59_[Default_Changelist]/shelved.patch +453 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_28-2-2022_22_59__Default_Changelist_.xml +4 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_3-3-2022_20_28_[Default_Changelist]/shelved.patch +20 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_3-3-2022_20_28__Default_Changelist_.xml +4 -0
- package/.idea/workspace.xml +174 -142
- package/README.md +63 -36
- package/lib/digest-auth.js +1 -6
- package/lib/musicbrainz-api.d.ts +40 -23
- package/lib/musicbrainz-api.js +70 -39
- package/lib/musicbrainz.types.d.ts +171 -32
- package/package.json +28 -20
- package/.idea/shelf/Uncommitted_changes_before_Update_at_6-1-2022_11_38_[Default_Changelist]/shelved.patch +0 -58
- package/.idea/shelf/Uncommitted_changes_before_Update_at_6-1-2022_11_38__Default_Changelist_.xml +0 -4
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ If you plan to use this module for submitting metadata, please ensure you comply
|
|
|
32
32
|
|
|
33
33
|
Import the module
|
|
34
34
|
JavaScript example, how to import 'musicbrainz-api:
|
|
35
|
-
```
|
|
35
|
+
```js
|
|
36
36
|
const MusicBrainzApi = require('musicbrainz-api').MusicBrainzApi;
|
|
37
37
|
|
|
38
38
|
const mbApi = new MusicBrainzApi({
|
|
@@ -43,7 +43,7 @@ const mbApi = new MusicBrainzApi({
|
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
In TypeScript you it would look like this:
|
|
46
|
-
```
|
|
46
|
+
```js
|
|
47
47
|
import {MusicBrainzApi} from 'musicbrainz-api';
|
|
48
48
|
|
|
49
49
|
const mbApi = new MusicBrainzApi({
|
|
@@ -54,7 +54,7 @@ const mbApi = new MusicBrainzApi({
|
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
The following configuration settings can be passed
|
|
57
|
-
```
|
|
57
|
+
```js
|
|
58
58
|
import {MusicBrainzApi} from '../src/musicbrainz-api';
|
|
59
59
|
|
|
60
60
|
const config = {
|
|
@@ -93,49 +93,76 @@ Arguments:
|
|
|
93
93
|
* entity: `'artist'` | `'label'` | `'recording'` | `'release'` | `'release-group'` | `'work'` | `'area'` | `'url'`
|
|
94
94
|
* MBID [(MusicBrainz identifier)](https://wiki.musicbrainz.org/MusicBrainz_Identifier)
|
|
95
95
|
|
|
96
|
-
```
|
|
97
|
-
const artist = await mbApi.
|
|
96
|
+
```js
|
|
97
|
+
const artist = await mbApi.lookupEntity('artist', {query: 'ab2528d9-719f-4261-8098-21849222a0f2'});
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
### Lookup area
|
|
101
101
|
|
|
102
|
-
```
|
|
103
|
-
const area = await mbApi.
|
|
102
|
+
```js
|
|
103
|
+
const area = await mbApi.lookupArea({query: 'ab2528d9-719f-4261-8098-21849222a0f2'});
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
### Lookup artist
|
|
107
107
|
|
|
108
108
|
Lookup an `artist` and include their `releases`, `release-groups` and `aliases`
|
|
109
109
|
|
|
110
|
-
```
|
|
111
|
-
const artist = await mbApi.
|
|
110
|
+
```js
|
|
111
|
+
const artist = await mbApi.lookupArtist({query: 'ab2528d9-719f-4261-8098-21849222a0f2'});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Lookup instrument
|
|
115
|
+
|
|
116
|
+
Lookup an instrument
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
const artist = await mbApi.lookupInstrument({query: 'b3eac5f9-7859-4416-ac39-7154e2e8d348'});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Lookup label
|
|
123
|
+
|
|
124
|
+
Lookup a label
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
const artist = await mbApi.lookupInstrument({query: '25dda9f9-f069-4898-82f0-59330a106c7f'});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Lookup place
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
const artist = await mbApi.lookupPlace({query: 'e6cfb74d-d69b-44c3-b890-1b3f509816e4'});
|
|
112
134
|
```
|
|
113
135
|
|
|
114
136
|
The second argument can be used to pass [subqueries](https://wiki.musicbrainz.org/Development/XML_Web_Service/Version_2#Subqueries), which will return more (nested) information:
|
|
115
|
-
```
|
|
116
|
-
const artist = await mbApi.
|
|
137
|
+
```js
|
|
138
|
+
const artist = await mbApi.lookupArtist('ab2528d9-719f-4261-8098-21849222a0f2', ['releases', 'recordings', 'url-rels']);
|
|
117
139
|
```
|
|
118
140
|
|
|
119
141
|
### Lookup recording
|
|
120
142
|
|
|
121
143
|
The second argument can be used to pass [subqueries](https://wiki.musicbrainz.org/Development/XML_Web_Service/Version_2#Subqueries):
|
|
122
|
-
```
|
|
123
|
-
const artist = await mbApi.
|
|
144
|
+
```js
|
|
145
|
+
const artist = await mbApi.lookupRecording({query: '16afa384-174e-435e-bfa3-5591accda31c'}, ['artists', 'url-rels']);
|
|
124
146
|
```
|
|
125
147
|
|
|
126
148
|
### Lookup release
|
|
127
|
-
```
|
|
128
|
-
const release = await mbApi.
|
|
149
|
+
```js
|
|
150
|
+
const release = await mbApi.lookupRelease({query: '976e0677-a480-4a5e-a177-6a86c1900bbf'}, ['artists', 'url-rels']);
|
|
129
151
|
```
|
|
130
152
|
|
|
131
153
|
### Lookup release-group
|
|
132
|
-
```
|
|
133
|
-
const releaseGroup = await mbApi.
|
|
154
|
+
```js
|
|
155
|
+
const releaseGroup = await mbApi.lookupReleaseGroup({query: '19099ea5-3600-4154-b482-2ec68815883e'});
|
|
134
156
|
```
|
|
135
157
|
|
|
136
158
|
### Lookup work
|
|
137
|
-
```
|
|
138
|
-
const work = await mbApi.
|
|
159
|
+
```js
|
|
160
|
+
const work = await mbApi.lookupWork({query: 'b2aa02f4-6c95-43be-a426-aedb9f9a3805'});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Lookup URL
|
|
164
|
+
```js
|
|
165
|
+
const url = await mbApi.lookupUrl({query: 'c69556a6-7ded-4c54-809c-afb45a1abe7d'});
|
|
139
166
|
```
|
|
140
167
|
|
|
141
168
|
## Search (query)
|
|
@@ -164,28 +191,28 @@ Arguments:
|
|
|
164
191
|
* `limit.query`: optional, an integer value defining how many entries should be returned. Only values between 1 and 100 (both inclusive) are allowed. If not given, this defaults to 25.
|
|
165
192
|
|
|
166
193
|
For example, to find any recordings of _'We Will Rock You'_ by Queen:
|
|
167
|
-
```
|
|
194
|
+
```js
|
|
168
195
|
const query = 'query="We Will Rock You" AND arid:0383dadf-2a4e-4d10-a46a-e9e041da8eb3';
|
|
169
196
|
const result = await mbApi.query<mb.IReleaseGroupList>('release-group', {query});
|
|
170
197
|
```
|
|
171
198
|
|
|
172
199
|
##### Example: search Île-de-France
|
|
173
200
|
|
|
174
|
-
```
|
|
201
|
+
```js
|
|
175
202
|
mbApi.search('area', 'Île-de-France');
|
|
176
203
|
````
|
|
177
204
|
|
|
178
205
|
##### Example: search release by barcode
|
|
179
206
|
|
|
180
207
|
Search a release with the barcode 602537479870:
|
|
181
|
-
```
|
|
182
|
-
mbApi.search('release', {barcode: 602537479870});
|
|
208
|
+
```js
|
|
209
|
+
mbApi.search('release', {query: {barcode: 602537479870}});
|
|
183
210
|
````
|
|
184
211
|
|
|
185
212
|
##### Example: search by object
|
|
186
213
|
|
|
187
214
|
Same as previous example, but automatically serialize parameters to search query
|
|
188
|
-
```
|
|
215
|
+
```js
|
|
189
216
|
mbApi.search('release', 'barcode: 602537479870');
|
|
190
217
|
````
|
|
191
218
|
|
|
@@ -198,17 +225,17 @@ searchReleaseGroup(query: string | IFormData, offset?: number, limit?: number):
|
|
|
198
225
|
```
|
|
199
226
|
|
|
200
227
|
Search artist:
|
|
201
|
-
```
|
|
202
|
-
const result = await mbApi.searchArtist('Stromae');
|
|
228
|
+
```js
|
|
229
|
+
const result = await mbApi.searchArtist({query: 'Stromae'});
|
|
203
230
|
```
|
|
204
231
|
|
|
205
232
|
Search release-group:
|
|
206
|
-
```
|
|
207
|
-
const result = await mbApi.searchReleaseGroup('Racine carrée');
|
|
233
|
+
```js
|
|
234
|
+
const result = await mbApi.searchReleaseGroup({query: 'Racine carrée'});
|
|
208
235
|
```
|
|
209
236
|
|
|
210
237
|
Search a combination of a release-group and an artist.
|
|
211
|
-
```
|
|
238
|
+
```js
|
|
212
239
|
const result = await mbApi.searchReleaseGroup({artist: 'Racine carrée', releasegroup: 'Stromae'});
|
|
213
240
|
```
|
|
214
241
|
|
|
@@ -220,7 +247,7 @@ const result = await mbApi.searchReleaseGroup({artist: 'Racine carrée', release
|
|
|
220
247
|
|
|
221
248
|
Using the [XML ISRC submission](https://wiki.musicbrainz.org/Development/XML_Web_Service/Version_2#ISRC_submission) API.
|
|
222
249
|
|
|
223
|
-
```
|
|
250
|
+
```js
|
|
224
251
|
const mbid_Formidable = '16afa384-174e-435e-bfa3-5591accda31c';
|
|
225
252
|
const isrc_Formidable = 'BET671300161';
|
|
226
253
|
|
|
@@ -239,13 +266,13 @@ For all of the following function you need to use a dedicated bot account.
|
|
|
239
266
|
<img width="150" src="http://www.clker.com/cliparts/i/w/L/q/u/1/work-in-progress.svg"/>
|
|
240
267
|
Use with caution, and only on a test server, it may clear existing metadata as side effect.
|
|
241
268
|
|
|
242
|
-
```
|
|
269
|
+
```js
|
|
243
270
|
|
|
244
271
|
const mbid_Formidable = '16afa384-174e-435e-bfa3-5591accda31c';
|
|
245
272
|
const isrc_Formidable = 'BET671300161';
|
|
246
273
|
|
|
247
274
|
|
|
248
|
-
const recording = await mbApi.
|
|
275
|
+
const recording = await mbApi.lookupRecording(mbid_Formidable);
|
|
249
276
|
|
|
250
277
|
// Authentication the http-session against MusicBrainz (as defined in config.baseUrl)
|
|
251
278
|
const succeed = await mbApi.login();
|
|
@@ -257,8 +284,8 @@ await mbApi.addIsrc(recording, isrc_Formidable);
|
|
|
257
284
|
|
|
258
285
|
### Submit recording URL
|
|
259
286
|
|
|
260
|
-
```
|
|
261
|
-
const recording = await mbApi.
|
|
287
|
+
```js
|
|
288
|
+
const recording = await mbApi.lookupRecording('16afa384-174e-435e-bfa3-5591accda31c');
|
|
262
289
|
|
|
263
290
|
const succeed = await mbApi.login();
|
|
264
291
|
assert.isTrue(succeed, 'Login successful');
|
|
@@ -270,8 +297,8 @@ await mbApi.addUrlToRecording(recording, {
|
|
|
270
297
|
```
|
|
271
298
|
|
|
272
299
|
Actually a Spotify-track-ID can be submitted easier:
|
|
273
|
-
```
|
|
274
|
-
const recording = await mbApi.
|
|
300
|
+
```js
|
|
301
|
+
const recording = await mbApi.lookupRecording('16afa384-174e-435e-bfa3-5591accda31c');
|
|
275
302
|
|
|
276
303
|
const succeed = await mbApi.login();
|
|
277
304
|
assert.isTrue(succeed, 'Login successful');
|
package/lib/digest-auth.js
CHANGED
|
@@ -23,12 +23,7 @@ class DigestAuth {
|
|
|
23
23
|
*/
|
|
24
24
|
static ha1Compute(algorithm, user, realm, pass, nonce, cnonce) {
|
|
25
25
|
const ha1 = md5(user + ':' + realm + ':' + pass); // lgtm [js/insufficient-password-hash]
|
|
26
|
-
|
|
27
|
-
return md5(ha1 + ':' + nonce + ':' + cnonce);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return ha1;
|
|
31
|
-
}
|
|
26
|
+
return algorithm && algorithm.toLowerCase() === 'md5-sess' ? md5(ha1 + ':' + nonce + ':' + cnonce) : ha1;
|
|
32
27
|
}
|
|
33
28
|
digest(method, path, authHeader) {
|
|
34
29
|
// TODO: More complete implementation of RFC 2617.
|
package/lib/musicbrainz-api.d.ts
CHANGED
|
@@ -58,48 +58,66 @@ export declare class MusicBrainzApi {
|
|
|
58
58
|
* @param mbid
|
|
59
59
|
* @param inc
|
|
60
60
|
*/
|
|
61
|
-
|
|
61
|
+
lookupEntity<T>(entity: mb.EntityType, mbid: string, inc?: Includes[]): Promise<T>;
|
|
62
62
|
/**
|
|
63
63
|
* Lookup area
|
|
64
64
|
* @param areaId Area MBID
|
|
65
65
|
* @param inc Sub-queries
|
|
66
66
|
*/
|
|
67
|
-
|
|
67
|
+
lookupArea(areaId: string, inc?: Includes[]): Promise<mb.IArea>;
|
|
68
68
|
/**
|
|
69
69
|
* Lookup artist
|
|
70
70
|
* @param artistId Artist MBID
|
|
71
71
|
* @param inc Sub-queries
|
|
72
72
|
*/
|
|
73
|
-
|
|
73
|
+
lookupArtist(artistId: string, inc?: Includes[]): Promise<mb.IArtist>;
|
|
74
|
+
/**
|
|
75
|
+
* Lookup instrument
|
|
76
|
+
* @param artistId Instrument MBID
|
|
77
|
+
* @param inc Sub-queries
|
|
78
|
+
*/
|
|
79
|
+
lookupInstrument(instrumentId: string, inc?: Includes[]): Promise<mb.IInstrument>;
|
|
80
|
+
/**
|
|
81
|
+
* Lookup label
|
|
82
|
+
* @param labelId Area MBID
|
|
83
|
+
* @param inc Sub-queries
|
|
84
|
+
*/
|
|
85
|
+
lookupLabel(labelId: string, inc?: Includes[]): Promise<mb.ILabel>;
|
|
86
|
+
/**
|
|
87
|
+
* Lookup place
|
|
88
|
+
* @param placeId Area MBID
|
|
89
|
+
* @param inc Sub-queries
|
|
90
|
+
*/
|
|
91
|
+
lookupPlace(placeId: string, inc?: Includes[]): Promise<mb.IPlace>;
|
|
74
92
|
/**
|
|
75
93
|
* Lookup release
|
|
76
94
|
* @param releaseId Release MBID
|
|
77
95
|
* @param inc Include: artist-credits, labels, recordings, release-groups, media, discids, isrcs (with recordings)
|
|
78
96
|
* ToDo: ['recordings', 'artists', 'artist-credits', 'isrcs', 'url-rels', 'release-groups']
|
|
79
97
|
*/
|
|
80
|
-
|
|
98
|
+
lookupRelease(releaseId: string, inc?: Includes[]): Promise<mb.IRelease>;
|
|
81
99
|
/**
|
|
82
100
|
* Lookup release-group
|
|
83
101
|
* @param releaseGroupId Release-group MBID
|
|
84
102
|
* @param inc Include: ToDo
|
|
85
103
|
*/
|
|
86
|
-
|
|
104
|
+
lookupReleaseGroup(releaseGroupId: string, inc?: Includes[]): Promise<mb.IReleaseGroup>;
|
|
87
105
|
/**
|
|
88
|
-
* Lookup
|
|
89
|
-
* @param
|
|
106
|
+
* Lookup recording
|
|
107
|
+
* @param recordingId Label MBID
|
|
108
|
+
* @param inc Include: artist-credits, isrcs
|
|
90
109
|
*/
|
|
91
|
-
|
|
110
|
+
lookupRecording(recordingId: string, inc?: Includes[]): Promise<mb.IRecording>;
|
|
92
111
|
/**
|
|
93
|
-
* Lookup
|
|
94
|
-
* @param
|
|
112
|
+
* Lookup work
|
|
113
|
+
* @param workId Work MBID
|
|
95
114
|
*/
|
|
96
|
-
|
|
115
|
+
lookupWork(workId: string): Promise<mb.IWork>;
|
|
97
116
|
/**
|
|
98
|
-
* Lookup
|
|
99
|
-
* @param
|
|
100
|
-
* @param inc Include: artist-credits, isrcs
|
|
117
|
+
* Lookup URL
|
|
118
|
+
* @param urlId URL MBID
|
|
101
119
|
*/
|
|
102
|
-
|
|
120
|
+
lookupUrl(urlId: string): Promise<mb.IUrl>;
|
|
103
121
|
postRecording(xmlMetadata: XmlMetadata): Promise<void>;
|
|
104
122
|
post(entity: mb.EntityType, xmlMetadata: XmlMetadata): Promise<void>;
|
|
105
123
|
login(): Promise<boolean>;
|
|
@@ -135,10 +153,9 @@ export declare class MusicBrainzApi {
|
|
|
135
153
|
* Search an entity using a search query
|
|
136
154
|
* @param query e.g.: '" artist: Madonna, track: Like a virgin"' or object with search terms: {artist: Madonna}
|
|
137
155
|
* @param entity e.g. 'recording'
|
|
138
|
-
* @param
|
|
139
|
-
* @param limit
|
|
156
|
+
* @param query Arguments
|
|
140
157
|
*/
|
|
141
|
-
search<T extends mb.ISearchResult>(entity: mb.EntityType, query:
|
|
158
|
+
search<T extends mb.ISearchResult>(entity: mb.EntityType, query: mb.ISearchQuery): Promise<T>;
|
|
142
159
|
/**
|
|
143
160
|
* Add Spotify-ID to MusicBrainz recording.
|
|
144
161
|
* This function will automatically lookup the recording title, which is required to submit the recording URL
|
|
@@ -147,11 +164,11 @@ export declare class MusicBrainzApi {
|
|
|
147
164
|
* @param editNote Comment to add.
|
|
148
165
|
*/
|
|
149
166
|
addSpotifyIdToRecording(recording: mb.IRecording, spotifyId: string, editNote: string): Promise<void>;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
searchUrl(query:
|
|
167
|
+
searchArea(query: mb.ISearchQuery & mb.ILinkedEntitiesArea): Promise<mb.IAreaList>;
|
|
168
|
+
searchArtist(query: mb.ISearchQuery & mb.ILinkedEntitiesArtist): Promise<mb.IArtistList>;
|
|
169
|
+
searchRelease(query: mb.ISearchQuery & mb.ILinkedEntitiesRelease): Promise<mb.IReleaseList>;
|
|
170
|
+
searchReleaseGroup(query: mb.ISearchQuery & mb.ILinkedEntitiesReleaseGroup): Promise<mb.IReleaseGroupList>;
|
|
171
|
+
searchUrl(query: mb.ISearchQuery & mb.ILinkedEntitiesUrl): Promise<mb.IUrlList>;
|
|
155
172
|
private getSession;
|
|
156
173
|
}
|
|
157
174
|
export declare function makeAndQueryString(keyValuePairs: IFormData): string;
|
package/lib/musicbrainz-api.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -134,7 +138,7 @@ class MusicBrainzApi {
|
|
|
134
138
|
* @param mbid
|
|
135
139
|
* @param inc
|
|
136
140
|
*/
|
|
137
|
-
|
|
141
|
+
lookupEntity(entity, mbid, inc = []) {
|
|
138
142
|
return this.restGet(`/${entity}/${mbid}`, { inc: inc.join(' ') });
|
|
139
143
|
}
|
|
140
144
|
/**
|
|
@@ -142,16 +146,40 @@ class MusicBrainzApi {
|
|
|
142
146
|
* @param areaId Area MBID
|
|
143
147
|
* @param inc Sub-queries
|
|
144
148
|
*/
|
|
145
|
-
|
|
146
|
-
return this.
|
|
149
|
+
lookupArea(areaId, inc = []) {
|
|
150
|
+
return this.lookupEntity('area', areaId, inc);
|
|
147
151
|
}
|
|
148
152
|
/**
|
|
149
153
|
* Lookup artist
|
|
150
154
|
* @param artistId Artist MBID
|
|
151
155
|
* @param inc Sub-queries
|
|
152
156
|
*/
|
|
153
|
-
|
|
154
|
-
return this.
|
|
157
|
+
lookupArtist(artistId, inc = []) {
|
|
158
|
+
return this.lookupEntity('artist', artistId, inc);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Lookup instrument
|
|
162
|
+
* @param artistId Instrument MBID
|
|
163
|
+
* @param inc Sub-queries
|
|
164
|
+
*/
|
|
165
|
+
lookupInstrument(instrumentId, inc = []) {
|
|
166
|
+
return this.lookupEntity('instrument', instrumentId, inc);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Lookup label
|
|
170
|
+
* @param labelId Area MBID
|
|
171
|
+
* @param inc Sub-queries
|
|
172
|
+
*/
|
|
173
|
+
lookupLabel(labelId, inc = []) {
|
|
174
|
+
return this.lookupEntity('label', labelId, inc);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Lookup place
|
|
178
|
+
* @param placeId Area MBID
|
|
179
|
+
* @param inc Sub-queries
|
|
180
|
+
*/
|
|
181
|
+
lookupPlace(placeId, inc = []) {
|
|
182
|
+
return this.lookupEntity('place', placeId, inc);
|
|
155
183
|
}
|
|
156
184
|
/**
|
|
157
185
|
* Lookup release
|
|
@@ -159,38 +187,38 @@ class MusicBrainzApi {
|
|
|
159
187
|
* @param inc Include: artist-credits, labels, recordings, release-groups, media, discids, isrcs (with recordings)
|
|
160
188
|
* ToDo: ['recordings', 'artists', 'artist-credits', 'isrcs', 'url-rels', 'release-groups']
|
|
161
189
|
*/
|
|
162
|
-
|
|
163
|
-
return this.
|
|
190
|
+
lookupRelease(releaseId, inc = []) {
|
|
191
|
+
return this.lookupEntity('release', releaseId, inc);
|
|
164
192
|
}
|
|
165
193
|
/**
|
|
166
194
|
* Lookup release-group
|
|
167
195
|
* @param releaseGroupId Release-group MBID
|
|
168
196
|
* @param inc Include: ToDo
|
|
169
197
|
*/
|
|
170
|
-
|
|
171
|
-
return this.
|
|
198
|
+
lookupReleaseGroup(releaseGroupId, inc = []) {
|
|
199
|
+
return this.lookupEntity('release-group', releaseGroupId, inc);
|
|
172
200
|
}
|
|
173
201
|
/**
|
|
174
|
-
* Lookup
|
|
175
|
-
* @param
|
|
202
|
+
* Lookup recording
|
|
203
|
+
* @param recordingId Label MBID
|
|
204
|
+
* @param inc Include: artist-credits, isrcs
|
|
176
205
|
*/
|
|
177
|
-
|
|
178
|
-
return this.
|
|
206
|
+
lookupRecording(recordingId, inc = []) {
|
|
207
|
+
return this.lookupEntity('recording', recordingId, inc);
|
|
179
208
|
}
|
|
180
209
|
/**
|
|
181
|
-
* Lookup
|
|
182
|
-
* @param
|
|
210
|
+
* Lookup work
|
|
211
|
+
* @param workId Work MBID
|
|
183
212
|
*/
|
|
184
|
-
|
|
185
|
-
return this.
|
|
213
|
+
lookupWork(workId) {
|
|
214
|
+
return this.lookupEntity('work', workId);
|
|
186
215
|
}
|
|
187
216
|
/**
|
|
188
|
-
* Lookup
|
|
189
|
-
* @param
|
|
190
|
-
* @param inc Include: artist-credits, isrcs
|
|
217
|
+
* Lookup URL
|
|
218
|
+
* @param urlId URL MBID
|
|
191
219
|
*/
|
|
192
|
-
|
|
193
|
-
return this.
|
|
220
|
+
lookupUrl(urlId) {
|
|
221
|
+
return this.lookupEntity('url', urlId);
|
|
194
222
|
}
|
|
195
223
|
async postRecording(xmlMetadata) {
|
|
196
224
|
return this.post('recording', xmlMetadata);
|
|
@@ -332,14 +360,17 @@ class MusicBrainzApi {
|
|
|
332
360
|
* Search an entity using a search query
|
|
333
361
|
* @param query e.g.: '" artist: Madonna, track: Like a virgin"' or object with search terms: {artist: Madonna}
|
|
334
362
|
* @param entity e.g. 'recording'
|
|
335
|
-
* @param
|
|
336
|
-
* @param limit
|
|
363
|
+
* @param query Arguments
|
|
337
364
|
*/
|
|
338
|
-
search(entity, query
|
|
339
|
-
|
|
340
|
-
|
|
365
|
+
search(entity, query) {
|
|
366
|
+
const urlQuery = Object.assign({}, query);
|
|
367
|
+
if (typeof query.query === 'object') {
|
|
368
|
+
urlQuery.query = makeAndQueryString(query.query);
|
|
369
|
+
}
|
|
370
|
+
if (Array.isArray(query.inc)) {
|
|
371
|
+
urlQuery.inc = urlQuery.inc.join(' ');
|
|
341
372
|
}
|
|
342
|
-
return this.restGet('/' + entity + '/',
|
|
373
|
+
return this.restGet('/' + entity + '/', urlQuery);
|
|
343
374
|
}
|
|
344
375
|
// -----------------------------------------------------------------------------------------------------------------
|
|
345
376
|
// Helper functions
|
|
@@ -358,20 +389,20 @@ class MusicBrainzApi {
|
|
|
358
389
|
text: 'https://open.spotify.com/track/' + spotifyId
|
|
359
390
|
}, editNote);
|
|
360
391
|
}
|
|
361
|
-
|
|
362
|
-
return this.search('
|
|
392
|
+
searchArea(query) {
|
|
393
|
+
return this.search('area', query);
|
|
363
394
|
}
|
|
364
|
-
|
|
365
|
-
return this.search('
|
|
395
|
+
searchArtist(query) {
|
|
396
|
+
return this.search('artist', query);
|
|
366
397
|
}
|
|
367
|
-
|
|
368
|
-
return this.search('release
|
|
398
|
+
searchRelease(query) {
|
|
399
|
+
return this.search('release', query);
|
|
369
400
|
}
|
|
370
|
-
|
|
371
|
-
return this.search('
|
|
401
|
+
searchReleaseGroup(query) {
|
|
402
|
+
return this.search('release-group', query);
|
|
372
403
|
}
|
|
373
|
-
searchUrl(query
|
|
374
|
-
return this.search('url', query
|
|
404
|
+
searchUrl(query) {
|
|
405
|
+
return this.search('url', query);
|
|
375
406
|
}
|
|
376
407
|
async getSession(url) {
|
|
377
408
|
const response = await got_1.default.get('login', Object.assign({ followRedirect: false, responseType: 'text' }, this.options));
|