cody-music
Advanced tools
Comparing version 2.6.88 to 2.6.89
@@ -12,3 +12,3 @@ "use strict"; | ||
const musicUtil = new util_1.MusicUtil(); | ||
let userPlaylists = []; | ||
let playlists = []; | ||
class Playlist { | ||
@@ -108,4 +108,3 @@ constructor() { | ||
async getPlaylists(qsOptions = {}) { | ||
userPlaylists = []; | ||
let playlists = []; | ||
playlists = []; | ||
if (!musicStore.spotifyUserId) { | ||
@@ -128,14 +127,3 @@ await userProfile.getUserProfile(); | ||
playlist.type = "playlist"; | ||
const name = playlist.name; | ||
if (playlistMap[name]) { | ||
// add to the duplicates | ||
const existingPlaylist = playlistMap[name]; | ||
if (!existingPlaylist.duplicateIds) { | ||
existingPlaylist["duplicateIds"] = []; | ||
} | ||
existingPlaylist["duplicateIds"].push(playlist.id); | ||
} | ||
else { | ||
playlistMap[name] = playlist; | ||
} | ||
playlists.push(playlist); | ||
}); | ||
@@ -156,14 +144,3 @@ // check if we need to fetch every playlist | ||
playlist.type = "playlist"; | ||
const name = playlist.name; | ||
if (playlistMap[name]) { | ||
// add to the duplicates | ||
const existingPlaylist = playlistMap[name]; | ||
if (!existingPlaylist.duplicateIds) { | ||
existingPlaylist["duplicateIds"] = []; | ||
} | ||
existingPlaylist["duplicateIds"].push(playlist.id); | ||
} | ||
else { | ||
playlistMap[name] = playlist; | ||
} | ||
playlists.push(playlist); | ||
}); | ||
@@ -177,9 +154,2 @@ } | ||
} | ||
if (playlistMap) { | ||
Object.keys(playlistMap).forEach(key => { | ||
const item = playlistMap[key]; | ||
playlists.push(item); | ||
userPlaylists.push(item); | ||
}); | ||
} | ||
return playlists; | ||
@@ -285,5 +255,5 @@ } | ||
let names = []; | ||
let playlists = await this.getPlaylists(qsOptions); | ||
if (playlists) { | ||
names = playlists.map((playlistItem) => { | ||
let playlistNames = await this.getPlaylists(qsOptions); | ||
if (playlistNames) { | ||
names = playlistNames.map((playlistItem) => { | ||
return playlistItem.name; | ||
@@ -306,4 +276,4 @@ }); | ||
// check if it's already in the playlist | ||
const existingPlaylist = userPlaylists.length | ||
? userPlaylists.filter((n) => n.name === name) | ||
const existingPlaylist = playlists.length | ||
? playlists.filter((n) => n.name === name) | ||
: []; | ||
@@ -310,0 +280,0 @@ if (existingPlaylist.length > 0) { |
@@ -19,3 +19,3 @@ import { MusicClient, SPOTIFY_ROOT_API } from "./client"; | ||
let userPlaylists: PlaylistItem[] = []; | ||
let playlists: PlaylistItem[] = []; | ||
@@ -143,4 +143,3 @@ export class Playlist { | ||
async getPlaylists(qsOptions: any = {}): Promise<PlaylistItem[]> { | ||
userPlaylists = []; | ||
let playlists: PlaylistItem[] = []; | ||
playlists = []; | ||
if (!musicStore.spotifyUserId) { | ||
@@ -171,14 +170,3 @@ await userProfile.getUserProfile(); | ||
const name = playlist.name; | ||
if (playlistMap[name]) { | ||
// add to the duplicates | ||
const existingPlaylist: PlaylistItem = | ||
playlistMap[name]; | ||
if (!existingPlaylist.duplicateIds) { | ||
existingPlaylist["duplicateIds"] = []; | ||
} | ||
existingPlaylist["duplicateIds"].push(playlist.id); | ||
} else { | ||
playlistMap[name] = playlist; | ||
} | ||
playlists.push(playlist); | ||
}); | ||
@@ -207,17 +195,3 @@ | ||
playlist.type = "playlist"; | ||
const name = playlist.name; | ||
if (playlistMap[name]) { | ||
// add to the duplicates | ||
const existingPlaylist: PlaylistItem = | ||
playlistMap[name]; | ||
if (!existingPlaylist.duplicateIds) { | ||
existingPlaylist["duplicateIds"] = []; | ||
} | ||
existingPlaylist["duplicateIds"].push( | ||
playlist.id | ||
); | ||
} else { | ||
playlistMap[name] = playlist; | ||
} | ||
playlists.push(playlist); | ||
}); | ||
@@ -232,10 +206,2 @@ } | ||
if (playlistMap) { | ||
Object.keys(playlistMap).forEach(key => { | ||
const item = playlistMap[key]; | ||
playlists.push(item); | ||
userPlaylists.push(item); | ||
}); | ||
} | ||
return playlists; | ||
@@ -369,5 +335,5 @@ } | ||
let names: string[] = []; | ||
let playlists = await this.getPlaylists(qsOptions); | ||
if (playlists) { | ||
names = playlists.map((playlistItem: PlaylistItem) => { | ||
let playlistNames = await this.getPlaylists(qsOptions); | ||
if (playlistNames) { | ||
names = playlistNames.map((playlistItem: PlaylistItem) => { | ||
return playlistItem.name; | ||
@@ -396,4 +362,4 @@ }); | ||
// check if it's already in the playlist | ||
const existingPlaylist: PlaylistItem[] = userPlaylists.length | ||
? userPlaylists.filter((n: PlaylistItem) => n.name === name) | ||
const existingPlaylist: PlaylistItem[] = playlists.length | ||
? playlists.filter((n: PlaylistItem) => n.name === name) | ||
: []; | ||
@@ -400,0 +366,0 @@ if (existingPlaylist.length > 0) { |
{ | ||
"name": "cody-music", | ||
"version": "2.6.88", | ||
"version": "2.6.89", | ||
"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
519233
12679