Giter VIP home page Giter VIP logo

musicbrainz-api's Introduction

Node.js CI NPM version npm downloads Coverage Status Codacy Badge CodeQL Known Vulnerabilities DeepScan grade Discord

musicbrainz-api

A MusicBrainz-API-client for reading and submitting metadata

Features

  • Access metadata from MusicBrainz
  • Submit metadata
  • Smart and adjustable throttling, like MusicBrainz, it allows a bursts of requests
  • Build in TypeScript definitions

Hint

This package is currently only developed for the use in a node.js environment. We are looking into making this package usable in the browser as well.

Before using this library

MusicBrainz asks that you to identify your application by filling in the 'User-Agent' Header. By passing appName, appVersion, appMail musicbrainz-api takes care of that.

Submitting metadata

If you plan to use this module for submitting metadata, please ensure you comply with the MusicBrainz Code of conduct/Bots.

Example

Example, how to import 'musicbrainz-api:

import {MusicBrainzApi} from 'musicbrainz-api';

const mbApi = new MusicBrainzApi({
  appName: 'my-app',
  appVersion: '0.1.0',
  appContactInfo: '[email protected]'
});

The following configuration settings can be passed

import {MusicBrainzApi} from 'musicbrainz-api';

const config = {
  // MusicBrainz bot account username & password (optional)
  botAccount: { 
    username: 'myUserName_bot',
    password: 'myPassword' 
  },
  
  // API base URL, default: 'https://musicbrainz.org' (optional)
  baseUrl: 'https://musicbrainz.org',

  appName: 'my-app',
  appVersion: '0.1.0',

  // Optional, default: no proxy server
  proxy: {
    host: 'localhost',
    port: 8888
   },

  // Your e-mail address, required for submitting ISRCs
  appMail: string
}

const mbApi = new MusicbrainzApi(config);

Lookup MusicBrainz Entities

MusicBrainz API documentation: XML Web Service/Version 2 Lookups

Generic lookup function

Arguments:

  • entity: 'area' | 'artist' | 'collection' | 'instrument' | 'label' | 'place' | 'release' | 'release-group' | 'recording' | 'series' | 'work' | 'url' | 'event'
  • MBID (MusicBrainz identifier)
  • query
const artist = await mbApi.lookup('artist', 'ab2528d9-719f-4261-8098-21849222a0f2');
Query argument Query value
query.collection Collection MBID

Browse artist

const artists = await mbApi.browse('artist', query);
Query argument Query value
query.area Area MBID
query.collection Collection MBID
query.recording Recording MBID
query.release Release MBID
query.release-group Release-group MBID
query.work Work MBID

Browse collection

const collections = await mbApi.browse('collection', query);
Query argument Query value
query.area Area MBID
query.artist Artist MBID
query.editor Editor MBID
query.event Event MBID
query.label Label MBID
query.place Place MBID
query.recording Recording MBID
query.release Release MBID
query.release-group Release-group MBID
query.work Work MBID

Browse events

const events = await mbApi.browse('event', query);
Query argument Query value
query.area Area MBID
query.artist Artist MBID
query.collection Collection MBID
query.place Place MBID

Browse instruments

const instruments = await mbApi.browse('event', query);
Query argument Query value
query.collection Collection MBID

Browse labels

const labels = await mbApi.browse('label', query);
Query argument Query value
query.area Area MBID
query.collection Collection MBID
query.release Release MBID

Browse places

const places = await mbApi.browse('place', query);
Query argument Query value
query.area Area MBID
query.collection Collection MBID

Browse recordings

const recordings = await mbApi.browse('recording', query);
Query argument Query value
query.artist Area MBID
query.collection Collection MBID
query.release Release MBID
query.work Work MBID

Browse releases

const releases = await mbApi.browse('release', query);
Query argument Query value
query.area Area MBID
query.artist Artist MBID
query.editor Editor MBID
query.event Event MBID
query.label Label MBID
query.place Place MBID
query.recording Recording MBID
query.release Release MBID
query.release-group Release-group MBID
query.work Work MBID

