From 6d69c3036b0d152a08729855955fbf87ce57188b Mon Sep 17 00:00:00 2001 From: Muhimur Date: Tue, 15 Jun 2021 11:45:48 -0400 Subject: [PATCH 01/11] commit --- package-lock.json | 5 + package.json | 3 +- src/index.js | 296 +++++++++++++++++++++++----------------------- 3 files changed, 154 insertions(+), 150 deletions(-) diff --git a/package-lock.json b/package-lock.json index b02813c..030e2ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,11 @@ "version": "2.6.1", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" + }, + "petitio": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/petitio/-/petitio-1.3.2.tgz", + "integrity": "sha512-hbbT+rOvovz39ZneGW+C8B4YsKH20KLXYVDT/IzSUxaY8H7al/TO+vFCm+H5cnYe62gIqF9ak5p8OJktV/I0Ig==" } } } diff --git a/package.json b/package.json index 41fc1a3..3a61520 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "test": "node test/index.js" }, "dependencies": { - "node-fetch": "2.6.1" + "node-fetch": "2.6.1", + "petitio": "^1.3.2" }, "devDependencies": {}, "repository": { diff --git a/src/index.js b/src/index.js index 3eb959c..697da61 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ -const fetch = require('node-fetch'); -const apiUrl = 'https://api.deezer.com/' +const fetch = require("petitio"); +const apiUrl = "https://api.deezer.com/"; function DeezerPublicApi() { this.apiUrl = apiUrl; @@ -8,333 +8,334 @@ function DeezerPublicApi() { /* * ALBUM */ -DeezerPublicApi.prototype.album = function(id, limit, index) { - var url = 'album/' + id; +DeezerPublicApi.prototype.album = function (id, limit, index) { + let url = `album/${id}`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.album.comments = function(id, limit, index) { - var url = 'album/' + id + '/comments'; +DeezerPublicApi.prototype.album.comments = function (id, limit, index) { + let url = `album/${id}/comments`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.album.fans = function(id, limit, index) { - var url = 'album/' + id + '/fans'; +DeezerPublicApi.prototype.album.fans = function (id, limit, index) { + let url = `album/${id}/fans`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.album.tracks = function(id, limit, index) { - var url = 'album/' + id + '/tracks'; +DeezerPublicApi.prototype.album.tracks = function (id, limit, index) { + let url = `album/${id}/tracks`; return rq(url, index, limit); }; /* * ARTIST */ -DeezerPublicApi.prototype.artist = function(id, limit, index) { - var url = 'artist/' + id; +DeezerPublicApi.prototype.artist = function (id, limit, index) { + let url = `artist/${id}`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.artist.top = function(id, limit, index) { - var url = 'artist/' + id + '/top'; +DeezerPublicApi.prototype.artist.top = function (id, limit, index) { + let url = `artist/${id}/top`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.artist.albums = function(id, limit, index) { - var url = 'artist/' + id + '/albums'; +DeezerPublicApi.prototype.artist.albums = function (id, limit, index) { + let url = `artist/${id}/albums`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.artist.comments = function(id, limit, index) { - var url = 'artist/' + id + '/comments'; +DeezerPublicApi.prototype.artist.comments = function (id, limit, index) { + let url = `artist/${id}/comments`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.artist.fans = function(id, limit, index) { - var url = 'artist/' + id + '/fans'; +DeezerPublicApi.prototype.artist.fans = function (id, limit, index) { + let url = `artist/${id}/fans`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.artist.related = function(id, limit, index) { - var url = 'artist/' + id + '/related'; +DeezerPublicApi.prototype.artist.related = function (id, limit, index) { + let url = `artist/${id}/related`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.artist.radio = function(id, limit, index) { - var url = 'artist/' + id + '/radio'; +DeezerPublicApi.prototype.artist.radio = function (id, limit, index) { + let url = `artist/${id}/radio`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.artist.playlists = function(id, limit, index) { - var url = 'artist/' + id + '/playlists'; +DeezerPublicApi.prototype.artist.playlists = function (id, limit, index) { + let url = `artist/${id}/playlists`; return rq(url, index, limit); }; /* * CHART */ -DeezerPublicApi.prototype.chart = function(limit, index) { - var url = 'chart/'; +DeezerPublicApi.prototype.chart = function (limit, index) { + let url = "chart/"; return rq(url, index, limit); }; -DeezerPublicApi.prototype.chart.tracks = function(limit, index) { - var url = 'chart/0/tracks'; +DeezerPublicApi.prototype.chart.tracks = function (limit, index) { + let url = "chart/0/tracks"; return rq(url, index, limit); }; -DeezerPublicApi.prototype.chart.albums = function(limit, index) { - var url = 'chart/0/albums'; +DeezerPublicApi.prototype.chart.albums = function (limit, index) { + let url = "chart/0/albums"; return rq(url, index, limit); }; -DeezerPublicApi.prototype.chart.artists = function(limit, index) { - var url = 'chart/0/artists'; +DeezerPublicApi.prototype.chart.artists = function (limit, index) { + let url = "chart/0/artists"; return rq(url, index, limit); }; -DeezerPublicApi.prototype.chart.playlists = function(limit, index) { - var url = 'chart/0/playlists'; +DeezerPublicApi.prototype.chart.playlists = function (limit, index) { + let url = "chart/0/playlists"; return rq(url, index, limit); }; -DeezerPublicApi.prototype.chart.podcasts = function(limit, index) { - var url = 'chart/0/podcasts'; +DeezerPublicApi.prototype.chart.podcasts = function (limit, index) { + let url = "chart/0/podcasts"; return rq(url, index, limit); }; /* * COMMENT */ -DeezerPublicApi.prototype.comment = function(id, limit, index) { - var url = 'comment/' + id; +DeezerPublicApi.prototype.comment = function (id, limit, index) { + let url = `comment/${id}`; return rq(url, index, limit); }; /* * EDITORIAL */ -DeezerPublicApi.prototype.editorial = function(id, limit, index) { - var url = 'editorial/' + ((id) ? id : ''); +DeezerPublicApi.prototype.editorial = function (id, limit, index) { + let url = "editorial/" + ((id) ? id : ""); return rq(url, index, limit); }; -DeezerPublicApi.prototype.editorial.selection = function(id, date, limit, index) { - var url = 'editorial/' + id + '/selection'; - if (date) url = url + '&date=' + date; +DeezerPublicApi.prototype.editorial.selection = function (id, date, limit, index) { + let url = `editorial/${id}/selection`; + if (date) url = url + "&date=" + date; return rq(url, index, limit); }; -DeezerPublicApi.prototype.editorial.charts = function(id, limit, index) { - var url = 'editorial/' + id + '/charts'; +DeezerPublicApi.prototype.editorial.charts = function (id, limit, index) { + let url = `editorial/${id}/charts`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.editorial.releases = function(id, limit, index) { - var url = 'editorial/' + id + '/releases'; +DeezerPublicApi.prototype.editorial.releases = function (id, limit, index) { + let url = `editorial/${id}/releases`; return rq(url, index, limit); }; /* * EPISODE */ -DeezerPublicApi.prototype.episode = function(id, limit, index) { - var url = 'episode/' + id; +DeezerPublicApi.prototype.episode = function (id, limit, index) { + let url = `episode/${id}`; return rq(url, index, limit); }; /* * GENRE */ -DeezerPublicApi.prototype.genre = function(id, limit, index) { - var url = 'genre/' + ((id) ? id : ''); +DeezerPublicApi.prototype.genre = function (id, limit, index) { + let url = "genre/" + ((id) ? id : ""); return rq(url, index, limit); }; -DeezerPublicApi.prototype.genre.artists = function(id, limit, index) { - var url = 'genre/' + id + '/artists'; +DeezerPublicApi.prototype.genre.artists = function (id, limit, index) { + let url = `genre/${id}/artists`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.genre.podcasts = function(id, limit, index) { - var url = 'genre/' + id + '/podcasts'; +DeezerPublicApi.prototype.genre.podcasts = function (id, limit, index) { + let url = `genre/${id}/podcasts`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.genre.radios = function(id, limit, index) { - var url = 'genre/' + id + '/radios'; +DeezerPublicApi.prototype.genre.radios = function (id, limit, index) { + let url = `genre/${id}/radios`; return rq(url, index, limit); }; /* * INFOS */ -DeezerPublicApi.prototype.infos = function() { - var url = 'infos'; +DeezerPublicApi.prototype.infos = function () { + let url = "infos"; return rq(url); }; /* * OPTIONS */ -DeezerPublicApi.prototype.options = function() { - var url = 'options'; +DeezerPublicApi.prototype.options = function () { + let url = "options"; return rq(url); }; /* * PLAYLIST */ -DeezerPublicApi.prototype.playlist = function(id, limit, index) { - var url = 'playlist/' + id; +DeezerPublicApi.prototype.playlist = function (id, limit, index) { + let url = `playlist/${id}`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.playlist.comments = function(id, limit, index) { - var url = 'playlist/' + id + '/comments'; +DeezerPublicApi.prototype.playlist.comments = function (id, limit, index) { + let url = `playlist/${id}/comments`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.playlist.fans = function(id, limit, index) { - var url = 'playlist/' + id + '/fans'; +DeezerPublicApi.prototype.playlist.fans = function (id, limit, index) { + let url = "playlist/" + id + "/fans"; return rq(url, index, limit); }; -DeezerPublicApi.prototype.playlist.tracks = function(id, limit, index) { - var url = 'playlist/' + id + '/tracks'; +DeezerPublicApi.prototype.playlist.tracks = function (id, limit, index) { + let url = `playlist/${id}/tracks`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.playlist.radio = function(id, limit, index) { - var url = 'playlist/' + id + '/radio'; +DeezerPublicApi.prototype.playlist.radio = function (id, limit, index) { + let url = `playlist/${id}/radio`; return rq(url, index, limit); }; /* * PODCAST */ -DeezerPublicApi.prototype.podcast = function(id, limit, index) { - var url = 'podcast/' + ((id) ? id : ''); +DeezerPublicApi.prototype.podcast = function (id, limit, index) { + let url = "podcast/" + ((id) ? id : ""); return rq(url, index, limit); }; -DeezerPublicApi.prototype.podcast.episodes = function(id, limit, index) { - var url = 'podcast/' + id + '/episodes'; +DeezerPublicApi.prototype.podcast.episodes = function (id, limit, index) { + let url = "podcast/" + id + "/episodes"; return rq(url, index, limit); }; /* * RADIO */ -DeezerPublicApi.prototype.radio = function(id, limit, index) { - var url = 'radio/' + ((id) ? id : ''); +DeezerPublicApi.prototype.radio = function (id, limit, index) { + let url = "radio/" + ((id) ? id : ""); return rq(url, index, limit); }; -DeezerPublicApi.prototype.radio.genres = function(limit, index) { - var url = 'radio/genres'; +DeezerPublicApi.prototype.radio.genres = function (limit, index) { + let url = "radio/genres"; return rq(url, index, limit); }; -DeezerPublicApi.prototype.radio.top = function(limit, index) { - var url = 'radio/top'; +DeezerPublicApi.prototype.radio.top = function (limit, index) { + let url = "radio/top"; return rq(url, index, limit); }; -DeezerPublicApi.prototype.radio.lists = function(limit, index) { - var url = 'radio/lists'; +DeezerPublicApi.prototype.radio.lists = function (limit, index) { + let url = "radio/lists"; return rq(url, index, limit); }; -DeezerPublicApi.prototype.radio.tracks = function(id, limit, index) { - var url = 'radio/' + id + '/tracks'; +DeezerPublicApi.prototype.radio.tracks = function (id, limit, index) { + let url = `radio/${id}/tracks`; return rq(url, index, limit); }; /* * TRACK */ -DeezerPublicApi.prototype.track = function(id, limit, index) { - var url = 'track/' + id; +DeezerPublicApi.prototype.track = function (id, limit, index) { + let url = `track/${id}`; return rq(url, index, limit); }; /* * USER */ -DeezerPublicApi.prototype.user = function(id, limit, index) { - var url = 'user/' + id; +DeezerPublicApi.prototype.user = function (id, limit, index) { + let url = `user/${id}`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.user.albums = function(id, limit, index) { - var url = 'user/' + id + '/albums'; +DeezerPublicApi.prototype.user.albums = function (id, limit, index) { + let url = `user/${id}/albums` return rq(url, index, limit); }; -DeezerPublicApi.prototype.user.artists = function(id, limit, index) { - var url = 'user/' + id + '/artists'; +DeezerPublicApi.prototype.user.artists = function (id, limit, index) { + let url = `user/${id}/artists`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.user.charts = function(id, limit, index) { - var url = 'user/' + id + '/charts'; +DeezerPublicApi.prototype.user.charts = function (id, limit, index) { + let url = `user/${id}/charts`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.user.charts.tracks = function(id, limit, index) { - var url = 'user/' + id + '/charts/tracks'; +DeezerPublicApi.prototype.user.charts.tracks = function (id, limit, index) { + let url = `user/${id}/charts/tracks`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.user.charts.albums = function(id, limit, index) { - var url = 'user/' + id + '/charts/albums'; +DeezerPublicApi.prototype.user.charts.albums = function (id, limit, index) { + let url = `user/${id}/charts/albums`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.user.charts.playlists = function(id, limit, index) { - var url = 'user/' + id + '/charts/playlists'; +DeezerPublicApi.prototype.user.charts.playlists = function (id, limit, index) { + let url = `user/${id}/charts/playlists`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.user.charts.artists = function(id, limit, index) { - var url = 'user/' + id + '/charts/artists'; +DeezerPublicApi.prototype.user.charts.artists = function (id, limit, index) { + let url = `user/${id}/charts/artists`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.user.flow = function(id, limit, index) { - var url = 'user/' + id + '/flow'; +DeezerPublicApi.prototype.user.flow = function (id, limit, index) { + let url = `user/${id}/flow`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.user.followings = function(id, limit, index) { - var url = 'user/' + id + '/followings'; +DeezerPublicApi.prototype.user.followings = function (id, limit, index) { + let url = `user/${id}/followings`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.user.followers = function(id, limit, index) { - var url = 'user/' + id + '/followers'; +DeezerPublicApi.prototype.user.followers = function (id, limit, index) { + let url = `user/${id}/followers`; + let url = "user/" + id + "/followers"; return rq(url, index, limit); }; -DeezerPublicApi.prototype.user.playlists = function(id, limit, index) { - var url = 'user/' + id + '/playlists'; +DeezerPublicApi.prototype.user.playlists = function (id, limit, index) { + let url = `user/${id}/playlists`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.user.podcasts = function(id, limit, index) { - var url = 'user/' + id + '/podcasts'; +DeezerPublicApi.prototype.user.podcasts = function (id, limit, index) { + let url = `user/${id}/podcasts`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.user.radios = function(id, limit, index) { - var url = 'user/' + id + '/radios'; +DeezerPublicApi.prototype.user.radios = function (id, limit, index) { + let url = `user/${id}/radios`; return rq(url, index, limit); }; -DeezerPublicApi.prototype.user.tracks = function(id, limit, index) { - var url = 'user/' + id + '/tracks'; +DeezerPublicApi.prototype.user.tracks = function (id, limit, index) { + let url = `user/${id}/tracks`; return rq(url, index, limit); }; @@ -343,12 +344,12 @@ DeezerPublicApi.prototype.user.tracks = function(id, limit, index) { /* * SEARCH */ -DeezerPublicApi.prototype.search = function(options, order, limit, index) { - var url = 'search?q='; - var query = ''; - if (typeof options === 'object') { - for (var key in options) { - query = query + key + ':"' + options[key] + '" '; +DeezerPublicApi.prototype.search = function (options, order, limit, index) { + let url = "search?q="; + let query = ""; + if (typeof options === "object") { + for (let key in options) { + query = query + key + ":'" + options[key] + '" '; } } else { query = options; @@ -358,52 +359,49 @@ DeezerPublicApi.prototype.search = function(options, order, limit, index) { return rq(url, index, limit, order); }; -DeezerPublicApi.prototype.search.artist = function(query, order, limit, index, strict) { - var url = 'search/artist?q=' + query; +DeezerPublicApi.prototype.search.artist = function (query, order, limit, index, strict) { + let url = "search/artist?q=" + query; return rq(url, index, limit, order, strict); }; -DeezerPublicApi.prototype.search.playlist = function(query, order, limit, index, strict) { - var url = 'search/playlist?q=' + query; +DeezerPublicApi.prototype.search.playlist = function (query, order, limit, index, strict) { + let url = "search/playlist?q=" + query; return rq(url, index, limit, order, strict); }; -DeezerPublicApi.prototype.search.podcast = function(query, order, limit, index, strict) { - var url = 'search/podcast?q=' + query; +DeezerPublicApi.prototype.search.podcast = function (query, order, limit, index, strict) { + let url = "search/podcast?q=" + query; return rq(url, index, limit, order, strict); }; -DeezerPublicApi.prototype.search.radio = function(query, order, limit, index, strict) { - var url = 'search/radio?q=' + query; +DeezerPublicApi.prototype.search.radio = function (query, order, limit, index, strict) { + let url = "search/radio?q=" + query; return rq(url, index, limit, order, strict); }; -DeezerPublicApi.prototype.search.track = function(query, order, limit, index, strict) { - var url = 'search/track?q=' + query; +DeezerPublicApi.prototype.search.track = function (query, order, limit, index, strict) { + let url = "search/track?q=" + query; return rq(url, index, limit, order, strict); }; -DeezerPublicApi.prototype.search.user = function(query, order, limit, index, strict) { - var url = 'search/user?q=' + query; +DeezerPublicApi.prototype.search.user = function (query, order, limit, index, strict) { + let url = "search/user?q=" + query; return rq(url, index, limit, order, strict); }; function rq(url, index, limit, order, strict) { - return new Promise((resolve, reject)=>{ - if (!url.includes("?")) url = url + '?'; - if (index && index !== 0) url = url + '&index=' + index; - if (limit && limit !== 0) url = url + '&limit=' + limit; - if (order) url = url + '&order=' + order; - if (strict) url = url + '&strict=on'; - if (url.endsWith('?')) url = url.slice(0, -1); - fetch(apiUrl + url, { - json: true - }).then(res => res.json()) + return new Promise((resolve, reject) => { + if (!url.includes("?")) url = url + "?"; + if (index && index !== 0) url = url + "&index=" + index; + if (limit && limit !== 0) url = url + "&limit=" + limit; + if (order) url = url + "&order=" + order; + if (strict) url = url + "&strict=on"; + if (url.endsWith("?")) url = url.slice(0, -1); + fetch(apiUrl + url).json() .then(json => { resolve(json) - // console.log(json) }).catch((err) => reject(err)); }); } -module.exports = DeezerPublicApi; +module.exports = DeezerPublicApi; \ No newline at end of file From 1abf5d57710c6951cd63b1748bd8d2bccad4f529 Mon Sep 17 00:00:00 2001 From: Muhimur Date: Tue, 15 Jun 2021 11:48:48 -0400 Subject: [PATCH 02/11] commit --- README.md | 171 +++++++++++++++++++++++++++----------------------- test/index.js | 22 +++---- 2 files changed, 105 insertions(+), 88 deletions(-) diff --git a/README.md b/README.md index 0000515..00848e5 100644 --- a/README.md +++ b/README.md @@ -1,124 +1,141 @@ # Deezer Public API wrapper -This is *Nodejs* wrapper for the [Deezer Public API](http://developers.deezer.com/api) that return promises. +This is _Nodejs_ wrapper for the [Deezer Public API](http://developers.deezer.com/api) that return promises. + +Forked from https://github.com/zaosoula/deezer-public-api. ## Installation - npm install deezer-public-api --save + + npm install deezer-public-api ## Usage example ```js -const DeezerPublicApi = require('deezer-public-api'); +const DeezerPublicApi = require("deezer-public-api"); let deezer = new DeezerPublicApi(); +// Search a track + +deezer.track("493894782").then(result => console.log(result)); + //Search an artist -deezer.search.artist('ILYSH').then(function(result) { - console.log(result); -}); +deezer.search.artist("ILYSH").then(result => console.log(result)); //Get info for the given artist id -deezer.artist('58671252').then(function(result) { - console.log(result); -}); +deezer.artist("58671252").then(result => console.log(result)); //Get album list for the given artist id -deezer.artist.albums('58671252').then(function(result) { - console.log(result); -}); +deezer.artist.albums("58671252").then(result => console.log(result)); ``` + ## Available methods ##### Album -* album(`id`, `limit`, `index`) -* album.comments(`id`, `limit`, `index`) -* album.fans(`id`, `limit`, `index`) -* album.tracks(`id`, `limit`, `index`) + +- album(`id`, `limit`, `index`) +- album.comments(`id`, `limit`, `index`) +- album.fans(`id`, `limit`, `index`) +- album.tracks(`id`, `limit`, `index`) ##### Artist -* artist(`id`, `limit`, `index`) -* artist.top(`id`, `limit`, `index`) -* artist.albums(`id`, `limit`, `index`) -* artist.comments(`id`, `limit`, `index`) -* artist.fans(`id`, `limit`, `index`) -* artist.related(`id`, `limit`, `index`) -* artist.radio(`id`, `limit`, `index`) -* artist.playlists(`id`, `limit`, `index`) + +- artist(`id`, `limit`, `index`) +- artist.top(`id`, `limit`, `index`) +- artist.albums(`id`, `limit`, `index`) +- artist.comments(`id`, `limit`, `index`) +- artist.fans(`id`, `limit`, `index`) +- artist.related(`id`, `limit`, `index`) +- artist.radio(`id`, `limit`, `index`) +- artist.playlists(`id`, `limit`, `index`) ##### Chart -* chart(`limit`, `index`) -* chart.tracks(`limit`, `index`) -* chart.albums(`limit`, `index`) -* chart.artists(`limit`, `index`) -* chart.playlists(`limit`, `index`) -* chart.podcasts(`limit`, `index`) + +- chart(`limit`, `index`) +- chart.tracks(`limit`, `index`) +- chart.albums(`limit`, `index`) +- chart.artists(`limit`, `index`) +- chart.playlists(`limit`, `index`) +- chart.podcasts(`limit`, `index`) ##### Comment -* comment(`id`, `limit`, `index`) + +- comment(`id`, `limit`, `index`) ##### Editorial -* editorial(`id`, `limit`, `index`) -* editorial.selection(`id`, `limit`, `index`) -* editorial.charts(`id`, `limit`, `index`) -* editorial.releases(`id`, `limit`, `index`) + +- editorial(`id`, `limit`, `index`) +- editorial.selection(`id`, `limit`, `index`) +- editorial.charts(`id`, `limit`, `index`) +- editorial.releases(`id`, `limit`, `index`) ##### Episode -* episode(`id`, `limit`, `index`) + +- episode(`id`, `limit`, `index`) ##### Genre -* genre(`id`, `limit`, `index`) -* genre.artists(`id`, `limit`, `index`) -* genre.podcasts(`id`, `limit`, `index`) -* genre.radios(`id`, `limit`, `index`) + +- genre(`id`, `limit`, `index`) +- genre.artists(`id`, `limit`, `index`) +- genre.podcasts(`id`, `limit`, `index`) +- genre.radios(`id`, `limit`, `index`) ##### Infos -* infos() + +- infos() ##### Options -* options() + +- options() ##### Playlist -* playlist(`id`, `limit`, `index`) -* playlist.comments(`id`, `limit`, `index`) -* playlist.fans(`id`, `limit`, `index`) -* playlist.tracks(`id`, `limit`, `index`) -* playlist.radio(`id`, `limit`, `index`) + +- playlist(`id`, `limit`, `index`) +- playlist.comments(`id`, `limit`, `index`) +- playlist.fans(`id`, `limit`, `index`) +- playlist.tracks(`id`, `limit`, `index`) +- playlist.radio(`id`, `limit`, `index`) ##### Podcast -* podcast(`id`, `limit`, `index`) -* podcast.episodes(`id`, `limit`, `index`) + +- podcast(`id`, `limit`, `index`) +- podcast.episodes(`id`, `limit`, `index`) ##### Radio -* radio(`id`, `limit`, `index`) -* radio.genres(`limit`, `index`) -* radio.top(`limit`, `index`) -* radio.lists(`limit`, `index`) -* radio.tracks(`id`, `limit`, `index`) + +- radio(`id`, `limit`, `index`) +- radio.genres(`limit`, `index`) +- radio.top(`limit`, `index`) +- radio.lists(`limit`, `index`) +- radio.tracks(`id`, `limit`, `index`) ##### Track -* track(`id`, `limit`, `index`) + +- track(`id`, `limit`, `index`) ##### User -* user(`id`, `limit`, `index`) -* user.albums(`id`, `limit`, `index`) -* user.artists(`id`, `limit`, `index`) -* user.charts(`id`, `limit`, `index`) -* user.charts.tracks(`id`, `limit`, `index`) -* user.charts.albums(`id`, `limit`, `index`) -* user.charts.playlists(`id`, `limit`, `index`) -* user.charts.artists(`id`, `limit`, `index`) -* user.flow(`id`, `limit`, `index`) -* user.followings(`id`, `limit`, `index`) -* user.followers(`id`, `limit`, `index`) -* user.playlists(`id`, `limit`, `index`) -* user.podcasts(`id`, `limit`, `index`) -* user.radios(`id`, `limit`, `index`) -* user.tracks(`id`, `limit`, `index`) + +- user(`id`, `limit`, `index`) +- user.albums(`id`, `limit`, `index`) +- user.artists(`id`, `limit`, `index`) +- user.charts(`id`, `limit`, `index`) +- user.charts.tracks(`id`, `limit`, `index`) +- user.charts.albums(`id`, `limit`, `index`) +- user.charts.playlists(`id`, `limit`, `index`) +- user.charts.artists(`id`, `limit`, `index`) +- user.flow(`id`, `limit`, `index`) +- user.followings(`id`, `limit`, `index`) +- user.followers(`id`, `limit`, `index`) +- user.playlists(`id`, `limit`, `index`) +- user.podcasts(`id`, `limit`, `index`) +- user.radios(`id`, `limit`, `index`) +- user.tracks(`id`, `limit`, `index`) ##### Search -* search(`options`, `order`, `limit`, `index`) -* search.artist(`query`, `order`, `limit`, `index`, `strict`) -* search.playlist(`query`, `order`, `limit`, `index`, `strict`) -* search.podcast(`query`, `order`, `limit`, `index`, `strict`) -* search.radio(`query`, `order`, `limit`, `index`, `strict`) -* search.track(`query`, `order`, `limit`, `index`, `strict`) -* search.user(`query`, `order`, `limit`, `index`, `strict`) + +- search(`options`, `order`, `limit`, `index`) +- search.artist(`query`, `order`, `limit`, `index`, `strict`) +- search.playlist(`query`, `order`, `limit`, `index`, `strict`) +- search.podcast(`query`, `order`, `limit`, `index`, `strict`) +- search.radio(`query`, `order`, `limit`, `index`, `strict`) +- search.track(`query`, `order`, `limit`, `index`, `strict`) +- search.user(`query`, `order`, `limit`, `index`, `strict`) diff --git a/test/index.js b/test/index.js index 50fca04..c468ef7 100644 --- a/test/index.js +++ b/test/index.js @@ -1,9 +1,9 @@ -const DeezerPublicApi = require('..'); +const DeezerPublicApi = require(''); let deezer = new DeezerPublicApi(); let artistName = 'ILYSH'; -deezer.search.artist(artistName).then((artists)=>{ +deezer.search.artist(artistName).then((artists) => { - let artist = artists.data.find((artist)=> { + let artist = artists.data.find((artist) => { console.log(artist.name); return artist.name == artistName }); @@ -11,15 +11,15 @@ deezer.search.artist(artistName).then((artists)=>{ console.log(artist); return deezer.artist.albums(artist.id, 1000); -}).then((result)=>{ +}).then((result) => { - result.data.map((i)=>{ + result.data.map((i) => { console.log(i); }) return deezer.album(result.data[0].id) -}).then((album)=>{ - if(album.error){ +}).then((album) => { + if (album.error) { console.log(album.error); return; } @@ -42,19 +42,19 @@ deezer.search.artist(artistName).then((artists)=>{ name: album.artist.name, picture: album.artist.picture_xl, }, - contributors: album.contributors.map((e)=>{ + contributors: album.contributors.map((e) => { return { name: e.name, picture: e.picture_xl, } }), - genres: album.genres.data.map((o)=>{ + genres: album.genres.data.map((o) => { return { id: o.id, name: o.name } }), - tracks: album.tracks.data.map((o)=>{ + tracks: album.tracks.data.map((o) => { return { title: o.title, titleShort: o.title_short, @@ -67,6 +67,6 @@ deezer.search.artist(artistName).then((artists)=>{ console.log(albumData); -}).catch((err)=>{ +}).catch((err) => { console.log("has an error:", err); }) From 99220ee1987d7a536f45aa77df8a291aa26d60f4 Mon Sep 17 00:00:00 2001 From: Muhimur Date: Tue, 15 Jun 2021 11:49:24 -0400 Subject: [PATCH 03/11] commit --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 00848e5..bee2d55 100644 --- a/README.md +++ b/README.md @@ -15,16 +15,15 @@ const DeezerPublicApi = require("deezer-public-api"); let deezer = new DeezerPublicApi(); // Search a track - deezer.track("493894782").then(result => console.log(result)); -//Search an artist +// Search an artist deezer.search.artist("ILYSH").then(result => console.log(result)); -//Get info for the given artist id +// Get info for the given artist id deezer.artist("58671252").then(result => console.log(result)); -//Get album list for the given artist id +// Get album list for the given artist id deezer.artist.albums("58671252").then(result => console.log(result)); ``` From c2aee836b182aa71fd01d6057e6b62afd610bf83 Mon Sep 17 00:00:00 2001 From: Muhimur Date: Tue, 15 Jun 2021 11:54:45 -0400 Subject: [PATCH 04/11] remove node-fetch --- package-lock.json | 7 +------ package.json | 5 ++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 030e2ce..f20a5d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,9 @@ { "name": "deezer-public-api", - "version": "1.0.4", + "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { - "node-fetch": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" - }, "petitio": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/petitio/-/petitio-1.3.2.tgz", diff --git a/package.json b/package.json index 3a61520..3068b3b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "deezer-public-api", - "version": "1.0.4", + "version": "1.0.0", "description": "This is Nodejs wrapper for the Deezer Public API that return promises.", "keywords": [ "deezer-api", @@ -19,13 +19,12 @@ "test": "node test/index.js" }, "dependencies": { - "node-fetch": "2.6.1", "petitio": "^1.3.2" }, "devDependencies": {}, "repository": { "type": "git", - "url": "https://github.com/zaosoula/deezer-public-api.git" + "url": "git+https://github.com/zaosoula/deezer-public-api.git" }, "bugs": { "url": "https://github.com/zaosoula/deezer-public-api/issues" From fdadefcbc3c9f7fe06bc812273992c396f002d5f Mon Sep 17 00:00:00 2001 From: Muhimur Date: Tue, 15 Jun 2021 12:03:36 -0400 Subject: [PATCH 05/11] Fix --- package.json | 4 ++-- src/index.js | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 3068b3b..b6f437a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "deezer-public-api", + "name": "@muhimur/deezer-public-api", "version": "1.0.0", - "description": "This is Nodejs wrapper for the Deezer Public API that return promises.", + "description": "This is Nodejs wrapper for the Deezer Public API that return promises. Forked from deezer-public-api with a faster response time.", "keywords": [ "deezer-api", "deezer", diff --git a/src/index.js b/src/index.js index 697da61..c9ac476 100644 --- a/src/index.js +++ b/src/index.js @@ -315,7 +315,6 @@ DeezerPublicApi.prototype.user.followings = function (id, limit, index) { DeezerPublicApi.prototype.user.followers = function (id, limit, index) { let url = `user/${id}/followers`; - let url = "user/" + id + "/followers"; return rq(url, index, limit); }; From 5b52beba4c81ca7c7c8dadc05fbd03b6cebfaf61 Mon Sep 17 00:00:00 2001 From: Muhimur Date: Tue, 15 Jun 2021 18:17:16 -0400 Subject: [PATCH 06/11] README.md --- README.md | 2 +- package.json | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bee2d55..0012ea5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This is _Nodejs_ wrapper for the [Deezer Public API](http://developers.deezer.com/api) that return promises. -Forked from https://github.com/zaosoula/deezer-public-api. +This is forked from https://github.com/zaosoula/deezer-public-api, but has modifications and uses a much faster HTTP library. ## Installation diff --git a/package.json b/package.json index b6f437a..7a07156 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@muhimur/deezer-public-api", - "version": "1.0.0", + "version": "1.0.1", "description": "This is Nodejs wrapper for the Deezer Public API that return promises. Forked from deezer-public-api with a faster response time.", "keywords": [ "deezer-api", @@ -24,10 +24,10 @@ "devDependencies": {}, "repository": { "type": "git", - "url": "git+https://github.com/zaosoula/deezer-public-api.git" + "url": "git+https://github.com/muhimur9049/deezer-public-api.git" }, "bugs": { - "url": "https://github.com/zaosoula/deezer-public-api/issues" + "url": "https://github.com/muhimur9049/deezer-public-api/issues" }, - "homepage": "https://github.com/zaosoula/deezer-public-api" + "homepage": "https://github.com/muhimur9049/deezer-public-api" } From 2af345e0e6f3c0e746d50b745372794b1f72ad58 Mon Sep 17 00:00:00 2001 From: Muhimur Date: Tue, 15 Jun 2021 18:18:30 -0400 Subject: [PATCH 07/11] README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0012ea5..5585f91 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This is forked from https://github.com/zaosoula/deezer-public-api, but has modif ```js const DeezerPublicApi = require("deezer-public-api"); -let deezer = new DeezerPublicApi(); +const deezer = new DeezerPublicApi(); // Search a track deezer.track("493894782").then(result => console.log(result)); @@ -137,4 +137,4 @@ deezer.artist.albums("58671252").then(result => console.log(result)); - search.podcast(`query`, `order`, `limit`, `index`, `strict`) - search.radio(`query`, `order`, `limit`, `index`, `strict`) - search.track(`query`, `order`, `limit`, `index`, `strict`) -- search.user(`query`, `order`, `limit`, `index`, `strict`) +- search.user(`query`, `order`, `limit`, `index`, `strict`) \ No newline at end of file From 0b9882fd0d8021337c3dcfb9d7f3e6f654ff4236 Mon Sep 17 00:00:00 2001 From: Muhimur Date: Tue, 15 Jun 2021 18:19:55 -0400 Subject: [PATCH 08/11] README.md --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5585f91..22de886 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Deezer Public API wrapper -This is _Nodejs_ wrapper for the [Deezer Public API](http://developers.deezer.com/api) that return promises. +This is **[Node.js](https://nodejs.org/en/download/)** wrapper for the [Deezer Public API](http://developers.deezer.com/api) that return promises. This is forked from https://github.com/zaosoula/deezer-public-api, but has modifications and uses a much faster HTTP library. diff --git a/package.json b/package.json index 7a07156..c352bce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@muhimur/deezer-public-api", - "version": "1.0.1", + "version": "1.0.2", "description": "This is Nodejs wrapper for the Deezer Public API that return promises. Forked from deezer-public-api with a faster response time.", "keywords": [ "deezer-api", From 92bbc078c09ae97d525df149830953b10112082f Mon Sep 17 00:00:00 2001 From: Muhimur Date: Tue, 15 Jun 2021 18:22:21 -0400 Subject: [PATCH 09/11] README.md --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 22de886..49e7e0c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This is **[Node.js](https://nodejs.org/en/download/)** wrapper for the [Deezer Public API](http://developers.deezer.com/api) that return promises. -This is forked from https://github.com/zaosoula/deezer-public-api, but has modifications and uses a much faster HTTP library. +This is forked from https://github.com/zaosoula/deezer-public-api, but it has modifications and uses a much faster HTTP library, giving you the most immediate results. ## Installation diff --git a/package.json b/package.json index c352bce..965cd88 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@muhimur/deezer-public-api", - "version": "1.0.2", + "version": "1.0.21", "description": "This is Nodejs wrapper for the Deezer Public API that return promises. Forked from deezer-public-api with a faster response time.", "keywords": [ "deezer-api", From dd4b8375db1f4065ab870767847f2612fce9c357 Mon Sep 17 00:00:00 2001 From: Muhimur Date: Tue, 15 Jun 2021 18:24:16 -0400 Subject: [PATCH 10/11] package-lock.json --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index f20a5d8..9b581a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "deezer-public-api", + "name": "@muhimur/deezer-public-api", "version": "1.0.0", "lockfileVersion": 1, "requires": true, diff --git a/package.json b/package.json index 965cd88..ba061ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@muhimur/deezer-public-api", - "version": "1.0.21", + "version": "1.0.22", "description": "This is Nodejs wrapper for the Deezer Public API that return promises. Forked from deezer-public-api with a faster response time.", "keywords": [ "deezer-api", From f7f5f9d52319c6d4667c673e9e26c14002d79455 Mon Sep 17 00:00:00 2001 From: Muhimur Date: Tue, 15 Jun 2021 18:26:17 -0400 Subject: [PATCH 11/11] README.md --- README.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 49e7e0c..b4f60a7 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,12 @@ This is forked from https://github.com/zaosoula/deezer-public-api, but it has mo ## Installation - npm install deezer-public-api + npm install @muhimur/deezer-public-api ## Usage example ```js -const DeezerPublicApi = require("deezer-public-api"); +const DeezerPublicApi = require("@muhimur/deezer-public-api"); const deezer = new DeezerPublicApi(); // Search a track diff --git a/package.json b/package.json index ba061ad..1c5d926 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@muhimur/deezer-public-api", - "version": "1.0.22", + "version": "1.0.23", "description": "This is Nodejs wrapper for the Deezer Public API that return promises. Forked from deezer-public-api with a faster response time.", "keywords": [ "deezer-api",