Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

musicbrainz-api

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

musicbrainz-api - npm Package Compare versions

Comparing version 0.2.1 to 0.3.3

20

lib/musicbrainz-api.d.ts

@@ -8,3 +8,3 @@ export { XmlMetadata } from './xml/xml-metadata';

export * from './musicbrainz.types';
declare type Includes = 'artists' | 'releases' | 'recordings' | 'artists' | 'artist-credits' | 'isrcs' | 'url-rels' | 'release-groups';
export declare type Includes = 'artists' | 'releases' | 'recordings' | 'artists' | 'artist-credits' | 'isrcs' | 'url-rels' | 'release-groups';
export interface IFormData {

@@ -18,3 +18,3 @@ [key: string]: string | number;

};
baseUrl: string;
baseUrl?: string;
appName?: string;

@@ -33,3 +33,3 @@ appVersion?: string;

private static escapeText;
private config;
readonly config: IMusicBrainzConfig;
private request;

@@ -124,6 +124,8 @@ private rateLimiter;

* Search an entity using a search query
* @param query e.g.: '" artist: Madonna, track: Like a virgin"' or object with search terms: {artist: Madonna}
* @param entity e.g. 'recording'
* @param query e.g.: '" artist: Madonna, track: Like a virgin"'
* @param offset
* @param limit
*/
query<T>(entity: mb.EntityType, query: mb.ISearchQuery): Promise<T>;
search<T extends mb.ISearchResult>(entity: mb.EntityType, query: string | IFormData, offset?: number, limit?: number): Promise<T>;
/**

@@ -139,6 +141,8 @@ * Add Spotify-ID to MusicBrainz recording.

}, spotifyId: string): Promise<void>;
searchArtist(name: string, offset?: number, limit?: number): Promise<mb.IArtistList>;
searchReleaseGroup(name: string, offset?: number, limit?: number): Promise<mb.IReleaseGroupList>;
searchReleaseGroupByTitleAndArtist(title: string, artist: string, offset?: number, limit?: number): Promise<mb.IReleaseGroupList>;
searchArtist(query: string | IFormData, offset?: number, limit?: number): Promise<mb.IArtistList>;
searchRelease(query: string | IFormData, offset?: number, limit?: number): Promise<mb.IReleaseList>;
searchReleaseGroup(query: string | IFormData, offset?: number, limit?: number): Promise<mb.IReleaseGroupList>;
searchArea(query: string | IFormData, offset?: number, limit?: number): Promise<mb.IAreaList>;
private getCookies;
}
export declare function makeAndQueryString(keyValuePairs: IFormData): string;

33

lib/musicbrainz-api.js

@@ -188,2 +188,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
yield this.rateLimiter.limit();
const clientId = 'WhatMusic-0.0.4';

@@ -262,2 +263,3 @@ const path = `/ws/2/${entity}/`;

return __awaiter(this, void 0, void 0, function* () {
yield this.rateLimiter.limit();
let response;

@@ -313,7 +315,12 @@ try {

* Search an entity using a search query
* @param query e.g.: '" artist: Madonna, track: Like a virgin"' or object with search terms: {artist: Madonna}
* @param entity e.g. 'recording'
* @param query e.g.: '" artist: Madonna, track: Like a virgin"'
* @param offset
* @param limit
*/
query(entity, query) {
return this.restGet('/' + entity + '/', query);
search(entity, query, offset, limit) {
if (typeof query === 'object') {
query = makeAndQueryString(query);
}
return this.restGet('/' + entity + '/', { query, offset, limit });
}

@@ -336,12 +343,14 @@ // -----------------------------------------------------------------------------------------------------------------

}
searchArtist(name, offset, limit) {
return this.query('artist', { query: name, offset, limit });
searchArtist(query, offset, limit) {
return this.search('artist', query, offset, limit);
}
searchReleaseGroup(name, offset, limit) {
return this.query('release-group', { query: `"${name}"`, offset, limit });
searchRelease(query, offset, limit) {
return this.search('release', query, offset, limit);
}
searchReleaseGroupByTitleAndArtist(title, artist, offset, limit) {
const query = '"' + MusicBrainzApi.escapeText(title) + '" AND artist:"' + MusicBrainzApi.escapeText(artist) + '"';
return this.query('release-group', { query, offset, limit });
searchReleaseGroup(query, offset, limit) {
return this.search('release-group', query, offset, limit);
}
searchArea(query, offset, limit) {
return this.search('area', query, offset, limit);
}
getCookies(url) {

@@ -352,1 +361,5 @@ return this.cookieJar.getCookies(url);

exports.MusicBrainzApi = MusicBrainzApi;
function makeAndQueryString(keyValuePairs) {
return Object.keys(keyValuePairs).map(key => `${key}:"${keyValuePairs[key]}"`).join(' AND ');
}
exports.makeAndQueryString = makeAndQueryString;

@@ -138,2 +138,6 @@ import DateTimeFormat = Intl.DateTimeFormat;

}
export interface IReleaseMatch extends IRelease, IMatch {
}
export interface IAreaMatch extends IArea, IMatch {
}
export interface ISearchResult {

@@ -147,2 +151,8 @@ created: DateTimeFormat;

}
export interface IAreaList extends ISearchResult {
areas: IAreaMatch[];
}
export interface IReleaseList extends ISearchResult {
releases: IReleaseMatch[];
}
export interface IReleaseGroupList extends ISearchResult {

@@ -149,0 +159,0 @@ 'release-groups': IReleaseGroupMatch[];

{
"name": "musicbrainz-api",
"version": "0.2.1",
"version": "0.3.3",
"description": "MusicBrainz API client for reading and submitting metadata",

@@ -5,0 +5,0 @@ "main": "lib/musicbrainz-api",

@@ -145,4 +145,35 @@ [![Build Status](https://travis-ci.org/Borewit/musicbrainz-api.svg?branch=master)](https://travis-ci.org/Borewit/musicbrainz-api)

Searches can be performed on the function: `query(entityType: string, query: ISearchQuery)`:
### Generic search function
Searches can be performed using the generic search function: `query(entity: mb.EntityType, query: string | IFormData, offset?: number, limit?: number)`:
##### Example: search Île-de-France
```JavaScript
mbApi.search('area', 'Île-de-France');
````
##### Example: search release by barcode
Search a release with the barcode 602537479870:
```JavaScript
mbApi.search('release', {barcode: 602537479870});
````
##### Example: search by object
Same as previous example, but automatically serialize parameters to search query
```JavaScript
mbApi.search('release', 'barcode: 602537479870');
````
### Entity specific search functions:
The following entity specific search functions are available:
```TypeScript
searchArtist(query: string | IFormData, offset?: number, limit?: number): Promise<mb.IArtistList>
searchReleaseGroup(query: string | IFormData, offset?: number, limit?: number): Promise<mb.IReleaseGroupList>`
```
Arguments:

@@ -149,0 +180,0 @@ * Entity type, which can be one of:

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc