Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cody-music

Package Overview
Dependencies
Maintainers
1
Versions
234
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cody-music - npm Package Compare versions

Comparing version 2.6.94 to 2.6.95

2

dist/lib/playlist.d.ts

@@ -42,2 +42,3 @@ import { CodyResponse, PlaylistItem, Track } from "./models";

search(type: string, q: string, limit?: number): Promise<any>;
removeTracksFromPlaylist(playlist_id: string, track_ids: string[]): Promise<CodyResponse>;
/**

@@ -64,3 +65,2 @@ * Add tracks to a given playlist

*/
removeTracksFromPlaylist(playlist_id: string, track_ids: string[]): Promise<CodyResponse>;
getTopSpotifyTracks(): Promise<Track[]>;

@@ -67,0 +67,0 @@ /**

@@ -424,2 +424,31 @@ "use strict";

}
async removeTracksFromPlaylist(playlist_id, track_ids) {
let codyResp = new models_1.CodyResponse();
if (!track_ids) {
codyResp.status = 500;
codyResp.state = models_1.CodyResponseType.Failed;
codyResp.message = "No track URIs provided to add to playlist";
return codyResp;
}
playlist_id = musicUtil.createSpotifyIdFromUri(playlist_id);
const uris = musicUtil.createUrisFromTrackIds(track_ids);
const uriList = uris.map(uri => {
return { uri };
});
let payload = {
tracks: uriList
};
// example:
// { "tracks": [{ "uri": "spotify:track:4iV5W9uYEdYUVa79Axb7Rh" },{ "uri": "spotify:track:1301WleyT98MSxVHPZCA6M" }] }
const api = `/v1/playlists/${playlist_id}/tracks`;
codyResp = await musicClient.spotifyApiPost(api, {}, 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, {}, payload);
}
return codyResp;
}
/**

@@ -436,3 +465,3 @@ * Add tracks to a given playlist

codyResp.state = models_1.CodyResponseType.Failed;
codyResp.message = "No track URIs provided to remove from playlist";
codyResp.message = "No track URIs provided to add to playlist";
return codyResp;

@@ -492,21 +521,36 @@ }

*/
async removeTracksFromPlaylist(playlist_id, track_ids) {
let codyResp = new models_1.CodyResponse();
if (!track_ids) {
codyResp.status = 500;
codyResp.state = models_1.CodyResponseType.Failed;
codyResp.message = "No track URIs provided to remove from playlist";
return codyResp;
}
const tracks = musicUtil.createUrisFromTrackIds(track_ids, true /*addUriObj*/);
codyResp = await musicClient.spotifyApiDelete(`/v1/playlists/${playlist_id}/tracks`, {}, { tracks });
// check if the token needs to be refreshed
if (codyResp.statusText === "EXPIRED") {
// refresh the token
await musicClient.refreshSpotifyToken();
// try again
codyResp = await musicClient.spotifyApiDelete(`/v1/playlists/${playlist_id}/tracks`, {}, { tracks });
}
return codyResp;
}
// async removeTracksFromPlaylist(
// playlist_id: string,
// track_ids: string[]
// ): Promise<CodyResponse> {
// playlist_id = musicUtil.createSpotifyIdFromUri(playlist_id);
// let codyResp = new CodyResponse();
// if (!track_ids) {
// codyResp.status = 500;
// codyResp.state = CodyResponseType.Failed;
// codyResp.message = "No track URIs provided to remove from playlist";
// return codyResp;
// }
// const tracks = musicUtil.createUrisFromTrackIds(
// track_ids,
// true /*addUriObj*/
// );
// codyResp = await musicClient.spotifyApiDelete(
// `/v1/playlists/${playlist_id}/tracks`,
// {},
// { tracks }
// );
// // check if the token needs to be refreshed
// if (codyResp.statusText === "EXPIRED") {
// // refresh the token
// await musicClient.refreshSpotifyToken();
// // try again
// codyResp = await musicClient.spotifyApiDelete(
// `/v1/playlists/${playlist_id}/tracks`,
// {},
// { tracks }
// );
// }
// return codyResp;
// }
async getTopSpotifyTracks() {

@@ -513,0 +557,0 @@ let tracks = [];

@@ -534,2 +534,36 @@ import { MusicClient, SPOTIFY_ROOT_API } from "./client";

async removeTracksFromPlaylist(playlist_id: string, track_ids: string[]) {
let codyResp = new CodyResponse();
if (!track_ids) {
codyResp.status = 500;
codyResp.state = CodyResponseType.Failed;
codyResp.message = "No track URIs provided to add to playlist";
return codyResp;
}
playlist_id = musicUtil.createSpotifyIdFromUri(playlist_id);
const uris = musicUtil.createUrisFromTrackIds(track_ids);
const uriList = uris.map(uri => {
return { uri };
});
let payload = {
tracks: uriList
};
// example:
// { "tracks": [{ "uri": "spotify:track:4iV5W9uYEdYUVa79Axb7Rh" },{ "uri": "spotify:track:1301WleyT98MSxVHPZCA6M" }] }
const api = `/v1/playlists/${playlist_id}/tracks`;
codyResp = await musicClient.spotifyApiPost(api, {}, 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, {}, payload);
}
return codyResp;
}
/**

@@ -550,3 +584,3 @@ * Add tracks to a given playlist

codyResp.state = CodyResponseType.Failed;
codyResp.message = "No track URIs provided to remove from playlist";
codyResp.message = "No track URIs provided to add to playlist";
return codyResp;

@@ -616,38 +650,39 @@ }

*/
async removeTracksFromPlaylist(
playlist_id: string,
track_ids: string[]
): Promise<CodyResponse> {
let codyResp = new CodyResponse();
if (!track_ids) {
codyResp.status = 500;
codyResp.state = CodyResponseType.Failed;
codyResp.message = "No track URIs provided to remove from playlist";
return codyResp;
}
const tracks = musicUtil.createUrisFromTrackIds(
track_ids,
true /*addUriObj*/
);
// async removeTracksFromPlaylist(
// playlist_id: string,
// track_ids: string[]
// ): Promise<CodyResponse> {
// playlist_id = musicUtil.createSpotifyIdFromUri(playlist_id);
// let codyResp = new CodyResponse();
// if (!track_ids) {
// codyResp.status = 500;
// codyResp.state = CodyResponseType.Failed;
// codyResp.message = "No track URIs provided to remove from playlist";
// return codyResp;
// }
// const tracks = musicUtil.createUrisFromTrackIds(
// track_ids,
// true /*addUriObj*/
// );
codyResp = await musicClient.spotifyApiDelete(
`/v1/playlists/${playlist_id}/tracks`,
{},
{ tracks }
);
// codyResp = await musicClient.spotifyApiDelete(
// `/v1/playlists/${playlist_id}/tracks`,
// {},
// { tracks }
// );
// check if the token needs to be refreshed
if (codyResp.statusText === "EXPIRED") {
// refresh the token
await musicClient.refreshSpotifyToken();
// try again
codyResp = await musicClient.spotifyApiDelete(
`/v1/playlists/${playlist_id}/tracks`,
{},
{ tracks }
);
}
// // check if the token needs to be refreshed
// if (codyResp.statusText === "EXPIRED") {
// // refresh the token
// await musicClient.refreshSpotifyToken();
// // try again
// codyResp = await musicClient.spotifyApiDelete(
// `/v1/playlists/${playlist_id}/tracks`,
// {},
// { tracks }
// );
// }
return codyResp;
}
// return codyResp;
// }

@@ -654,0 +689,0 @@ async getTopSpotifyTracks() {

{
"name": "cody-music",
"version": "2.6.94",
"version": "2.6.95",
"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",

@@ -22,2 +22,3 @@ # cody-music

- Follow or unfollow a playlist
- Spotify Recommendations

@@ -24,0 +25,0 @@ ## iTunes API support

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc