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.
@@ -1,17 +1,20 @@
1
1
  import DateTimeFormat = Intl.DateTimeFormat;
2
+ import { IFormData, Includes } from './musicbrainz-api';
2
3
  export interface IPeriod {
3
4
  'begin': string;
4
5
  'ended': boolean;
5
6
  'end': string;
6
7
  }
7
- export interface IArea {
8
+ export interface IEntity {
8
9
  id: string;
10
+ }
11
+ export interface IArea extends IEntity {
9
12
  'iso-3166-1-codes': string[];
10
13
  name: string;
11
14
  'sort-name': string;
12
15
  disambiguation: string;
13
16
  }
14
- export interface IAlias {
17
+ export interface IAlias extends IEntity {
15
18
  name: string;
16
19
  'sort-name': string;
17
20
  ended: boolean;
@@ -25,8 +28,7 @@ export interface IAlias {
25
28
  export interface IMatch {
26
29
  score: number;
27
30
  }
28
- export interface IArtist {
29
- id: string;
31
+ export interface IArtist extends IEntity {
30
32
  name: string;
31
33
  disambiguation: string;
32
34
  'sort-name': string;
@@ -54,9 +56,25 @@ export interface IArtistCredit {
54
56
  joinphrase: string;
55
57
  name: string;
56
58
  }
59
+ export interface IEvent extends IEntity {
60
+ cancelled: boolean;
61
+ type: string;
62
+ 'life-span': IPeriod;
63
+ disambiguation: string;
64
+ 'type-id': string;
65
+ time: string;
66
+ setlist: string;
67
+ name: string;
68
+ }
69
+ export interface IInstrument extends IEntity {
70
+ disambiguation: string;
71
+ name: string;
72
+ 'type-id': string;
73
+ type: string;
74
+ description: string;
75
+ }
57
76
  export declare type ReleaseQuality = 'normal';
58
- export interface IRelease {
59
- id: string;
77
+ export interface IRelease extends IEntity {
60
78
  title: string;
61
79
  'text-representation': {
62
80
  'language': string;
@@ -84,23 +102,21 @@ export interface IReleaseEvent {
84
102
  date?: string;
85
103
  }
86
104
  export declare type MediaFormatType = 'Digital Media';
87
- export interface IRecording {
88
- id: string;
105
+ export interface IRecording extends IEntity {
89
106
  video: boolean;
90
107
  length: number;
91
108
  title: string;
92
109
  disambiguation: string;
93
110
  isrcs?: string[];
94
- releases?: IRelease;
111
+ releases?: IRelease[];
95
112
  relations?: IRelation[];
96
113
  'artist-credit'?: IArtistCredit[];
97
114
  aliases?: IAlias[];
98
115
  }
99
- export interface ITrack {
100
- id: string;
116
+ export interface ITrack extends IEntity {
101
117
  position: number;
102
118
  recording: IRecording;
103
- number: string;
119
+ 'number': string;
104
120
  length: number;
105
121
  title: string;
106
122
  'artist-credit'?: IArtistCredit[];
@@ -109,10 +125,10 @@ export interface IMedium {
109
125
  title: string;
110
126
  format?: string;
111
127
  'format-id': string;
112
- 'tracks': ITrack[];
128
+ tracks: ITrack[];
113
129
  'track-count': number;
114
130
  'track-offset': number;
115
- 'position': number;
131
+ position: number;
116
132
  }
117
133
  export interface ICoverArtArchive {
118
134
  count: number;
@@ -121,15 +137,16 @@ export interface ICoverArtArchive {
121
137
  artwork: boolean;
122
138
  back: boolean;
123
139
  }
124
- export interface IReleaseGroup {
125
- id: string;
140
+ export interface IReleaseGroup extends IEntity {
126
141
  count: number;
127
142
  title: string;
128
143
  'primary-type': string;
129
144
  'sort-name': string;
130
- 'artist-credit': [{
145
+ 'artist-credit': {
131
146
  artist: IArtist;
132
- }];
147
+ name: string;
148
+ joinphrase: string;
149
+ }[];
133
150
  releases?: IRelease[];
134
151
  }
135
152
  export interface IArtistMatch extends IArtist, IMatch {
@@ -162,7 +179,7 @@ export interface IUrlList extends ISearchResult {
162
179
  }
163
180
  export declare type RelationDirection = 'backward' | 'forward';
164
181
  export interface IRelation {
165
- 'attribute-ids': {};
182
+ 'attribute-ids': any;
166
183
  direction: RelationDirection;
167
184
  'target-credit': string;
168
185
  end: null | object;
@@ -174,35 +191,32 @@ export interface IRelation {
174
191
  begin?: null | object;
175
192
  'target-type'?: 'url';
176
193
  'type-id': string;
177
- url?: IURL;
194
+ url?: IUrl;
178
195
  release?: IRelease;
179
196
  }
180
- export interface IURL {
181
- id: string;
182
- resource: string;
183
- }
184
197
  export interface IRelationList {
185
198
  relations: IRelation[];
186
199
  }
187
- export interface IWork {
188
- id: string;
200
+ export interface IWork extends IEntity {
189
201
  title: string;
190
202
  }
191
- export interface ILabel {
192
- id: string;
203
+ export interface ILabel extends IEntity {
204
+ name: string;
205
+ }
206
+ export interface IPlace extends IEntity {
193
207
  name: string;
194
208
  }
195
- export interface IUrl {
209
+ export interface IUrl extends IEntity {
196
210
  id: string;
197
211
  resource: string;
198
- 'relation-list': IRelationList[];
212
+ 'relation-list'?: IRelationList[];
199
213
  }
200
214
  export interface IUrlMatch extends IMatch, IUrl {
201
215
  }
202
216
  export interface IUrlSearchResult extends ISearchResult {
203
217
  urls?: IUrlMatch[];
204
218
  }
205
- export interface IIsrcSearchResult {
219
+ export interface IIsrcSearchResult extends ISearchResult {
206
220
  'isrc': string;
207
221
  'recordings': IRecording[];
208
222
  }
@@ -249,5 +263,130 @@ export interface ISearchQuery extends IPagination {
249
263
  /**
250
264
  * Lucene search query, this is mandatory
251
265
  */
252
- query: string;
266
+ query?: string | IFormData;
267
+ inc?: Includes[];
268
+ }
269
+ /**
270
+ * https://musicbrainz.org/doc/MusicBrainz_API#Browse
271
+ * /ws/2/area collection
272
+ */
273
+ export interface ILinkedEntitiesArea {
274
+ collection?: string;
275
+ }
276
+ /**
277
+ * https://musicbrainz.org/doc/MusicBrainz_API#Browse
278
+ * /ws/2/artist area, collection, recording, release, release-group, work
279
+ */
280
+ export interface ILinkedEntitiesArtist {
281
+ area?: string;
282
+ collection?: string;
283
+ recording?: string;
284
+ release?: string;
285
+ 'release-group'?: string;
286
+ work?: string;
287
+ }
288
+ /**
289
+ * https://musicbrainz.org/doc/MusicBrainz_API#Browse
290
+ * /ws/2/collection area, artist, editor, event, label, place, recording, release, release-group, work
291
+ */
292
+ export interface ILinkedEntitiesCollection {
293
+ area?: string;
294
+ artist?: string;
295
+ editor?: string;
296
+ event?: string;
297
+ label?: string;
298
+ place?: string;
299
+ recording?: string;
300
+ release?: string;
301
+ 'release-group'?: string;
302
+ work?: string;
303
+ }
304
+ /**
305
+ * https://musicbrainz.org/doc/MusicBrainz_API#Subqueries
306
+ * /ws/2/event area, artist, collection, place
307
+ */
308
+ export interface ILinkedEntitiesEvent {
309
+ area?: string;
310
+ artist?: string;
311
+ collection?: string;
312
+ place?: string;
313
+ }
314
+ /**
315
+ * https://musicbrainz.org/doc/MusicBrainz_API#Subqueries
316
+ * /ws/2/instrument collection
317
+ */
318
+ export interface ILinkedEntitiesInstrument {
319
+ collection?: string;
320
+ }
321
+ /**
322
+ * https://musicbrainz.org/doc/MusicBrainz_API#Subqueries
323
+ * /ws/2/label area, collection, release
324
+ */
325
+ export interface ILinkedEntitiesLabel {
326
+ area?: string;
327
+ collection?: string;
328
+ release?: string;
329
+ }
330
+ /**
331
+ * https://musicbrainz.org/doc/MusicBrainz_API#Subqueries
332
+ * /ws/2/place area, collection
333
+ */
334
+ export interface IBrowseArgumentPlace {
335
+ area?: string;
336
+ collection?: string;
337
+ }
338
+ /**
339
+ * https://musicbrainz.org/doc/MusicBrainz_API#Subqueries
340
+ * /ws/2/recording artist, collection, release, work
341
+ */
342
+ export interface ILinkedEntitiesRecording {
343
+ area?: string;
344
+ collection?: string;
345
+ release?: string;
346
+ work?: string;
347
+ }
348
+ /**
349
+ * https://musicbrainz.org/doc/MusicBrainz_API#Subqueries
350
+ * /ws/2/release area, artist, collection, label, track, track_artist, recording, release-group
351
+ */
352
+ export interface ILinkedEntitiesRelease {
353
+ area?: string;
354
+ artist?: string;
355
+ collection?: string;
356
+ label?: string;
357
+ track?: string;
358
+ track_artist?: string;
359
+ recording?: string;
360
+ 'release-group'?: string;
361
+ }
362
+ /**
363
+ * https://musicbrainz.org/doc/MusicBrainz_API#Subqueries
364
+ * /ws/2/release-group artist, collection, release
365
+ */
366
+ export interface ILinkedEntitiesReleaseGroup {
367
+ artist?: string;
368
+ collection?: string;
369
+ release?: string;
370
+ }
371
+ /**
372
+ * https://musicbrainz.org/doc/MusicBrainz_API#Subqueries
373
+ * /ws/2/series collection
374
+ */
375
+ export interface ILinkedEntitiesSeries {
376
+ collection?: string;
377
+ }
378
+ /**
379
+ * https://musicbrainz.org/doc/MusicBrainz_API#Browse
380
+ * /ws/2/work artist, collection
381
+ */
382
+ export interface ILinkedEntitiesWork {
383
+ artist?: string;
384
+ collection?: string;
385
+ }
386
+ /**
387
+ * https://musicbrainz.org/doc/MusicBrainz_API#Browse
388
+ * /ws/2/url resource
389
+ */
390
+ export interface ILinkedEntitiesUrl {
391
+ resource?: string;
253
392
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musicbrainz-api",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "MusicBrainz API client for reading and submitting metadata",
5
5
  "main": "lib/musicbrainz-api",
6
6
  "types": "lib/musicbrainz-api",
@@ -24,21 +24,6 @@
24
24
  ],
25
25
  "license": "MIT",
26
26
  "private": false,
27
- "devDependencies": {
28
- "@types/chai": "^4.2.5",
29
- "@types/mocha": "^9.0.0",
30
- "@types/node": "^17.0.8",
31
- "chai": "^4.2.0",
32
- "coveralls": "^3.0.9",
33
- "del-cli": "^4.0.1",
34
- "mocha": "^9.0.1",
35
- "nyc": "^15.0.0",
36
- "remark-cli": "^10.0.1",
37
- "remark-preset-lint-recommended": "^6.1.2",
38
- "ts-node": "^10.0.0",
39
- "tslint": "^6.1.1",
40
- "typescript": "^4.0.2"
41
- },
42
27
  "engines": {
43
28
  "node": "*"
44
29
  },
@@ -63,14 +48,38 @@
63
48
  "tough-cookie": "^4.0.0",
64
49
  "uuid": "^8.3.2"
65
50
  },
51
+ "devDependencies": {
52
+ "@types/chai": "^4.3.0",
53
+ "@types/mocha": "^9.0.0",
54
+ "@types/node": "^17.0.8",
55
+ "@typescript-eslint/eslint-plugin": "^5.13.0",
56
+ "@typescript-eslint/parser": "^5.13.0",
57
+ "chai": "^4.2.0",
58
+ "coveralls": "^3.0.9",
59
+ "del-cli": "^4.0.1",
60
+ "eslint": "^8.10.0",
61
+ "eslint-config-prettier": "^8.4.0",
62
+ "eslint-import-resolver-typescript": "^2.5.0",
63
+ "eslint-plugin-import": "^2.25.4",
64
+ "eslint-plugin-jsdoc": "^37.9.5",
65
+ "eslint-plugin-node": "^11.1.0",
66
+ "eslint-plugin-unicorn": "^41.0.0",
67
+ "mocha": "^9.0.1",
68
+ "nyc": "^15.0.0",
69
+ "remark-cli": "^10.0.1",
70
+ "remark-preset-lint-recommended": "^6.1.2",
71
+ "ts-node": "^10.0.0",
72
+ "tslint": "^6.1.1",
73
+ "typescript": "^4.0.2"
74
+ },
66
75
  "scripts": {
67
- "clean": "del-cli lib/** src/**/*.js src/**/*.js.map src/**/*.d.ts test/**/*.js test/**/*.js.map",
76
+ "clean": "del-cli src/**/*.js src/**/*.js.map src/**/*.d.ts test/**/*.js test/**/*.js.map",
68
77
  "compile-src": "tsc -p src",
69
78
  "compile-test": "tsc -p test",
70
79
  "compile": "npm run compile-src && npm run compile-test",
71
- "lint-ts": "tslint 'src/**/*.ts' --exclude 'src/**/*.d.ts' 'test/**/*.ts' --exclude 'test/**/*.d.ts'",
80
+ "eslint": "eslint src/**/*.ts --ignore-pattern src/**/*.d.ts test/**/*.ts",
72
81
  "lint-md": "remark -u preset-lint-recommended .",
73
- "lint": "npm run lint-md && npm run lint-ts",
82
+ "lint": "npm run lint-md && npm run eslint",
74
83
  "test": "mocha --require ts-node/register --require source-map-support/register --full-trace test/test-*.ts",
75
84
  "build": "npm run clean && npm run compile",
76
85
  "start": "npm-run-all compile lint cover-test",
@@ -80,7 +89,6 @@
80
89
  },
81
90
  "nyc": {
82
91
  "exclude": [
83
- "lib/**",
84
92
  "test/**/*.ts",
85
93
  "src/**/*.js"
86
94
  ],
@@ -1,58 +0,0 @@
1
- Index: test/test-musicbrainz-api.ts
2
- IDEA additional info:
3
- Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
4
- <+>import { IMusicBrainzConfig, LinkType, MusicBrainzApi } from '../src/musicbrainz-api';\r\nimport { assert } from 'chai';\r\nimport { XmlMetadata } from '../src/xml/xml-metadata';\r\nimport * as mb from '../src/musicbrainz.types';\r\nimport * as fs from 'fs';\r\nimport * as path from 'path';\r\n\r\nconst packageInfo = require('../package.json');\r\n\r\nconst appUrl = 'https://github.com/Borewit/musicbrainz-api';\r\n\r\nconst testBotAccount = {\r\n username: process.env.MBUSER,\r\n password: process.env.MBPWD\r\n};\r\n\r\nconst testApiConfig: IMusicBrainzConfig = {\r\n botAccount: testBotAccount,\r\n baseUrl: 'https://test.musicbrainz.org',\r\n\r\n /**\r\n * Enable proxy, like Fiddler\r\n */\r\n proxy: process.env.MBPROXY,\r\n\r\n appName: packageInfo.name,\r\n appVersion: packageInfo.version,\r\n appContactInfo: appUrl\r\n};\r\n\r\nconst searchApiConfig: IMusicBrainzConfig = {\r\n\r\n baseUrl: 'https://musicbrainz.org',\r\n\r\n /**\r\n * Enable proxy, like Fiddler\r\n */\r\n proxy: process.env.MBPROXY,\r\n\r\n appName: packageInfo.name,\r\n appVersion: packageInfo.version,\r\n appContactInfo: appUrl\r\n};\r\n\r\nconst mbTestApi = new MusicBrainzApi(testApiConfig);\r\nconst mbApi = new MusicBrainzApi(searchApiConfig);\r\n\r\n// Hack shared rate-limiter\r\n(mbApi as any).rateLimiter = (mbTestApi as any).rateLimiter;\r\n\r\ndescribe('MusicBrainz-api', function() {\r\n\r\n this.timeout(20000); // MusicBrainz has a rate limiter\r\n\r\n const mbid = {\r\n artist: {\r\n Stromae: 'ab2528d9-719f-4261-8098-21849222a0f2'\r\n },\r\n recording: {\r\n Formidable: '16afa384-174e-435e-bfa3-5591accda31c',\r\n Montilla: '2faab3ff-1b3a-4378-bfa2-0513446644ed'\r\n },\r\n release: {\r\n Formidable: '976e0677-a480-4a5e-a177-6a86c1900bbf',\r\n Anomalie: '478aaba4-9425-4a67-8951-a77739462df4',\r\n RacineCarree: [\r\n '348662a8-54ce-4d14-adf5-3ce2cefd57bb',\r\n 'c22bdb3a-69c0-449a-9ef5-99796bb0f2d7',\r\n 'de57c1d9-5e65-420f-a896-1332e87d4c09'\r\n ]\r\n },\r\n releaseGroup: {\r\n Formidable: '19099ea5-3600-4154-b482-2ec68815883e',\r\n RacineCarree: 'd079dc50-fa9b-4a88-90f4-5e8723accd75'\r\n },\r\n work: {\r\n Formidable: 'b2aa02f4-6c95-43be-a426-aedb9f9a3805'\r\n },\r\n area: {\r\n Belgium: '5b8a5ee5-0bb3-34cf-9a75-c27c44e341fc',\r\n IleDeFrance: 'd79e4501-8cba-431b-96e7-bb9976f0ae76'\r\n },\r\n label: {\r\n Mosaert: '0550200c-22c1-4c62-b761-ef0b3665262b'\r\n }\r\n };\r\n\r\n const spotify = {\r\n album: {\r\n RacineCarree: {\r\n id: '6uyslsVGFsHKzdGUosFwBM'\r\n }\r\n },\r\n track: {\r\n Formidable: {\r\n id: '2AMysGXOe0zzZJMtH3Nizb'\r\n }\r\n }\r\n };\r\n\r\n it('Required environment variable', () => {\r\n assert.isDefined(process.env.MBUSER, 'process.env.MBUSER');\r\n assert.isDefined(process.env.MBPWD, 'process.env.MBPWD');\r\n });\r\n\r\n it('Extract CSRF', () => {\r\n const html = fs.readFileSync(path.join(__dirname, 'csrf.html'), 'utf8');\r\n const csrf = MusicBrainzApi.fetchCsrf(html);\r\n assert.deepStrictEqual(csrf, {\r\n sessionKey: 'csrf_token:x0VIlHob5nPcWKqJIwNPwE5Y3kE+nGQ9fccgTSYbuMU=',\r\n token: '6G9f/xJ6Y4fLVvfYGHrzBUM34j6hy4CJrBi3VkVwO9I='\r\n }, 'CSRF data');\r\n });\r\n\r\n describe('Read metadata', () => {\r\n\r\n describe('Lookup', () => {\r\n\r\n it('get area', async () => {\r\n const area = await mbApi.getArea(mbid.area.Belgium);\r\n assert.strictEqual(area.id, mbid.area.Belgium);\r\n assert.strictEqual(area.name, 'Belgium');\r\n });\r\n\r\n it('get artist', async () => {\r\n const artist = await mbApi.getArtist(mbid.artist.Stromae);\r\n assert.strictEqual(artist.id, mbid.artist.Stromae);\r\n assert.strictEqual(artist.name, 'Stromae');\r\n });\r\n\r\n describe('Release', () => {\r\n\r\n it('get release Formidable', async () => {\r\n const release = await mbApi.getRelease(mbid.release.Formidable);\r\n assert.strictEqual(release.id, mbid.release.Formidable);\r\n assert.strictEqual(release.title, 'Formidable');\r\n });\r\n\r\n it('check release Anomalie', async () => {\r\n const release = await mbApi.getRelease(mbid.release.Anomalie);\r\n assert.strictEqual(release.id, mbid.release.Anomalie);\r\n assert.strictEqual(release.title, 'Anomalie');\r\n });\r\n\r\n [\r\n {inc: 'artist-credits', key: 'artist-credit'},\r\n {inc: 'artists', key: 'artist-credit'},\r\n {inc: 'collections', key: 'collections'},\r\n {inc: 'labels', key: 'release-events'},\r\n {inc: 'media', key: 'media'},\r\n // {inc: 'recordings', key: 'recordings'},\r\n {inc: 'release-groups', key: 'release-group'}\r\n ].forEach(inc => {\r\n\r\n it(`get release, include: '${inc.inc}'`, async () => {\r\n const release = await mbApi.getRelease(mbid.release.Formidable, [inc.inc as any]);\r\n assert.strictEqual(release.id, mbid.release.Formidable);\r\n assert.strictEqual(release.title, 'Formidable');\r\n assert.isDefined(release[inc.key], `Should include '${inc.key}'`);\r\n });\r\n });\r\n\r\n });\r\n\r\n describe('Release-group', () => {\r\n\r\n it('get release-group', async () => {\r\n const releaseGroup = await mbApi.getReleaseGroup(mbid.releaseGroup.Formidable);\r\n assert.strictEqual(releaseGroup.id, mbid.releaseGroup.Formidable);\r\n assert.strictEqual(releaseGroup.title, 'Formidable');\r\n });\r\n\r\n [\r\n {inc: 'artist-credits', key: 'artist-credit'}\r\n ].forEach(inc => {\r\n\r\n it(`get release-group, include: '${inc.inc}'`, async () => {\r\n const group = await mbApi.getReleaseGroup(mbid.releaseGroup.Formidable, [inc.inc as any]);\r\n assert.strictEqual(group.id, mbid.releaseGroup.Formidable);\r\n assert.strictEqual(group.title, 'Formidable');\r\n assert.isDefined(group[inc.key], `Should include '${inc.key}'`);\r\n });\r\n });\r\n\r\n });\r\n\r\n it('get work', async () => {\r\n const work = await mbApi.getWork(mbid.work.Formidable);\r\n assert.strictEqual(work.id, mbid.work.Formidable);\r\n assert.strictEqual(work.title, 'Formidable');\r\n });\r\n\r\n it('get label', async () => {\r\n const label = await mbApi.getLabel(mbid.label.Mosaert);\r\n assert.strictEqual(label.id, mbid.label.Mosaert);\r\n assert.strictEqual(label.name, 'Mosaert');\r\n });\r\n\r\n describe('Recording', () => {\r\n\r\n it('get recording', async () => {\r\n const recording = await mbApi.getRecording(mbid.recording.Formidable);\r\n assert.strictEqual(recording.id, mbid.recording.Formidable);\r\n assert.strictEqual(recording.title, 'Formidable');\r\n assert.isUndefined(recording.isrcs);\r\n assert.isUndefined(recording['artist-credit']);\r\n assert.isUndefined(recording.releases);\r\n });\r\n\r\n [\r\n {inc: 'isrcs', key: 'isrcs'},\r\n {inc: 'artist-credits', key: 'artist-credit'},\r\n {inc: 'artists', key: 'artist-credit'},\r\n {inc: 'releases', key: 'releases'}\r\n ].forEach(inc => {\r\n\r\n it(`get recording, include: '${inc.inc}'`, async () => {\r\n const recording = await mbApi.getRecording(mbid.recording.Formidable, [inc.inc as any]);\r\n assert.strictEqual(recording.id, mbid.recording.Formidable);\r\n assert.strictEqual(recording.title, 'Formidable');\r\n assert.isDefined(recording[inc.key], `Should include '${inc.key}'`);\r\n });\r\n });\r\n\r\n it('get extended recording', async () => {\r\n const recording = await mbApi.getRecording(mbid.recording.Formidable, ['isrcs', 'artists', 'releases', 'url-rels']);\r\n assert.strictEqual(recording.id, mbid.recording.Formidable);\r\n assert.strictEqual(recording.title, 'Formidable');\r\n assert.isDefined(recording.isrcs);\r\n assert.isDefined(recording['artist-credit']);\r\n // assert.isDefined(recording.releases);\r\n });\r\n });\r\n\r\n });\r\n\r\n describe('Query', () => {\r\n\r\n it('query: Queen - We Will Rock You', async () => {\r\n const query = 'query=\"We Will Rock You\" AND arid:0383dadf-2a4e-4d10-a46a-e9e041da8eb3';\r\n const result = await mbApi.search<mb.IReleaseGroupList>('release-group', {query});\r\n assert.isAtLeast(result.count, 1);\r\n });\r\n\r\n });\r\n\r\n describe('Search', () => {\r\n\r\n describe('generic search', () => {\r\n\r\n it('find artist: Stromae', async () => {\r\n const result = await mbApi.search('artist', 'Stromae');\r\n assert.isAtLeast(result.count, 1);\r\n });\r\n\r\n });\r\n\r\n describe('searchArtist', () => {\r\n\r\n it('find artist: Stromae', async () => {\r\n const result = await mbApi.searchArtist('Stromae');\r\n assert.isAtLeast(result.count, 1);\r\n assert.isAtLeast(result.artists.length, 1);\r\n assert.strictEqual(result.artists[0].id, mbid.artist.Stromae);\r\n });\r\n\r\n });\r\n\r\n describe('searchReleaseGroup', () => {\r\n\r\n it('find release-group: Racine carrée', async () => {\r\n const result = await mbApi.searchReleaseGroup('Racine carrée');\r\n assert.isAtLeast(result.count, 1);\r\n assert.isAtLeast(result['release-groups'].length, 1);\r\n assert.strictEqual(result['release-groups'][0].id, mbid.releaseGroup.RacineCarree);\r\n });\r\n\r\n it('find release-group: Racine carrée, by artist and group name', async () => {\r\n const result = await mbApi.searchReleaseGroup({release: 'Racine carrée', artist: 'Stromae'});\r\n assert.isAtLeast(result.count, 1);\r\n assert.isAtLeast(result['release-groups'].length, 1);\r\n assert.strictEqual(result['release-groups'][0].id, mbid.releaseGroup.RacineCarree);\r\n });\r\n });\r\n\r\n describe('searchRelease', () => {\r\n\r\n it('find release-group: Racine carrée', async () => {\r\n const result = await mbApi.searchRelease({release: 'Racine carrée'});\r\n assert.isAtLeast(result.count, 2);\r\n assert.isAtLeast(result.releases.length, 2);\r\n assert.includeMembers(result.releases.map(release => release.id), mbid.release.RacineCarree);\r\n });\r\n\r\n it('find release by barcode', async () => {\r\n const result = await mbApi.searchRelease({barcode: 602537479870});\r\n assert.isAtLeast(result.count, 1);\r\n assert.isAtLeast(result.releases.length, 1);\r\n assert.equal(result.releases[0].id, mbid.release.RacineCarree[2]);\r\n });\r\n\r\n });\r\n\r\n describe('searchArea', () => {\r\n\r\n it('find area by name', async () => {\r\n const result = await mbApi.searchArea('Île-de-France');\r\n assert.isAtLeast(result.count, 1);\r\n assert.isAtLeast(result.areas.length, 1);\r\n assert.strictEqual(result.areas[0].id, mbid.area.IleDeFrance);\r\n });\r\n });\r\n\r\n describe('searchUrl', () => {\r\n\r\n const spotifyUrl = 'https://open.spotify.com/album/' + spotify.album.RacineCarree.id;\r\n\r\n it('find url by url', async () => {\r\n const result = await mbApi.searchUrl({url: spotifyUrl});\r\n assert.isAtLeast(result.count, 1);\r\n assert.isAtLeast(result.urls.length, 1);\r\n assert.strictEqual(result.urls[0].resource, spotifyUrl);\r\n });\r\n });\r\n });\r\n\r\n });\r\n\r\n describe('Submit API', () => {\r\n\r\n it('Post ISRC Formidable', async () => {\r\n const isrc_Formidable = 'BET671300161';\r\n const xmlMetadata = new XmlMetadata();\r\n const xmlRecording = xmlMetadata.pushRecording(mbid.recording.Formidable);\r\n xmlRecording.isrcList.pushIsrc(isrc_Formidable);\r\n\r\n await mbTestApi.post('recording', xmlMetadata);\r\n });\r\n\r\n });\r\n\r\n /**\r\n * https://wiki.musicbrainz.org/Development/Release_Editor_Seeding\r\n */\r\n describe.skip('User (bot) post form-data API', () => {\r\n\r\n it('login & logout', async () => {\r\n for (let n = 1; n <= 2; ++n) {\r\n assert.isTrue(await mbTestApi.login(), `Login ${n}`);\r\n assert.isTrue(await mbTestApi.logout(), `Logout ${n}`);\r\n }\r\n });\r\n\r\n describe('Recording', () => {\r\n\r\n it('add link', async () => {\r\n const recording = await mbTestApi.getRecording(mbid.recording.Formidable);\r\n assert.strictEqual(recording.id, mbid.recording.Formidable);\r\n assert.strictEqual(recording.title, 'Formidable');\r\n\r\n await mbTestApi.addUrlToRecording(recording, {\r\n linkTypeId: LinkType.stream_for_free,\r\n text: 'https://open.spotify.com/track/' + spotify.track.Formidable.id\r\n });\r\n });\r\n\r\n it('add Spotify-ID', async () => {\r\n const recording = await mbTestApi.getRecording(mbid.recording.Formidable);\r\n\r\n const editNote = `Unit-test musicbrainz-api (${appUrl}), test augment recording with Spotify URL & ISRC`;\r\n await mbTestApi.addSpotifyIdToRecording(recording, spotify.track.Formidable.id, editNote);\r\n });\r\n\r\n it('add Spotify-ID to recording with ISRC', async () => {\r\n // https://test.musicbrainz.org/recording/a75b85bf-63dd-4fe1-8008-d15541b93bac\r\n const recording_id = 'a75b85bf-63dd-4fe1-8008-d15541b93bac';\r\n\r\n const recording = await mbTestApi.getRecording(recording_id);\r\n const editNote = `Unit-test musicbrainz-api (${appUrl}), test augment recording with Spotify URL & ISRC`;\r\n await mbTestApi.addSpotifyIdToRecording(recording, '3ZDO5YINwfoifRQ3ElshPM', editNote);\r\n });\r\n\r\n });\r\n\r\n describe('ISRC', () => {\r\n\r\n it('add ISRC', async () => {\r\n const recording = await mbTestApi.getRecording(mbid.recording.Formidable, ['isrcs']);\r\n assert.strictEqual(recording.id, mbid.recording.Formidable);\r\n assert.strictEqual(recording.title, 'Formidable');\r\n\r\n await mbTestApi.addIsrc(recording, 'BET671300161');\r\n });\r\n\r\n });\r\n\r\n /**\r\n * https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2#ISRC_submission\r\n */\r\n describe('ISRC submission', () => {\r\n\r\n it('add ISRC', async () => {\r\n const xmlMedata = new XmlMetadata();\r\n const xmlRec = xmlMedata.pushRecording('94fb868b-9233-4f9e-966b-e8036bf7461e');\r\n xmlRec.isrcList.pushIsrc('GB5EM1801762');\r\n await mbTestApi.post('recording', xmlMedata);\r\n });\r\n\r\n });\r\n\r\n });\r\n\r\n});\r\n
5
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
6
- <+>UTF-8
7
- ===================================================================
8
- diff --git a/test/test-musicbrainz-api.ts b/test/test-musicbrainz-api.ts
9
- --- a/test/test-musicbrainz-api.ts (revision 34904480bc8291aefe77a94593cf8a0ef1c85a91)
10
- +++ b/test/test-musicbrainz-api.ts (date 1641463729365)
11
- @@ -4,6 +4,7 @@
12
- import * as mb from '../src/musicbrainz.types';
13
- import * as fs from 'fs';
14
- import * as path from 'path';
15
- +import { IArtist } from '../lib/musicbrainz.types';
16
-
17
- const packageInfo = require('../package.json');
18
-
19
- @@ -298,6 +299,20 @@
20
- assert.isAtLeast(result.releases.length, 1);
21
- assert.equal(result.releases[0].id, mbid.release.RacineCarree[2]);
22
- });
23
- +
24
- + it('find release by barcode', async () => {
25
- + const result = await mbApi.searchRelease({barcode: 602537479870});
26
- + assert.isAtLeast(result.count, 1);
27
- + assert.isAtLeast(result.releases.length, 1);
28
- + assert.equal(result.releases[0].id, mbid.release.RacineCarree[2]);
29
- + });
30
- +
31
- + it('find releases by artist', async () => {
32
- + const result = await mbApi.searchRelease({artist: 'eeb41a1e-4326-4d04-8c47-0f564ceecd68'});
33
- + assert.isAtLeast(result.count, 1);
34
- + assert.isAtLeast(result.releases.length, 1);
35
- + assert.equal(result.releases[0].id, mbid.release.RacineCarree[2]);
36
- + });
37
-
38
- });
39
-
40
- @@ -410,4 +425,18 @@
41
-
42
- });
43
-
44
- + it('try something', async () => {
45
- + const artist_mbid = 'eeb41a1e-4326-4d04-8c47-0f564ceecd68';
46
- + const searchResult: IArtist = await mbApi.getArtist(artist_mbid, [
47
- + 'artist-rels',
48
- + 'releases',
49
- + 'recordings',
50
- + 'url-rels'
51
- + ]);
52
- +
53
- + const result = await mbApi.searchRelease({artist: 'eeb41a1e-4326-4d04-8c47-0f564ceecd68'}, 25);
54
- +
55
- + assert.isNotNull(result);
56
- + });
57
- +
58
- });
@@ -1,4 +0,0 @@
1
- <changelist name="Uncommitted_changes_before_Update_at_6-1-2022_11_38_[Default_Changelist]" date="1641465535745" recycled="true" deleted="true">
2
- <option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_6-1-2022_11_38_[Default_Changelist]/shelved.patch" />
3
- <option name="DESCRIPTION" value="Uncommitted changes before Update at 6-1-2022 11:38 [Default Changelist]" />
4
- </changelist>