mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
[musicmatch] removed additional tslint rules, updated typings and tests
This commit is contained in:
Vendored
+46
-48
@@ -1,84 +1,82 @@
|
||||
// Type definitions for musicmatch 0.3.2
|
||||
// Type definitions for musicmatch 0.3
|
||||
// Project: https://github.com/c0b41/musixmatch, https://www.npmjs.com/package/musicmatch
|
||||
// Definitions by: Aleksei Klimenko <https://github.com/DadUndead>
|
||||
// Definitions: https://github.com/DefinitelyTyped/
|
||||
|
||||
declare module 'musicmatch';
|
||||
export type TFormat = 'json' | 'xml';
|
||||
export type TSort = 'asc' | 'desc';
|
||||
export type TBoolean = 0 | 1;
|
||||
|
||||
type TFormat = 'json' | 'xml';
|
||||
type TSort = 'asc' | 'desc';
|
||||
type TBoolean = 0 | 1;
|
||||
|
||||
export interface IPageable {
|
||||
export interface Pageable {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
}
|
||||
|
||||
export interface IAlbumParams {
|
||||
export interface AlbumParams {
|
||||
album_id: number;
|
||||
}
|
||||
|
||||
export interface IAlbumTracksParams {
|
||||
export interface AlbumTracksParams {
|
||||
album_id?: number;
|
||||
album_mbid?: number;
|
||||
format?: TFormat;
|
||||
}
|
||||
|
||||
export interface IArtistParams {
|
||||
export interface ArtistParams {
|
||||
artist_id?: number;
|
||||
artist_mbid?: number;
|
||||
}
|
||||
|
||||
export interface IArtistRelatedParams extends IArtistParams, IPageable {
|
||||
export interface ArtistRelatedParams extends ArtistParams, Pageable {
|
||||
}
|
||||
|
||||
export interface IArtistAlbumsParams extends IArtistParams, IPageable {
|
||||
export interface ArtistAlbumsParams extends ArtistParams, Pageable {
|
||||
g_album_name?: TBoolean;
|
||||
s_release_date?: TSort;
|
||||
}
|
||||
|
||||
export interface IArtistSearchParams extends IPageable {
|
||||
export interface ArtistSearchParams extends Pageable {
|
||||
q_artist?: string;
|
||||
f_artist_id?: number;
|
||||
f_artist_mbid?: number;
|
||||
}
|
||||
|
||||
export interface IMatcherLyricsParams {
|
||||
export interface MatcherLyricsParams {
|
||||
q_track?: string;
|
||||
q_artist?: string;
|
||||
}
|
||||
|
||||
export interface IMatcherSubtitleParams extends IMatcherLyricsParams {
|
||||
export interface MatcherSubtitleParams extends MatcherLyricsParams {
|
||||
f_subtitle_length?: number;
|
||||
f_subtitle_length_max_deviation?: number;
|
||||
}
|
||||
|
||||
export interface IMatcherTrackParams extends IMatcherLyricsParams {
|
||||
export interface MatcherTrackParams extends MatcherLyricsParams {
|
||||
f_has_lyrics?: TBoolean;
|
||||
f_has_subtitle?: TBoolean;
|
||||
}
|
||||
|
||||
export interface ITrackLyricsFeedbackParams {
|
||||
export interface TrackLyricsFeedbackParams {
|
||||
lyrics_id?: number;
|
||||
track_id?: number;
|
||||
feedback?: 'wrong_lyrics' | 'wrong_attribution' | 'bad_characters' | 'lines_too_long' | 'wrong_verses' | 'wrong_formatting';
|
||||
}
|
||||
|
||||
export interface ITrackLyricsAddParams {
|
||||
export interface TrackLyricsAddParams {
|
||||
lyrics_id?: number;
|
||||
lyrics_body?: string;
|
||||
}
|
||||
|
||||
export interface ITrackSnippetParams {
|
||||
export interface TrackSnippetParams {
|
||||
track_id: number;
|
||||
}
|
||||
|
||||
export interface ITrackLyricsParams {
|
||||
export interface TrackLyricsParams {
|
||||
track_id?: number;
|
||||
track_mbid?: number;
|
||||
}
|
||||
|
||||
export interface ITrackSubtitleParams {
|
||||
export interface TrackSubtitleParams {
|
||||
track_id?: number;
|
||||
track_mbid?: number;
|
||||
subtitle_format?: 'lrc' | 'dfxp' | 'stledu';
|
||||
@@ -86,12 +84,12 @@ export interface ITrackSubtitleParams {
|
||||
f_subtitle_length_max_deviation?: number;
|
||||
}
|
||||
|
||||
export interface ITrackParams {
|
||||
export interface TrackParams {
|
||||
track_id?: number;
|
||||
track_mbid?: number;
|
||||
}
|
||||
|
||||
export interface ITrackSearchParams extends IPageable {
|
||||
export interface TrackSearchParams extends Pageable {
|
||||
q?: string;
|
||||
q_lyrics?: string;
|
||||
f_has_lyrics?: TBoolean;
|
||||
@@ -104,10 +102,10 @@ export interface ITrackSearchParams extends IPageable {
|
||||
quorum_factor?: number;
|
||||
}
|
||||
|
||||
export interface ITrackSearchResult {
|
||||
export interface TrackSearchResult {
|
||||
message: {
|
||||
body: {
|
||||
track_list: ITrackResult[];
|
||||
track_list: TrackResult[];
|
||||
},
|
||||
header: {
|
||||
available: number;
|
||||
@@ -117,7 +115,7 @@ export interface ITrackSearchResult {
|
||||
};
|
||||
}
|
||||
|
||||
export interface IMusicGenre {
|
||||
export interface MusicGenre {
|
||||
music_genre_id: number;
|
||||
music_genre_parent_id: number;
|
||||
music_genre_name: string;
|
||||
@@ -126,10 +124,10 @@ export interface IMusicGenre {
|
||||
}
|
||||
|
||||
export interface PrimaryGenres {
|
||||
music_genre_list: Array<{ music_genre: IMusicGenre }>;
|
||||
music_genre_list: Array<{ music_genre: MusicGenre }>;
|
||||
}
|
||||
|
||||
export interface ITrackResult {
|
||||
export interface TrackResult {
|
||||
track: {
|
||||
track_id: number;
|
||||
track_name: string;
|
||||
@@ -154,51 +152,51 @@ export interface ITrackResult {
|
||||
};
|
||||
}
|
||||
|
||||
export interface IChartTracksParams extends IPageable {
|
||||
export interface ChartTracksParams extends Pageable {
|
||||
country?: string;
|
||||
f_has_lyrics?: TBoolean;
|
||||
}
|
||||
|
||||
export interface IChartArtistsParams extends IPageable {
|
||||
export interface ChartArtistsParams extends Pageable {
|
||||
country?: string;
|
||||
}
|
||||
|
||||
export default class Musicmatch {
|
||||
constructor(obj?: { apikey?: string, format?: string });
|
||||
|
||||
album(params: IAlbumParams): Promise<any>;
|
||||
album(params: AlbumParams): Promise<any>;
|
||||
|
||||
albumTracks(params: IAlbumTracksParams): Promise<any>;
|
||||
albumTracks(params: AlbumTracksParams): Promise<any>;
|
||||
|
||||
artist(params: IArtistParams): Promise<any>;
|
||||
artist(params: ArtistParams): Promise<any>;
|
||||
|
||||
artistAlbums(params: IArtistAlbumsParams): Promise<any>;
|
||||
artistAlbums(params: ArtistAlbumsParams): Promise<any>;
|
||||
|
||||
artistRelated(params: IArtistRelatedParams): Promise<any>;
|
||||
artistRelated(params: ArtistRelatedParams): Promise<any>;
|
||||
|
||||
artistSearch(params: IArtistSearchParams): Promise<any>;
|
||||
artistSearch(params: ArtistSearchParams): Promise<any>;
|
||||
|
||||
chartArtists(params: IChartArtistsParams): Promise<any>;
|
||||
chartArtists(params: ChartArtistsParams): Promise<any>;
|
||||
|
||||
chartTracks(params: IChartTracksParams): Promise<any>;
|
||||
chartTracks(params: ChartTracksParams): Promise<any>;
|
||||
|
||||
matcherLyrics(params: IMatcherLyricsParams): Promise<any>;
|
||||
matcherLyrics(params: MatcherLyricsParams): Promise<any>;
|
||||
|
||||
matcherSubtitle(params: IMatcherSubtitleParams): Promise<any>;
|
||||
matcherSubtitle(params: MatcherSubtitleParams): Promise<any>;
|
||||
|
||||
matcherTrack(params: IMatcherTrackParams): Promise<any>;
|
||||
matcherTrack(params: MatcherTrackParams): Promise<any>;
|
||||
|
||||
track(params: ITrackParams): Promise<any>;
|
||||
track(params: TrackParams): Promise<any>;
|
||||
|
||||
trackLyrics(params: ITrackLyricsParams): Promise<any>;
|
||||
trackLyrics(params: TrackLyricsParams): Promise<any>;
|
||||
|
||||
trackLyricsAdd(params: ITrackLyricsAddParams): Promise<any>;
|
||||
trackLyricsAdd(params: TrackLyricsAddParams): Promise<any>;
|
||||
|
||||
trackLyricsFeedback(params: ITrackLyricsFeedbackParams): Promise<any>;
|
||||
trackLyricsFeedback(params: TrackLyricsFeedbackParams): Promise<any>;
|
||||
|
||||
trackSearch(params: ITrackSearchParams): Promise<ITrackSearchResult>;
|
||||
trackSearch(params: TrackSearchParams): Promise<TrackSearchResult>;
|
||||
|
||||
trackSnippet(params: ITrackSnippetParams): Promise<any>;
|
||||
trackSnippet(params: TrackSnippetParams): Promise<any>;
|
||||
|
||||
trackSubtitle(params: ITrackSubtitleParams): Promise<any>;
|
||||
trackSubtitle(params: TrackSubtitleParams): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,35 @@
|
||||
// Type definitions for musicmatch 0.3.2
|
||||
// Project: https://github.com/c0b41/musixmatch, https://www.npmjs.com/package/musicmatch
|
||||
// Definitions by: Aleksei Klimenko <https://github.com/DadUndead>
|
||||
// Definitions: https://github.com/DefinitelyTyped/
|
||||
|
||||
import Musicmatch, { ITrackSearchParams, ITrackSearchResult } from 'musicmatch';
|
||||
import Musicmatch, {
|
||||
AlbumParams,
|
||||
AlbumTracksParams,
|
||||
ArtistAlbumsParams,
|
||||
ArtistParams,
|
||||
ArtistRelatedParams,
|
||||
ArtistSearchParams,
|
||||
ChartArtistsParams,
|
||||
MatcherLyricsParams,
|
||||
MatcherSubtitleParams,
|
||||
MatcherTrackParams,
|
||||
TrackLyricsAddParams,
|
||||
TrackLyricsFeedbackParams,
|
||||
TrackLyricsParams,
|
||||
TrackParams,
|
||||
TrackSearchParams,
|
||||
TrackSearchResult,
|
||||
TrackSnippetParams,
|
||||
TrackSubtitleParams
|
||||
} from 'musicmatch';
|
||||
|
||||
const musicmatch = new Musicmatch({ apikey: 'api_key', format: '' });
|
||||
|
||||
const trackSearchParams: ITrackSearchParams = {
|
||||
const COUNTRY = 'USA';
|
||||
const Q_ARTIST = 'artist name';
|
||||
const Q_TRACK = 'track title';
|
||||
|
||||
const trackSearchParams: TrackSearchParams = {
|
||||
f_music_genre_id: 18,
|
||||
page_size: 100,
|
||||
page: 1,
|
||||
@@ -15,46 +37,144 @@ const trackSearchParams: ITrackSearchParams = {
|
||||
f_lyrics_language: 'en',
|
||||
};
|
||||
|
||||
musicmatch.trackSearch(trackSearchParams);
|
||||
const albumParams: AlbumParams = {
|
||||
album_id: 1,
|
||||
};
|
||||
|
||||
const albumTrackParams: AlbumTracksParams = {
|
||||
album_id: 1,
|
||||
album_mbid: 1,
|
||||
format: 'json',
|
||||
};
|
||||
|
||||
const artisParams: ArtistParams = {
|
||||
artist_id: 1,
|
||||
artist_mbid: 1,
|
||||
};
|
||||
|
||||
const artistAlbumsParams: ArtistAlbumsParams = {
|
||||
artist_mbid: 1,
|
||||
artist_id: 1,
|
||||
g_album_name: 1,
|
||||
page: 1,
|
||||
page_size: 10,
|
||||
s_release_date: 'desc',
|
||||
};
|
||||
|
||||
const artistRelatedParams: ArtistRelatedParams = {
|
||||
page_size: 10,
|
||||
page: 1,
|
||||
artist_id: 1,
|
||||
artist_mbid: 1,
|
||||
};
|
||||
|
||||
const artistSearchParams: ArtistSearchParams = {
|
||||
page: 1,
|
||||
page_size: 10,
|
||||
f_artist_id: 1,
|
||||
f_artist_mbid: 1,
|
||||
q_artist: Q_ARTIST
|
||||
};
|
||||
|
||||
const chartArtistsParams: ChartArtistsParams = {
|
||||
page: 1,
|
||||
page_size: 10,
|
||||
country: COUNTRY
|
||||
};
|
||||
|
||||
const chartTracksParams: ChartArtistsParams = {
|
||||
page: 1,
|
||||
page_size: 10,
|
||||
country: COUNTRY,
|
||||
};
|
||||
|
||||
const matcherLyricsParams: MatcherLyricsParams = {
|
||||
q_artist: Q_ARTIST,
|
||||
q_track: Q_TRACK,
|
||||
};
|
||||
|
||||
const matcherSubtitleParams: MatcherSubtitleParams = {
|
||||
q_artist: Q_ARTIST,
|
||||
q_track: Q_TRACK,
|
||||
f_subtitle_length: 100,
|
||||
f_subtitle_length_max_deviation: 10,
|
||||
};
|
||||
|
||||
const matcherTrackParams: MatcherTrackParams = {
|
||||
q_artist: Q_ARTIST,
|
||||
q_track: Q_TRACK,
|
||||
f_has_lyrics: 1,
|
||||
f_has_subtitle: 1,
|
||||
};
|
||||
|
||||
const trackParams: TrackParams = {
|
||||
track_id: 1,
|
||||
track_mbid: 1,
|
||||
};
|
||||
|
||||
const trackLyricsParams: TrackLyricsParams = {
|
||||
track_id: 1,
|
||||
track_mbid: 1,
|
||||
};
|
||||
|
||||
const trackLyricsAddParams: TrackLyricsAddParams = {
|
||||
lyrics_body: 'Lyrics',
|
||||
lyrics_id: 1,
|
||||
};
|
||||
|
||||
const trackLyricsFeedbackParams: TrackLyricsFeedbackParams = {
|
||||
feedback: 'bad_characters',
|
||||
lyrics_id: 1,
|
||||
track_id: 1,
|
||||
};
|
||||
|
||||
const trackSnippetParams: TrackSnippetParams = {
|
||||
track_id: 1,
|
||||
};
|
||||
|
||||
const trackSubtitleParams: TrackSubtitleParams = {
|
||||
f_subtitle_length: 100,
|
||||
f_subtitle_length_max_deviation: 10,
|
||||
subtitle_format: 'dfxp',
|
||||
track_id: 1,
|
||||
track_mbid: 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Search for a track
|
||||
*
|
||||
* GET ws/1.1/track.search
|
||||
*
|
||||
* Example of track search result
|
||||
*/
|
||||
const trackSearchResult: ITrackSearchResult = {
|
||||
'message': {
|
||||
'header': { 'status_code': 200, 'execute_time': 0.27148103713989, 'available': 10000 }, 'body': {
|
||||
'track_list': [{
|
||||
'track': {
|
||||
'track_id': 164289228,
|
||||
'track_name': '7 rings',
|
||||
'track_name_translation_list': [],
|
||||
'track_rating': 100,
|
||||
'commontrack_id': 91473047,
|
||||
'instrumental': 0,
|
||||
'explicit': 1,
|
||||
'has_lyrics': 1,
|
||||
'has_subtitles': 1,
|
||||
'has_richsync': 1,
|
||||
'num_favourite': 2130,
|
||||
'album_id': 31234760,
|
||||
'album_name': 'thank u, next',
|
||||
'artist_id': 13958599,
|
||||
'artist_name': 'Ariana Grande',
|
||||
'track_share_url': 'https:\/\/www.musixmatch.com\/lyrics\/Ariana-Grande\/7-rings?utm_source=application&utm_campaign=api&utm_medium=FruitSarcop%3A1409618278546',
|
||||
'track_edit_url': 'https:\/\/www.musixmatch.com\/lyrics\/Ariana-Grande\/7-rings\/edit?utm_source=application&utm_campaign=api&utm_medium=FruitSarcop%3A1409618278546',
|
||||
'restricted': 0,
|
||||
'updated_time': '2019-03-22T15:28:01Z',
|
||||
'primary_genres': {
|
||||
'music_genre_list': [{
|
||||
'music_genre': {
|
||||
'music_genre_id': 14,
|
||||
'music_genre_parent_id': 34,
|
||||
'music_genre_name': 'Pop',
|
||||
'music_genre_name_extended': 'Pop',
|
||||
'music_genre_vanity': 'Pop'
|
||||
const trackSearchResult: TrackSearchResult = {
|
||||
message: {
|
||||
header: { status_code: 200, execute_time: 0.27148103713989, available: 10000 }, body: {
|
||||
track_list: [{
|
||||
track: {
|
||||
track_id: 164289228,
|
||||
track_name: '7 rings',
|
||||
track_name_translation_list: [],
|
||||
track_rating: 100,
|
||||
commontrack_id: 91473047,
|
||||
instrumental: 0,
|
||||
explicit: 1,
|
||||
has_lyrics: 1,
|
||||
has_subtitles: 1,
|
||||
has_richsync: 1,
|
||||
num_favourite: 2130,
|
||||
album_id: 31234760,
|
||||
album_name: 'thank u, next',
|
||||
artist_id: 13958599,
|
||||
artist_name: 'Ariana Grande',
|
||||
track_share_url: 'https:\/\/www.musixmatch.com\/lyrics\/Ariana-Grande\/7-rings?utm_source=application&utm_campaign=api&utm_medium=FruitSarcop%3A1409618278546',
|
||||
track_edit_url: 'https:\/\/www.musixmatch.com\/lyrics\/Ariana-Grande\/7-rings\/edit?utm_source=application&utm_campaign=api&utm_medium=FruitSarcop%3A1409618278546',
|
||||
restricted: 0,
|
||||
updated_time: '2019-03-22T15:28:01Z',
|
||||
primary_genres: {
|
||||
music_genre_list: [{
|
||||
music_genre: {
|
||||
music_genre_id: 14,
|
||||
music_genre_parent_id: 34,
|
||||
music_genre_name: 'Pop',
|
||||
music_genre_name_extended: 'Pop',
|
||||
music_genre_vanity: 'Pop'
|
||||
}
|
||||
}]
|
||||
}
|
||||
@@ -63,3 +183,30 @@ const trackSearchResult: ITrackSearchResult = {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Promise
|
||||
.all([
|
||||
musicmatch.album(albumParams), // 0
|
||||
musicmatch.albumTracks(albumTrackParams), // 1
|
||||
musicmatch.artist(artisParams), // 2
|
||||
musicmatch.artistAlbums(artistAlbumsParams), // 3
|
||||
musicmatch.artistRelated(artistRelatedParams), // 4
|
||||
musicmatch.artistSearch(artistSearchParams), // 5
|
||||
musicmatch.chartArtists(chartArtistsParams), // 6
|
||||
musicmatch.chartTracks(chartTracksParams), // 7
|
||||
musicmatch.matcherLyrics(matcherLyricsParams), // 8
|
||||
musicmatch.matcherSubtitle(matcherSubtitleParams), // 9
|
||||
musicmatch.matcherTrack(matcherTrackParams), // 10
|
||||
musicmatch.track(trackParams), // 11
|
||||
musicmatch.trackLyrics(trackLyricsParams), // 12
|
||||
musicmatch.trackLyricsAdd(trackLyricsAddParams), // 13
|
||||
musicmatch.trackLyricsFeedback(trackLyricsFeedbackParams), // 14
|
||||
musicmatch.trackSearch(trackSearchParams), // 15
|
||||
musicmatch.trackSnippet(trackSnippetParams), // 16
|
||||
musicmatch.trackSubtitle(trackSubtitleParams), // 17
|
||||
])
|
||||
.then((results) => {
|
||||
const trackSearchResult: TrackSearchResult = results[15];
|
||||
|
||||
console.log('No. of tracks found by search:', trackSearchResult.message.body.track_list.length);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -1,79 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user