Browse release-groups

const releaseGroups = await mbApi.browse('release-group',query);
Query argument Query value
query.artist Artist MBID
query.collection Collection MBID
query.release Release MBID

Browse series

const series = await mbApi.browse('series');
Query argument Query value
query.area Area MBID
query.artist Artist MBID
query.editor Editor MBID
query.event Event MBID
query.label Label MBID
query.place Place MBID
query.recording Recording MBID
query.release Release MBID
query.release-group Release-group MBID
query.work Work MBID

Browse works

const works = await mbApi.browse('work');
Query argument Query value
query.artist Artist MBID
query.xollection Collection MBID

Browse urls

const urls = await mbApi.browse('url');
Query argument Query value
query.artist Artist MBID
query.xollection Collection MBID

Search (query)

Implements XML Web Service/Version 2/Search.

There are different search fields depending on the entity.

Search function

Searches can be performed using the generic search function: query(entity: mb.EntityType, query: string | IFormData, offset?: number, limit?: number): Promise<entity>

Arguments:

  • Entity type, which can be one of:
  • query {query: string, offset: number, limit: number}
    • query.query: supports the full Lucene Search syntax; you can find a detailed guide at Lucene Search Syntax. For example, you can set conditions while searching for a name with the AND operator.
    • query.offset: optional, return search results starting at a given offset. Used for paging through more than one page of results.
    • 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.

For example, to find any recordings of 'We Will Rock You' by Queen:

const query = 'query="We Will Rock You" AND arid:0383dadf-2a4e-4d10-a46a-e9e041da8eb3';
const result = await mbApi.search('release-group', {query});
Example: search Île-de-France
 mbApi.search('area', 'Île-de-France');
Example: search release by barcode

Search a release with the barcode 602537479870:

 mbApi.search('release', {query: {barcode: 602537479870}});
Example: search by object

Same as previous example, but automatically serialize parameters to search query

 mbApi.search('release', 'barcode: 602537479870');
Example: search artist by artist name

Search artist:

const result = await mbApi.search('artist', {query: 'Stromae'});
Example: search release-group by artist name

Search release-group:

const result = await mbApi.search('release-group', {query: 'Racine carrée'});
Example: search release-group by release-group and an artist

Search a combination of a release-group and an artist.

const result = await mbApi.search('release-group', {artist: 'Racine carrée', releasegroup: 'Stromae'});

Submitting data via XML POST

Submitting data via XML POST may be done using personal MusicBrainz credentials.

Submit ISRC code using XML POST

Using the XML ISRC submission API.

const mbid_Formidable = '16afa384-174e-435e-bfa3-5591accda31c';
const isrc_Formidable = 'BET671300161';

const xmlMetadata = new XmlMetadata();
const xmlRecording = xmlMetadata.pushRecording(mbid_Formidable);
xmlRecording.isrcList.pushIsrc(isrc_Formidable);
await mbApi.post('recording', xmlMetadata);

Submitting data via user form-data

For all of the following function you need to use a dedicated bot account.

Submitting ISRC via post user form-data

Work in progress

Use with caution, and only on a test server, it may clear existing metadata as side effect.
const mbid_Formidable = '16afa384-174e-435e-bfa3-5591accda31c';
const isrc_Formidable = 'BET671300161';

    
const recording = await mbApi.lookup('recording', mbid_Formidable);

// Authentication the http-session against MusicBrainz (as defined in config.baseUrl)
const succeed = await mbApi.login();
assert.isTrue(succeed, 'Login successful');

// To submit the ISRC, the `recording.id` and `recording.title` are required
await mbApi.addIsrc(recording, isrc_Formidable);

Submit recording URL

const recording = await mbApi.lookup('recording', '16afa384-174e-435e-bfa3-5591accda31c');

