cody-music
Advanced tools
Comparing version 2.8.0 to 2.8.1
@@ -174,44 +174,4 @@ "use strict"; | ||
} | ||
// // get the arist data | ||
// if (includeArtistData && track.artists) { | ||
// let artists: Artist[] = []; | ||
// for (let i = 0; i < track.artists.length; i++) { | ||
// const artist = track.artists[i]; | ||
// try { | ||
// const artistData: Artist = await this.getSpotifyArtistById( | ||
// artist.id | ||
// ); | ||
// artists.push(artistData); | ||
// } catch (e) { | ||
// // just use the current artists info | ||
// artists.push(artist); | ||
// } | ||
// } | ||
// if (artists.length > 0) { | ||
// track.artists = artists; | ||
// } else { | ||
// track.artists = []; | ||
// } | ||
// } | ||
if (!track.genre && includeGenre) { | ||
// first check if we have an artist in artists | ||
// artists[0].genres[0] | ||
let genre = ""; | ||
if (track.artists && | ||
track.artists.length > 0 && | ||
track.artists[0].genres) { | ||
// make sure we use the highest frequency genre | ||
genre = musicClient.getHighestFrequencySpotifyGenre(track.artists[0].genres); | ||
} | ||
if (!genre) { | ||
// get the genre | ||
genre = await musicController.getGenre(track.artist, track.name); | ||
} | ||
if (genre) { | ||
track.genre = genre; | ||
} | ||
} | ||
tracksToReturn.push(track); | ||
} | ||
let artists = []; | ||
if (includeArtistData) { | ||
@@ -225,6 +185,6 @@ let artistIds = Object.keys(artistIdMap).map(key => { | ||
} | ||
artists = await this.getSpotifyArtistsByIds(artistIds); | ||
const artists = await this.getSpotifyArtistsByIds(artistIds); | ||
if (artists && artists.length > 0) { | ||
// go through the tracks and update the artist with the fully populated one | ||
tracksToReturn.forEach((t) => { | ||
tracksToReturn.forEach(async (t) => { | ||
const trackArtistIds = t.artists.map((artist) => { | ||
@@ -238,2 +198,20 @@ return artist.id; | ||
} | ||
if (!t.genre && includeGenre) { | ||
// first check if we have an artist in artists | ||
// artists[0].genres[0] | ||
let genre = ""; | ||
if (t.artists && | ||
t.artists.length > 0 && | ||
t.artists[0].genres) { | ||
// make sure we use the highest frequency genre | ||
genre = musicClient.getHighestFrequencySpotifyGenre(t.artists[0].genres); | ||
} | ||
if (!genre) { | ||
// get the genre | ||
genre = await musicController.getGenre(t.artist, t.name); | ||
} | ||
if (genre) { | ||
t.genre = genre; | ||
} | ||
} | ||
}); | ||
@@ -240,0 +218,0 @@ } |
@@ -208,56 +208,5 @@ import { MusicUtil } from "./util"; | ||
// // get the arist data | ||
// if (includeArtistData && track.artists) { | ||
// let artists: Artist[] = []; | ||
// for (let i = 0; i < track.artists.length; i++) { | ||
// const artist = track.artists[i]; | ||
// try { | ||
// const artistData: Artist = await this.getSpotifyArtistById( | ||
// artist.id | ||
// ); | ||
// artists.push(artistData); | ||
// } catch (e) { | ||
// // just use the current artists info | ||
// artists.push(artist); | ||
// } | ||
// } | ||
// if (artists.length > 0) { | ||
// track.artists = artists; | ||
// } else { | ||
// track.artists = []; | ||
// } | ||
// } | ||
if (!track.genre && includeGenre) { | ||
// first check if we have an artist in artists | ||
// artists[0].genres[0] | ||
let genre = ""; | ||
if ( | ||
track.artists && | ||
track.artists.length > 0 && | ||
track.artists[0].genres | ||
) { | ||
// make sure we use the highest frequency genre | ||
genre = musicClient.getHighestFrequencySpotifyGenre( | ||
track.artists[0].genres | ||
); | ||
} | ||
if (!genre) { | ||
// get the genre | ||
genre = await musicController.getGenre( | ||
track.artist, | ||
track.name | ||
); | ||
} | ||
if (genre) { | ||
track.genre = genre; | ||
} | ||
} | ||
tracksToReturn.push(track); | ||
} | ||
let artists: any[] = []; | ||
if (includeArtistData) { | ||
@@ -271,6 +220,9 @@ let artistIds = Object.keys(artistIdMap).map(key => { | ||
} | ||
artists = await this.getSpotifyArtistsByIds(artistIds); | ||
const artists: any[] = await this.getSpotifyArtistsByIds( | ||
artistIds | ||
); | ||
if (artists && artists.length > 0) { | ||
// go through the tracks and update the artist with the fully populated one | ||
tracksToReturn.forEach((t: Track) => { | ||
tracksToReturn.forEach(async (t: Track) => { | ||
const trackArtistIds: string[] = t.artists.map( | ||
@@ -288,2 +240,29 @@ (artist: any) => { | ||
} | ||
if (!t.genre && includeGenre) { | ||
// first check if we have an artist in artists | ||
// artists[0].genres[0] | ||
let genre = ""; | ||
if ( | ||
t.artists && | ||
t.artists.length > 0 && | ||
t.artists[0].genres | ||
) { | ||
// make sure we use the highest frequency genre | ||
genre = musicClient.getHighestFrequencySpotifyGenre( | ||
t.artists[0].genres | ||
); | ||
} | ||
if (!genre) { | ||
// get the genre | ||
genre = await musicController.getGenre( | ||
t.artist, | ||
t.name | ||
); | ||
} | ||
if (genre) { | ||
t.genre = genre; | ||
} | ||
} | ||
}); | ||
@@ -290,0 +269,0 @@ } |
{ | ||
"name": "cody-music", | ||
"version": "2.8.0", | ||
"version": "2.8.1", | ||
"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
549813
13357