From 1198d3ddae738819f32f02d622957116778af4e6 Mon Sep 17 00:00:00 2001 From: yayuyokitano <69117606+yayuyokitano@users.noreply.github.com> Date: Sat, 19 Dec 2020 05:52:19 +0800 Subject: [PATCH] Fix user.getTopTracks (#6) --- package.json | 2 +- src/classes/user.ts | 8 ++++++++ src/interfaces/userInterface.ts | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3a2de4a3..4009abc7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lastfm-typed", - "version": "0.5.0", + "version": "0.5.1", "description": "Typed API wrapper for Last.FM using promises", "main": "dist/index.js", "author": "yayuyokitano", diff --git a/src/classes/user.ts b/src/classes/user.ts index 10ccc2ca..baafe423 100644 --- a/src/classes/user.ts +++ b/src/classes/user.ts @@ -74,6 +74,14 @@ export default class UserClass extends Base { } + public async getTopTracks(usernameOrSessionKey:string, params?:{limit?:number, page?:number, period?:"overall"|"7day"|"1month"|"3month"|"6month"|"12month"}) { + + this.checkLimit(params?.limit, 1000); + + return (await this.sendRequest(this.key, this.secret, { method: "user.getTopTracks", user: usernameOrSessionKey, ...params })).toptracks as UserInterface.getTopTracks; + + } + public async getWeeklyAlbumChart(usernameOrSessionKey:string, params?:{limit?:number, from:string, to:string}|{limit?:number}) { this.checkLimit(params?.limit, 1000); diff --git a/src/interfaces/userInterface.ts b/src/interfaces/userInterface.ts index 5ebb7a47..76451992 100644 --- a/src/interfaces/userInterface.ts +++ b/src/interfaces/userInterface.ts @@ -134,7 +134,7 @@ interface TopTrack extends TagTrack { } export interface getTopTracks { - artist:TopTrack[]; + track:TopTrack[]; "@attr":Metadata; }