const succeed = await mbApi.login();
assert.isTrue(succeed, 'Login successful');

await mbApi.addUrlToRecording(recording, {
  linkTypeId: LinkType.stream_for_free,
  text: 'https://open.spotify.com/track/2AMysGXOe0zzZJMtH3Nizb'
});

Actually a Spotify-track-ID can be submitted easier:

const recording = await mbApi.lookup('recording', '16afa384-174e-435e-bfa3-5591accda31c');

const succeed = await mbApi.login();
assert.isTrue(succeed, 'Login successful');
await mbApi.addSpotifyIdToRecording(recording, '2AMysGXOe0zzZJMtH3Nizb');

Cover Art Archive API

Implementation of the Cover Art Archive API.

import {CoverArtArchiveApi} from 'musicbrainz-api';

coverArtArchiveApiClient.getReleaseCovers(releaseMbid).then(releaseCoverInfo => {
    console.log('Release cover info', releaseCoverInfo);
});

coverArtArchiveApiClient.getReleaseCovers(releaseMbid, 'front').then(releaseCoverInfo => {
    console.log('Get best front cover', releaseCoverInfo);
});

coverArtArchiveApiClient.getReleaseCovers(releaseMbid, 'back').then(releaseCoverInfo => {
    console.log('Get best back cover', releaseCoverInfo);
});

Compatibility

The JavaScript in runtime is compliant with ECMAScript 2017 (ES8). Requires Node.js® version 6 or higher.

musicbrainz-api's People

Contributors

acal11 avatar borewit avatar cahamilton avatar davidwhitney avatar dependabot-preview[bot] avatar dependabot[bot] avatar ewanroycroft avatar fossforlife avatar haschikeks avatar hugovk avatar ikapo avatar lgtm-migrator avatar lombardoc4 avatar lufinkey avatar rururux avatar snyk-bot avatar tofi86 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

musicbrainz-api's Issues

Not working with Bun

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

I had to do that because it didn't work with Bun out of the box, because upon trying to run my project, it threw this error:

1 | import * as Debug from 'debug';
2 | 
3 | const debug = Debug('musicbrainz-api:rate-limiter');
                  ^
TypeError: Debug is not a function. (In 'Debug("musicbrainz-api:rate-limiter")', 'Debug' is an instance of Module)
      at /home/m1nt/Wavebreaker/node_modules/musicbrainz-api/lib/rate-limiter.ts:3:14
      at loadCJS2ESM (:1:20)
      at requireESM (:1:20)
      at require (:1:20)
      at /home/m1nt/Wavebreaker/node_modules/musicbrainz-api/lib/musicbrainz-api.js:31:6
      at globalThis (/home/m1nt/Wavebreaker/node_modules/musicbrainz-api/lib/musicbrainz-api.js:541:29)

Here is the diff that solved my problem:

diff --git a/node_modules/musicbrainz-api/lib/rate-limiter.ts b/node_modules/musicbrainz-api/lib/rate-limiter.ts
index 19b7cf7..b9bb987 100644
--- a/node_modules/musicbrainz-api/lib/rate-limiter.ts
+++ b/node_modules/musicbrainz-api/lib/rate-limiter.ts
@@ -1,4 +1,4 @@
-import * as Debug from 'debug';
+import Debug from 'debug';
 
 const debug = Debug('musicbrainz-api:rate-limiter');
 

This issue body was partially generated by patch-package.

README examples not up to date

I was having trouble getting the examples to work in the README, but after digging into the source code I figured out they were using an old version of the library:

For example:

  const artist = await mbApi.lookupEntity('artist', {query: 'ab2528d9-719f-4261-8098-21849222a0f2'});

Should be:

  const artist = await mbApi.lookupEntity('artist', 'ab2528d9-719f-4261-8098-21849222a0f2');

Is botAccount optional?

Hello 👋 , thank you for this library!

In the readme, the example for getting starting is

