cody-music
Advanced tools
Comparing version 2.1.4 to 2.1.5
@@ -171,3 +171,3 @@ import { PlayerName, Track, PlayerDevice, SpotifyAudioFeature, PlaylistItem } from "./models"; | ||
* @param playerName {spotify|spotify-web|itunes} | ||
* @param options | ||
* @param options (spotify-web only) {playlist_id | album_id | track_id } | ||
*/ | ||
@@ -174,0 +174,0 @@ export declare function launchPlayer(playerName: PlayerName, options?: any): Promise<any>; |
@@ -407,3 +407,3 @@ "use strict"; | ||
* @param playerName {spotify|spotify-web|itunes} | ||
* @param options | ||
* @param options (spotify-web only) {playlist_id | album_id | track_id } | ||
*/ | ||
@@ -410,0 +410,0 @@ function launchPlayer(playerName, options = {}) { |
@@ -195,8 +195,11 @@ "use strict"; | ||
launchWebPlayer(options) { | ||
if (options.album) { | ||
return musicUtil.launchWebUrl(`https://open.spotify.com/album/${options.album}`); | ||
if (options.album_id) { | ||
return musicUtil.launchWebUrl(`https://open.spotify.com/album/${options.album_id}`); | ||
} | ||
else if (options.track) { | ||
return musicUtil.launchWebUrl(`https://open.spotify.com/track/${options.track}`); | ||
else if (options.track_id) { | ||
return musicUtil.launchWebUrl(`https://open.spotify.com/track/${options.track_id}`); | ||
} | ||
else if (options.playlist_id) { | ||
return musicUtil.launchWebUrl(`https://open.spotify.com/playlist/${options.playlist_id}`); | ||
} | ||
return musicUtil.launchWebUrl("https://open.spotify.com/browse"); | ||
@@ -203,0 +206,0 @@ } |
@@ -37,5 +37,5 @@ import { CodyResponse, PlaylistItem } from "./models"; | ||
removeTracksFromPlaylist(playlist_id: string, track_ids: string[]): Promise<CodyResponse>; | ||
normalizeTrackIds(track_ids: string[]): { | ||
normalizeTrackIds(track_ids: string[], useUriObj?: boolean): (string | { | ||
uri: string; | ||
}[]; | ||
})[]; | ||
} |
@@ -165,3 +165,3 @@ "use strict"; | ||
} | ||
const tracks = this.normalizeTrackIds(track_ids); | ||
const tracks = this.normalizeTrackIds(track_ids, true /*addUriObj*/); | ||
codyResp = await musicClient.spotifyApiDelete(`/v1/playlists/${playlist_id}/tracks`, {}, { tracks }); | ||
@@ -177,13 +177,18 @@ // check if the token needs to be refreshed | ||
} | ||
normalizeTrackIds(track_ids) { | ||
normalizeTrackIds(track_ids, useUriObj = false) { | ||
let tracks = []; | ||
for (let i = 0; i < track_ids.length; i++) { | ||
let trackId = track_ids[i]; | ||
if (!trackId.includes("spotify:track:")) { | ||
trackId = `spotify:track:${trackId}`; | ||
let uri = track_ids[i]; | ||
if (!uri.includes("spotify:track:")) { | ||
uri = `spotify:track:${uri}`; | ||
} | ||
const urlObj = { | ||
uri: trackId | ||
}; | ||
tracks.push(urlObj); | ||
if (useUriObj) { | ||
const urlObj = { | ||
uri | ||
}; | ||
tracks.push(urlObj); | ||
} | ||
else { | ||
tracks.push(uri); | ||
} | ||
} | ||
@@ -190,0 +195,0 @@ return tracks; |
@@ -100,5 +100,5 @@ "use strict"; | ||
// High on Life | ||
const albumId = "1GUfof1gHsqYjoHFym3aim"; | ||
const album_id = "1GUfof1gHsqYjoHFym3aim"; | ||
await CodyMusic.launchPlayer(CodyMusic.PlayerName.SpotifyWeb, { | ||
album: albumId | ||
album_id | ||
}); | ||
@@ -105,0 +105,0 @@ musicUtil.sleep(5000); |
@@ -207,3 +207,3 @@ import { MusicClient } from "./client"; | ||
} | ||
const tracks = this.normalizeTrackIds(track_ids); | ||
const tracks = this.normalizeTrackIds(track_ids, true /*addUriObj*/); | ||
@@ -231,14 +231,18 @@ codyResp = await musicClient.spotifyApiDelete( | ||
normalizeTrackIds(track_ids: string[]) { | ||
normalizeTrackIds(track_ids: string[], useUriObj: boolean = false) { | ||
let tracks = []; | ||
for (let i = 0; i < track_ids.length; i++) { | ||
let trackId = track_ids[i]; | ||
if (!trackId.includes("spotify:track:")) { | ||
trackId = `spotify:track:${trackId}`; | ||
let uri = track_ids[i]; | ||
if (!uri.includes("spotify:track:")) { | ||
uri = `spotify:track:${uri}`; | ||
} | ||
const urlObj = { | ||
uri: trackId | ||
}; | ||
tracks.push(urlObj); | ||
if (useUriObj) { | ||
const urlObj = { | ||
uri | ||
}; | ||
tracks.push(urlObj); | ||
} else { | ||
tracks.push(uri); | ||
} | ||
} | ||
@@ -245,0 +249,0 @@ |
{ | ||
"name": "cody-music", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
290241
7092