From f3b55d58de4a33a1b39ac17bcf7e8d20be0f5320 Mon Sep 17 00:00:00 2001 From: Aleksey Klimenko Date: Sun, 24 Mar 2019 02:37:18 +0300 Subject: [PATCH 1/3] [musicmatch] added basic definitions and tests --- types/musicmatch/index.d.ts | 204 +++++++++++++++++++++++++++ types/musicmatch/musicmatch-tests.ts | 65 +++++++++ types/musicmatch/tsconfig.json | 23 +++ types/musicmatch/tslint.json | 79 +++++++++++ 4 files changed, 371 insertions(+) create mode 100644 types/musicmatch/index.d.ts create mode 100644 types/musicmatch/musicmatch-tests.ts create mode 100644 types/musicmatch/tsconfig.json create mode 100644 types/musicmatch/tslint.json diff --git a/types/musicmatch/index.d.ts b/types/musicmatch/index.d.ts new file mode 100644 index 0000000000..6bc88b1983 --- /dev/null +++ b/types/musicmatch/index.d.ts @@ -0,0 +1,204 @@ +// Type definitions for musicmatch 0.3.2 +// Project: https://www.npmjs.com/package/musicmatch +// Definitions by: Aleksei Klimenko +// Definitions: https://github.com/DefinitelyTyped/ + +declare module 'musicmatch'; + +type TFormat = 'json' | 'xml'; +type TSort = 'asc' | 'desc'; +type TBoolean = 0 | 1; + +export interface IPageable { + page?: number; + page_size?: number; +} + +export interface IAlbumParams { + album_id: number; +} + +export interface IAlbumTracksParams { + album_id?: number; + album_mbid?: number; + format?: TFormat; +} + +export interface IArtistParams { + artist_id?: number; + artist_mbid?: number; +} + +export interface IArtistRelatedParams extends IArtistParams, IPageable { +} + +export interface IArtistAlbumsParams extends IArtistParams, IPageable { + g_album_name?: TBoolean; + s_release_date?: TSort; +} + +export interface IArtistSearchParams extends IPageable { + q_artist?: string; + f_artist_id?: number; + f_artist_mbid?: number; +} + +export interface IMatcherLyricsParams { + q_track?: string; + q_artist?: string; +} + +export interface IMatcherSubtitleParams extends IMatcherLyricsParams { + f_subtitle_length?: number; + f_subtitle_length_max_deviation?: number; +} + +export interface IMatcherTrackParams extends IMatcherLyricsParams { + f_has_lyrics?: TBoolean; + f_has_subtitle?: TBoolean; +} + +export interface ITrackLyricsFeedbackParams { + lyrics_id?: number; + track_id?: number; + feedback?: 'wrong_lyrics' | 'wrong_attribution' | 'bad_characters' | 'lines_too_long' | 'wrong_verses' | 'wrong_formatting'; +} + +export interface ITrackLyricsAddParams { + lyrics_id?: number; + lyrics_body?: string; +} + +export interface ITrackSnippetParams { + track_id: number; +} + +export interface ITrackLyricsParams { + track_id?: number; + track_mbid?: number; +} + +export interface ITrackSubtitleParams { + track_id?: number; + track_mbid?: number; + subtitle_format?: 'lrc' | 'dfxp' | 'stledu'; + f_subtitle_length?: number; + f_subtitle_length_max_deviation?: number; +} + +export interface ITrackParams { + track_id?: number; + track_mbid?: number; +} + +export interface ITrackSearchParams extends IPageable { + q?: string; + q_lyrics?: string; + f_has_lyrics?: TBoolean; + f_artist_id?: number; + f_music_genre_id?: number; + f_artist_mbid?: number; + f_lyrics_language?: string; + s_track_rating?: TSort; + s_artist_rating?: TSort; + quorum_factor?: number; +} + +export interface ITrackSearchResult { + message: { + body: { + track_list: ITrackResult[]; + }, + header: { + available: number; + execute_time: number; + status_code: number; + } + }; +} + +export interface IMusicGenre { + music_genre_id: number; + music_genre_parent_id: number; + music_genre_name: string; + music_genre_name_extended: string; + music_genre_vanity: string; +} + +export interface PrimaryGenres { + music_genre_list: Array<{ music_genre: IMusicGenre }>; +} + +export interface ITrackResult { + track: { + track_id: number; + track_name: string; + track_name_translation_list: any[]; + track_rating: number; + commontrack_id: number; + instrumental: TBoolean; + explicit: TBoolean; + has_lyrics: TBoolean; + has_subtitles: TBoolean; + has_richsync: TBoolean; + num_favourite: number; + album_id: number; + album_name: string; + artist_id: number; + artist_name: string; + track_share_url: string; + track_edit_url: string; + restricted: TBoolean; + updated_time: string; + primary_genres: PrimaryGenres; + }; +} + +export interface IChartTracksParams extends IPageable { + country?: string; + f_has_lyrics?: TBoolean; +} + +export interface IChartArtistsParams extends IPageable { + country?: string; +} + +export default class Musicmatch { + constructor(obj?: { apikey?: string, format?: string }); + + album(params: IAlbumParams): Promise; + + albumTracks(params: IAlbumTracksParams): Promise; + + artist(params: IArtistParams): Promise; + + artistAlbums(params: IArtistAlbumsParams): Promise; + + artistRelated(params: IArtistRelatedParams): Promise; + + artistSearch(params: IArtistSearchParams): Promise; + + chartArtists(params: IChartArtistsParams): Promise; + + chartTracks(params: IChartTracksParams): Promise; + + matcherLyrics(params: IMatcherLyricsParams): Promise; + + matcherSubtitle(params: IMatcherSubtitleParams): Promise; + + matcherTrack(params: IMatcherTrackParams): Promise; + + track(params: ITrackParams): Promise; + + trackLyrics(params: ITrackLyricsParams): Promise; + + trackLyricsAdd(params: ITrackLyricsAddParams): Promise; + + trackLyricsFeedback(params: ITrackLyricsFeedbackParams): Promise; + + trackSearch(params: ITrackSearchParams): Promise; + + trackSnippet(params: ITrackSnippetParams): Promise; + + trackSubtitle(params: ITrackSubtitleParams): Promise; +} diff --git a/types/musicmatch/musicmatch-tests.ts b/types/musicmatch/musicmatch-tests.ts new file mode 100644 index 0000000000..5cab791bb6 --- /dev/null +++ b/types/musicmatch/musicmatch-tests.ts @@ -0,0 +1,65 @@ +// Type definitions for musicmatch 0.3.2 +// Project: https://www.npmjs.com/package/musicmatch +// Definitions by: Aleksei Klimenko +// Definitions: https://github.com/DefinitelyTyped/ + +import Musicmatch, { ITrackSearchParams, ITrackSearchResult } from 'musicmatch'; + +const musicmatch = new Musicmatch({ apikey: 'api_key', format: '' }); + +const trackSearchParams: ITrackSearchParams = { + f_music_genre_id: 18, + page_size: 100, + page: 1, + s_track_rating: 'desc', + f_lyrics_language: 'en', +}; + +musicmatch.trackSearch(trackSearchParams); + +/** + * Search for a track + * + * GET ws/1.1/track.search + * + */ +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' + } + }] + } + } + }] + } + } +}; diff --git a/types/musicmatch/tsconfig.json b/types/musicmatch/tsconfig.json new file mode 100644 index 0000000000..800f5abd46 --- /dev/null +++ b/types/musicmatch/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "musicmatch-tests.ts" + ] +} diff --git a/types/musicmatch/tslint.json b/types/musicmatch/tslint.json new file mode 100644 index 0000000000..a41bf5d19a --- /dev/null +++ b/types/musicmatch/tslint.json @@ -0,0 +1,79 @@ +{ + "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 + } +} From 15f39a5afe86b7037c7d7cd3e11cf845f2b9798d Mon Sep 17 00:00:00 2001 From: Aleksey Klimenko Date: Sun, 24 Mar 2019 03:02:57 +0300 Subject: [PATCH 2/3] [musicmatch] added github url --- types/musicmatch/index.d.ts | 2 +- types/musicmatch/musicmatch-tests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/musicmatch/index.d.ts b/types/musicmatch/index.d.ts index 6bc88b1983..c22bbc6424 100644 --- a/types/musicmatch/index.d.ts +++ b/types/musicmatch/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for musicmatch 0.3.2 -// Project: https://www.npmjs.com/package/musicmatch +// Project: https://github.com/c0b41/musixmatch, https://www.npmjs.com/package/musicmatch // Definitions by: Aleksei Klimenko // Definitions: https://github.com/DefinitelyTyped/ diff --git a/types/musicmatch/musicmatch-tests.ts b/types/musicmatch/musicmatch-tests.ts index 5cab791bb6..6511920854 100644 --- a/types/musicmatch/musicmatch-tests.ts +++ b/types/musicmatch/musicmatch-tests.ts @@ -1,5 +1,5 @@ // Type definitions for musicmatch 0.3.2 -// Project: https://www.npmjs.com/package/musicmatch +// Project: https://github.com/c0b41/musixmatch, https://www.npmjs.com/package/musicmatch // Definitions by: Aleksei Klimenko // Definitions: https://github.com/DefinitelyTyped/ From 4ff4c3e5cb2dee32bee9421b490926e566dea10d Mon Sep 17 00:00:00 2001 From: Aleksey Klimenko Date: Tue, 26 Mar 2019 01:16:30 +0300 Subject: [PATCH 3/3] [musicmatch] removed additional tslint rules, updated typings and tests --- types/musicmatch/index.d.ts | 94 ++++++----- types/musicmatch/musicmatch-tests.ts | 227 ++++++++++++++++++++++----- types/musicmatch/tsconfig.json | 3 +- types/musicmatch/tslint.json | 78 +-------- 4 files changed, 236 insertions(+), 166 deletions(-) diff --git a/types/musicmatch/index.d.ts b/types/musicmatch/index.d.ts index c22bbc6424..35e2937564 100644 --- a/types/musicmatch/index.d.ts +++ b/types/musicmatch/index.d.ts @@ -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 // 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; + album(params: AlbumParams): Promise; - albumTracks(params: IAlbumTracksParams): Promise; + albumTracks(params: AlbumTracksParams): Promise; - artist(params: IArtistParams): Promise; + artist(params: ArtistParams): Promise; - artistAlbums(params: IArtistAlbumsParams): Promise; + artistAlbums(params: ArtistAlbumsParams): Promise; - artistRelated(params: IArtistRelatedParams): Promise; + artistRelated(params: ArtistRelatedParams): Promise; - artistSearch(params: IArtistSearchParams): Promise; + artistSearch(params: ArtistSearchParams): Promise; - chartArtists(params: IChartArtistsParams): Promise; + chartArtists(params: ChartArtistsParams): Promise; - chartTracks(params: IChartTracksParams): Promise; + chartTracks(params: ChartTracksParams): Promise; - matcherLyrics(params: IMatcherLyricsParams): Promise; + matcherLyrics(params: MatcherLyricsParams): Promise; - matcherSubtitle(params: IMatcherSubtitleParams): Promise; + matcherSubtitle(params: MatcherSubtitleParams): Promise; - matcherTrack(params: IMatcherTrackParams): Promise; + matcherTrack(params: MatcherTrackParams): Promise; - track(params: ITrackParams): Promise; + track(params: TrackParams): Promise; - trackLyrics(params: ITrackLyricsParams): Promise; + trackLyrics(params: TrackLyricsParams): Promise; - trackLyricsAdd(params: ITrackLyricsAddParams): Promise; + trackLyricsAdd(params: TrackLyricsAddParams): Promise; - trackLyricsFeedback(params: ITrackLyricsFeedbackParams): Promise; + trackLyricsFeedback(params: TrackLyricsFeedbackParams): Promise; - trackSearch(params: ITrackSearchParams): Promise; + trackSearch(params: TrackSearchParams): Promise; - trackSnippet(params: ITrackSnippetParams): Promise; + trackSnippet(params: TrackSnippetParams): Promise; - trackSubtitle(params: ITrackSubtitleParams): Promise; + trackSubtitle(params: TrackSubtitleParams): Promise; } diff --git a/types/musicmatch/musicmatch-tests.ts b/types/musicmatch/musicmatch-tests.ts index 6511920854..cc9d516d92 100644 --- a/types/musicmatch/musicmatch-tests.ts +++ b/types/musicmatch/musicmatch-tests.ts @@ -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 // 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); + }); diff --git a/types/musicmatch/tsconfig.json b/types/musicmatch/tsconfig.json index 800f5abd46..035d6f98aa 100644 --- a/types/musicmatch/tsconfig.json +++ b/types/musicmatch/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, diff --git a/types/musicmatch/tslint.json b/types/musicmatch/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/musicmatch/tslint.json +++ b/types/musicmatch/tslint.json @@ -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" }