const mbApi = new MusicBrainzApi({
  appName: 'my-app',
  appVersion: '0.1.0',
  appContactInfo: '[email protected]',
});

however this will not work in Typescript. The IMusicBrainzConfig interface currently requires the botAccount object (even though the actual username/password is not required). For example adding an empty object for the botAccount satisfies Typescript.

const mbApi = new MusicBrainzApi({
  appName: 'my-app',
  appVersion: '0.1.0',
  appContactInfo: '[email protected]',
  // added to satisfy Typescript
  botAccount: {},
});

If the botAccount object is actually required then the readme may need a simple update (otherwise maybe the the botAccount object can be made optional)

`inc` (subqueries) parameters throws a TypeError

@Borewit One more question regarding inc params on search requests. I tried passing an array of strings for what I want included but I end up getting the following Type error:

TypeError: The `searchParams` value 'release-groups,media,label-rels' must be a string, number, boolean or null
    at validateSearchParameters (/home/bshellnu/projects/musicle/backend/node_modules/got/dist/source/core/index.js:67:19)
    at normalizeArguments (/home/bshellnu/projects/musicle/backend/node_modules/got/dist/source/core/index.js:446:21)
    at got (/home/bshellnu/projects/musicle/backend/node_modules/got/dist/source/create.js:112:39)
    at Function.got.<computed> [as get] (/home/bshellnu/projects/musicle/backend/node_modules/got/dist/source/create.js:224:42)
    at MusicBrainzApi.restGet (/home/bshellnu/projects/musicle/backend/node_modules/musicbrainz-api/lib/musicbrainz-api.js:107:44)

Code:

releaseList = await mbApi.searchRelease({
        query: `arid:${artist?.musicBrainzId}`,
        inc: ['release-groups', 'media', 'label-rels'],
        offset,
        limit: 25,
      });

Originally posted by @BradNut in #124 (comment)

Problem with search

https://musicbrainz.org/ws/2/release/?query=release:* AND type:album
https://musicbrainz.org/ws/2/release/?query=release:*%20AND%20type:album
https://musicbrainz.org/ws/2/release/?query=release:"*" AND type:album
https://musicbrainz.org/ws/2/release/?query=release:%22*%22%20AND%20type:album
function makeAndQueryString(keyValuePairs) {
    // return Object.keys(keyValuePairs).map(key => `${key}:"${keyValuePairs[key]}"`).join(' AND ');
    return Object.keys(keyValuePairs).map(key => `${key}:${keyValuePairs[key]}`).join(' AND ');
}

broken types for release groups

query:

mb.browseReleaseGroups({ artist: '1c25cfa7-037e-4d82-a7b9-1df62fb6d9c7' })

returns this object:

export interface IBrowseReleaseGroupsResult {
    'release-groups': IReleaseGroupsQuery[];
    'release-group-count': number;
    'release-group-offset': number;
}

the 'release-groups' property is declared to be of this type:

export interface IReleaseGroupsQuery extends IPagination {
    artist?: string;
    collection?: string;
    release?: string;
}

however, the actual object looks like this - nothing from the typedef matches:

    {
      disambiguation: '',
      id: '00080a9c-11ff-41b0-b325-454bcc16be83',
      'secondary-type-ids': [],
      'secondary-types': [],
      title: 'Śpiewnik domowy',
      'primary-type': 'EP',
      'first-release-date': '2020-04-17',
      'primary-type-id': '6d0c5bf6-7a33-3420-a519-44fc63eedebf'
    },

Cover Art Archive API w/ release-group (album)

Currently, getReleaseCovers uses the 'release' parameter to find a releases's cover.
Alternatively I'm interested in adding an option to select if the cover is from a

  1. Release
  2. Release Group

Ultimately this will be adding support for album images!

This is the current function

public async getReleaseCovers(releaseId: string, coverType?: 'front' | 'back'): Promise<ICoverInfo> {
    const path = ['release', releaseId];
    ...
  }

