cody-music
Advanced tools
Comparing version 2.6.17 to 2.6.18
@@ -106,2 +106,8 @@ import { PlayerName, Track, PlayerDevice, SpotifyAudioFeature, PlaylistItem, CodyResponse, CodyConfig, PlayerContext } from "./models"; | ||
*/ | ||
export declare function getSpotifyLikedSongs(qsOptions?: any): Promise<Track[]>; | ||
/** | ||
* Currently only returns Spotify Web tracks not associated with a playlist. | ||
* @param player | ||
* @param qsOptions | ||
*/ | ||
export declare function getSavedTracks(player: PlayerName, qsOptions?: any): Promise<Track[]>; | ||
@@ -108,0 +114,0 @@ /** |
@@ -351,2 +351,11 @@ "use strict"; | ||
*/ | ||
async function getSpotifyLikedSongs(qsOptions = {}) { | ||
return getSavedTracks(models_1.PlayerName.SpotifyWeb, qsOptions); | ||
} | ||
exports.getSpotifyLikedSongs = getSpotifyLikedSongs; | ||
/** | ||
* Currently only returns Spotify Web tracks not associated with a playlist. | ||
* @param player | ||
* @param qsOptions | ||
*/ | ||
async function getSavedTracks(player, qsOptions = {}) { | ||
@@ -353,0 +362,0 @@ let tracks = []; |
@@ -368,3 +368,12 @@ "use strict"; | ||
} | ||
return musicClient.spotifyApiPut("/v1/me/player/pause", qsOptions, payload); | ||
const api = "/v1/me/player/pause"; | ||
let codyResp = await musicClient.spotifyApiPut(api, qsOptions, payload); | ||
// check if the token needs to be refreshed | ||
if (codyResp.statusText === "EXPIRED") { | ||
// refresh the token | ||
await musicClient.refreshSpotifyToken(); | ||
// try again | ||
codyResp = await musicClient.spotifyApiPut(api, qsOptions, payload); | ||
} | ||
return codyResp; | ||
} | ||
@@ -382,3 +391,12 @@ async spotifyWebPrevious(options) { | ||
} | ||
return musicClient.spotifyApiPost("/v1/me/player/previous", qsOptions, payload); | ||
const api = "/v1/me/player/previous"; | ||
let codyResp = await musicClient.spotifyApiPost(api, qsOptions, payload); | ||
// check if the token needs to be refreshed | ||
if (codyResp.statusText === "EXPIRED") { | ||
// refresh the token | ||
await musicClient.refreshSpotifyToken(); | ||
// try again | ||
codyResp = await musicClient.spotifyApiPost(api, qsOptions, payload); | ||
} | ||
return codyResp; | ||
} | ||
@@ -396,3 +414,12 @@ async spotifyWebNext(options) { | ||
} | ||
return musicClient.spotifyApiPost("/v1/me/player/next", qsOptions, payload); | ||
const api = "/v1/me/player/next"; | ||
let codyResp = await musicClient.spotifyApiPost(api, qsOptions, payload); | ||
// check if the token needs to be refreshed | ||
if (codyResp.statusText === "EXPIRED") { | ||
// refresh the token | ||
await musicClient.refreshSpotifyToken(); | ||
// try again | ||
codyResp = await musicClient.spotifyApiPost(api, qsOptions, payload); | ||
} | ||
return codyResp; | ||
} | ||
@@ -399,0 +426,0 @@ async getGenre(artist, songName = "") { |
@@ -384,2 +384,13 @@ "use strict"; | ||
*/ | ||
export async function getSpotifyLikedSongs( | ||
qsOptions: any = {} | ||
): Promise<Track[]> { | ||
return getSavedTracks(PlayerName.SpotifyWeb, qsOptions); | ||
} | ||
/** | ||
* Currently only returns Spotify Web tracks not associated with a playlist. | ||
* @param player | ||
* @param qsOptions | ||
*/ | ||
export async function getSavedTracks( | ||
@@ -386,0 +397,0 @@ player: PlayerName, |
@@ -410,7 +410,15 @@ import { MusicUtil } from "./util"; | ||
} | ||
return musicClient.spotifyApiPut( | ||
"/v1/me/player/pause", | ||
qsOptions, | ||
payload | ||
); | ||
const api = "/v1/me/player/pause"; | ||
let codyResp = await musicClient.spotifyApiPut(api, qsOptions, payload); | ||
// check if the token needs to be refreshed | ||
if (codyResp.statusText === "EXPIRED") { | ||
// refresh the token | ||
await musicClient.refreshSpotifyToken(); | ||
// try again | ||
codyResp = await musicClient.spotifyApiPut(api, qsOptions, payload); | ||
} | ||
return codyResp; | ||
} | ||
@@ -430,7 +438,23 @@ | ||
} | ||
return musicClient.spotifyApiPost( | ||
"/v1/me/player/previous", | ||
const api = "/v1/me/player/previous"; | ||
let codyResp = await musicClient.spotifyApiPost( | ||
api, | ||
qsOptions, | ||
payload | ||
); | ||
// check if the token needs to be refreshed | ||
if (codyResp.statusText === "EXPIRED") { | ||
// refresh the token | ||
await musicClient.refreshSpotifyToken(); | ||
// try again | ||
codyResp = await musicClient.spotifyApiPost( | ||
api, | ||
qsOptions, | ||
payload | ||
); | ||
} | ||
return codyResp; | ||
} | ||
@@ -450,7 +474,23 @@ | ||
} | ||
return musicClient.spotifyApiPost( | ||
"/v1/me/player/next", | ||
const api = "/v1/me/player/next"; | ||
let codyResp = await musicClient.spotifyApiPost( | ||
api, | ||
qsOptions, | ||
payload | ||
); | ||
// check if the token needs to be refreshed | ||
if (codyResp.statusText === "EXPIRED") { | ||
// refresh the token | ||
await musicClient.refreshSpotifyToken(); | ||
// try again | ||
codyResp = await musicClient.spotifyApiPost( | ||
api, | ||
qsOptions, | ||
payload | ||
); | ||
} | ||
return codyResp; | ||
} | ||
@@ -457,0 +497,0 @@ |
{ | ||
"name": "cody-music", | ||
"version": "2.6.17", | ||
"version": "2.6.18", | ||
"description": "mac osx spotify and itunes music player controller, spotify audio features, itunes and spotify genre, and playlist control", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -453,2 +453,8 @@ # cody-music | ||
/** | ||
* Currently only returns Spotify Web tracks not associated with a playlist. | ||
* @param qsOptions (i.e. {limit: 10, offset: 0} return 10 tracks starting at offset 0 (base of zero)) | ||
*/ | ||
getSpotifyLikedSongs(qsOptions: any = {}): Promise<Track[]> | ||
/** | ||
* Returns the genre for a provided arguments | ||
@@ -455,0 +461,0 @@ * @param artist {string} is required |
425803
10437
578