Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
musicbrainz-api
Advanced tools
A MusicBrainz-API-client for reading and submitting metadata
MusicBrainz asks that you identifying your application by filling in the 'User-Agent' Header.
By passing appName
, appVersion
, appMail
musicbrainz-api takes care of that.
If you plan to use this module for submitting metadata, please ensure you comply with the MusicBrainz Code of conduct/Bots.
Import the module JavaScript example, how to import 'musicbrainz-api:
const MusicbrainzApi = require('musicbrainz-api');
const mbApi = new MusicbrainzApi({
appName: 'my-app',
appVersion: '0.1.0',
appMail: 'user@mail.org'
});
In TypeScript you it would look like this:
import {MusicBrainzApi} from '../src/musicbrainz-api';
const mbApi = new MusicbrainzApi({
appName: 'my-app',
appVersion: '0.1.0',
appMail: 'user@mail.org'
});
The following configuration settings can be passed
import {MusicBrainzApi} from '../src/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);
MusicBrainz API documentation: XML Web Service/Version 2 Lookups
Arguments:
'artist'
| 'label'
| 'recording'
| 'release'
| 'release-group'
| 'work'
| 'area'
| 'url'
const artist = await mbApi.getEntity('artist', 'ab2528d9-719f-4261-8098-21849222a0f2');
const area = await mbApi.getArea('ab2528d9-719f-4261-8098-21849222a0f2');
Lookup an artist
and include their releases
, release-groups
and aliases
const artist = await mbApi.getArtist('ab2528d9-719f-4261-8098-21849222a0f2');
The second argument can be used to pass subqueries, which will return more (nested) information:
const artist = await mbApi.getArtist('ab2528d9-719f-4261-8098-21849222a0f2', ['releases', 'recordings', 'url-rels']);
The second argument can be used to pass subqueries:
const artist = await mbApi.getRecording('16afa384-174e-435e-bfa3-5591accda31c', ['artists', 'url-rels']);
const release = await mbApi.getRelease('976e0677-a480-4a5e-a177-6a86c1900bbf', ['artists', 'url-rels']);
const releaseGroup = await mbApi.getReleaseGroup('19099ea5-3600-4154-b482-2ec68815883e');
const work = await mbApi.getWork('b2aa02f4-6c95-43be-a426-aedb9f9a3805');
Implements XML Web Service/Version 2/Search.
There are different search fields depending on the entity.
Searches can be performed using the generic search function: query(entity: mb.EntityType, query: string | IFormData, offset?: number, limit?: number)
:
mbApi.search('area', 'Île-de-France');
Search a release with the barcode 602537479870:
mbApi.search('release', {barcode: 602537479870});
Same as previous example, but automatically serialize parameters to search query
mbApi.search('release', 'barcode: 602537479870');
The following entity specific search functions are available:
searchArtist(query: string | IFormData, offset?: number, limit?: number): Promise<mb.IArtistList>
searchReleaseGroup(query: string | IFormData, offset?: number, limit?: number): Promise<mb.IReleaseGroupList>`
Arguments:
artist
: search fieldslabel
: search fieldsrecording
: search fieldsrelease
: search fieldsrelease-group
: search fieldswork
: search fieldsarea
: search fieldsurl
: search fieldsquery {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.query<mb.IReleaseGroupList>('release-group', {query});
Search artist:
const result = await mbApi.searchArtist('Stromae');
Search release-group:
const result = await mbApi.searchReleaseGroup('Racine carrée');
Search a combination of a release-group and an artist.
const result = await mbApi.searchReleaseGroupByTitleAndArtist('Racine carrée', 'Stromae');
Submitting data via XML POST may be done using personal MusicBrainz credentials.
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);
For all of the following function you need to use a dedicated bot account.
const mbid_Formidable = '16afa384-174e-435e-bfa3-5591accda31c';
const isrc_Formidable = 'BET671300161';
const recording = await mbApi.getRecording(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);
const recording = await mbApi.getRecording('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.getRecording('16afa384-174e-435e-bfa3-5591accda31c');
const succeed = await mbApi.login();
assert.isTrue(succeed, 'Login successful');
await mbApi.addSpotifyIdToRecording(recording, '2AMysGXOe0zzZJMtH3Nizb');
FAQs
MusicBrainz API client for reading and submitting metadata
The npm package musicbrainz-api receives a total of 287 weekly downloads. As such, musicbrainz-api popularity was classified as not popular.
We found that musicbrainz-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.