I'd suggest modifying the functions like so:

public async getReleaseCovers(releaseId: string, releaseType: 'release' | 'release-group' = 'release', coverType?: 'front' | 'back'): Promise<ICoverInfo> {
      const path = [releaseType, releaseId];
    ...
  }

Broken on TypeScript

Hello, I am trying to use this package with TypeScript, but starting my application fails. I posted the log on Pastebin, because it's too long to include here: https://pastebin.com/Dn7VT1gG

To reproduce this, simply trying to run any Node project using this TypeScript with this package should be enough.

Not sure i I understand how to run a query

the sample code:
const query = 'query="We Will Rock You" AND arid:0383dadf-2a4e-4d10-a46a-e9e041da8eb3';
const result = await mbApi.query<mb.IReleaseGroupList>('release-group', {query});

in nodejs I get an error warning that it can only be used in typescript.

and just using 'query' results in it is not a function.
All my other attempts have have failed.

Any suggestions?

And anyone tips on how to deal with the elements with a hyphen in the name?
Regards,

gerrit

Promise stuck on pending

Using the documentation provided to create an app in node js. Setting up the api the terminal keeps returning promise {pending}.

I'm unsure how to resolve this. Since I'm not making calls to a URL I can't figure out how to get info and log it to the console.

I have this:
const mbg = new MusicBrainzApi({ appName: 'appname', appVersion: '1.2', appContactInfo: 'site.com' })

which logs to the console the promise pending issue. I can't complete and db searches until obviously I can fulfill the promise. How do I do this?

(I am fairly new to node js, so apologies if this is a dumb q).

Problem installing to npm project

Hello!
Please bear with me as I'm fairly new to npm.
I've tried incorporating this project into my npm project through "npm install musicbrainz-api" and followed the readme guide. However, I ran into all kinds of errors - they all seem to relate to Webpack 5.

Some of the errors I'm getting:
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

WARNING in ./node_modules/musicbrainz-api/lib/xml/xml-isrc.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from ...

Uncaught ReferenceError: process is not defined
at ./node_modules/@szmarczak/http-timer/dist/source/index.js

So, at this point, I might resort to uninstalling it and referencing it for my own hand-crafted code - it would be easier that way!
Thanks

Need to keep the HTTP-connection alive in order to keep the authentication session alive

Description:

It looks like posting though the user/bot form API fails because the HTTP connection is not kept alive.
The prescribed way to keep it alive for Axios, the underlying HTTP-client does not seem to work: axios/axios#1981.

Workaround:

Use Fiddler as proxy in-between:

const Fiddler = {
  host: '127.0.0.1',
  port: 8888
};

const config = {
  proxy: Fiddler,
  //...
}

Fiddler will keep the connection to MusicBrainz alive.

IArtist interface missing IReleaseGroup array prop

This may be intentional as I'm missing a key functionality to this API, potentially. But the following example below gets rejected by TypeScript.

I'm trying to make as few calls as possible so I feel this is a prettier and simpler way to get the album information of an artist.

Example

var {artists}:any =  await mbApi.searchArtist("Oasis") //Get artist
artists.sort( function(a:any, b:any){return a.score + b.score}) //Sort by score
const result = await mbApi.getArtist(artists[0].id, ['release-groups']) //Get albums
console.log(result)

Proposed Fix

export interface IArtist {
...
"release-groups"?: IReleaseGroup[];
}

0.14.0 : TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"

Hello, since I updated from 0.11.0 to 0.14.0, I get this error fired when running my tests :

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /home/gordie/Local Sites/newspiff/spiff-clients/src/services/musicbrainz/tests.ts
    at new NodeError (node:internal/errors:399:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:79:11)
    at defaultGetFormat (node:internal/modules/esm/get_format:121:38)
    at defaultLoad (node:internal/modules/esm/load:81:20)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at ESMLoader.load (node:internal/modules/esm/loader:605:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
    at new ModuleJob (node:internal/modules/esm/module_job:64:26)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:480:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34)

I cleared the node cache - still get this.
I reverted to 0.11.0 : no more bug.

Hard to debug but it seems it is related to your update.
Any clue of what it might be ?

Thanks !

Query Include options missing

Hey,

thank you for this library. I started fiddling around a bit and found that there might be some includes for the subquerys missing.
For example genres and tags are missing in the Include type.

Maybe it would make sense to create an Include type for each lookup?

If you want I can start on a pull request to check which Includes are missing.

BUG Property 'recordings' does not exist on type 'ISearchResult'.

const rawPageTracks = await api.search('recording',{query:MYQUERY});
console.log(rawPageTracks.recordings);

gives me
Property 'recordings' does not exist on type 'ISearchResult'.

casting it to any works.

const rawPageTracks = await api.search('recording',{query:MYQUERY}) as any;

Missing Types for "Genre" & "Tag"

Hi 👋

I'm back with more types :)

I also noticed that there are currently no types for things like "Genre" or "Tag" and their respective connection to lookup.
Making this generic might be a bit harder, because for the standard lookups it depends on the inc parameters.

One easy approach where to just add the missing interfaces/types and tell the user to just define the needed types them selfs.

// musicbrainz.types.ts
interface ITag {
  id: string;
  name: string;
}

interface IGenre {
  id: string;
  name: string;
  count: number;
  disambiguation: string;
}
// index.ts
import { IArtist, ITag } from "musicbrainzapi";

type ArtitstWithTags = IArtist & { tags?: ITag[] }

type ArtistWithGenreTags = IArtist & { tags?: ITag[], genres?: IGenre[] }

In a second iteration someone could look into doing it in a more generic way and provide the correct type from the lookup method itself.

Cover all entities in lookup functions

If possible, add lookup functions for the following entities can be looked up:
Lookup functions

  • /ws/2/area
    • Implementation
    • Unit tests
    • Documentation
  • /ws/2/artist
    • Implementation
    • Unit tests
    • Documentation
  • /ws/2/collection
    • Implementation
    • Unit tests
    • Documentation
  • /ws/2/event
    • Implementation
    • Unit tests
    • Documentation
  • /ws/2/instrument
    • Implementation
    • Unit tests
    • Documentation
  • /ws/2/label
    • Implementation
    • Unit tests
    • Documentation
  • /ws/2/place
    • Implementation
    • Unit tests
    • Documentation
  • /ws/2/recording
    • Implementation
    • Unit tests
    • Documentation
  • /ws/2/release
    • Implementation
    • Unit tests
    • Documentation
  • /ws/2/release-group
    • Implementation
    • Unit tests
    • Documentation
  • /ws/2/series
    • Implementation
    • Unit tests
    • Documentation
  • /ws/2/work
    • Implementation
    • Unit tests
    • Documentation
  • /ws/2/url
    • Implementation
    • Unit tests
    • Documentation

Example API call:
http://musicbrainz.org/ws/2/area/8a754a16-0027-3a29-b6d7-2b40ea0481ed

Ref:
https://wiki.musicbrainz.org/Development/XML_Web_Service/Version_2#Subqueries

Property 'query' does not exist on type 'MusicBrainzApi'.

Hi, I tested the new version 0.14.0 (npm i musicbrainz-api) it seems broken.
I also cleared my npm cache, but no luck.


Property 'query' does not exist on type 'MusicBrainzApi'.

140     const response = await api.query('recording',apiQuery);

ERR_REQUIRE_ESM

Hi,
first of all, thank you for this lib :)
I'm trying to add it to my (Typescript-powered) project but get this error when trying to use it:

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/s/my-project/node_modules/musicbrainz-api/lib/index.js from /Users/s/my-project/src/modules/MusicBrainzModule.ts not supported.
Instead change the require of index.js in /Users/s/my-project/src/modules/MusicBrainzModule.ts to a dynamic import() which is available in all CommonJS modules.
    at require.extensions.<computed> [as .js] (/Users/s/my-project/node_modules/ts-node/dist/index.js:851:20)
    at Object.<anonymous> (/Users/s/my-project/src/modules/MusicBrainzModule.ts:37:24)
    at m._compile (/Users/s/my-project/node_modules/ts-node/dist/index.js:857:29)
    at require.extensions.<computed> [as .ts] (/Users/s/my-project/node_modules/ts-node/dist/index.js:859:16)
    at Object.<anonymous> (/Users/s/my-project/src/modules/index.ts:20:29)
    at m._compile (/Users/s/my-project/node_modules/ts-node/dist/index.js:857:29)
    at require.extensions.<computed> [as .ts] (/Users/s/my-project/node_modules/ts-node/dist/index.js:859:16)
    at Object.<anonymous> (/Users/s/my-project/src/KrateMate.ts:13:19)
    at m._compile (/Users/s/my-project/node_modules/ts-node/dist/index.js:857:29)
    at require.extensions.<computed> [as .ts] (/Users/s/my-project/node_modules/ts-node/dist/index.js:859:16)
    at Object.<anonymous> (/Users/s/my-project/src/index.ts:15:21)
    at m._compile (/Users/s/my-project/node_modules/ts-node/dist/index.js:857:29)
    at require.extensions.<computed> [as .ts] (/Users/s/my-project/node_modules/ts-node/dist/index.js:859:16) {
  code: 'ERR_REQUIRE_ESM'
}

Any ideas? Thanks :)

IReleaseGroup missing fields

This is the response from lookupReleaseGroup:

{
  'primary-type': 'Single',
  disambiguation: '',
  id: 'bdaeec2d-94f1-46b5-91f3-340ec6939c66',
  title: 'Under Pressure',
  'secondary-types': [],
  'first-release-date': '1981-10',
  'primary-type-id': 'd6038452-8ee0-3f68-affc-2de9a1ede0b9',
  'secondary-type-ids': [],
  'artist-credit': [
    { name: 'Queen', artist: [Object], joinphrase: ' & ' },
    { name: 'David Bowie', joinphrase: '', artist: [Object] }
  ]
}

This is the interface definition:

export interface IEntity {
    id: string;
}

export interface IReleaseGroup extends IEntity {
    count: number;
    title: string;
    'primary-type': string;
    'sort-name': string;
    'artist-credit': {
        artist: IArtist;
        name: string;
        joinphrase: string;
    }[];
    releases?: IRelease[];
}

As you can see, the interface is missing a few things:

  • disambiguation
  • secondary-types
  • first-release-date
  • primary-type-id
  • secondary-type-ids

I'm getting results that are different from the MB website

First, thank you for writting this module!!

So I'm trying to recreate this query:
https://musicbrainz.org/search?query=Beatles%2CThe+Lucy+In+The+Sky+With+Diamonds&type=recording

with this code:

  const res = await mbApi.search('recording', 'Beatles,The Lucy In The Sky With Diamonds ')

The url results includes The Beatles in the first several results (which is what I'm looking for).
The mbApi search doesnt have any Beatles until the 24th result.

Am I doing this correctly?

Improved output typing for `lookup` with `inc` parameter

Okay, so after experimenting a little bit we would need to do something like this

export interface ReleaseIncludes {
  labels: ILabel;
  recordings: IRecording;
}

and use it in the lookup functions like this:

public lookupRelease<T extends (keyof mb.RInc)[]>(releaseId: string, inc: T) {
  return this.lookupEntity<mb.IRelease & { [K in T[number]]: mb.RInc[K] }, keyof mb.RInc>('release', releaseId, inc);
}

const r = await this.lookupRelease("", ["labels"]);
const title = r.title;
const labels = r.labels.name;
// This throws an error
const recordings = r.recordings;

Originally posted by @Haschikeks in #504 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.