cody-music
Advanced tools
Comparing version 2.8.2 to 2.8.4
@@ -243,3 +243,5 @@ "use strict"; | ||
async getGenreFromItunes(artist, song = "") { | ||
let genre = await this.fetchItunesGenre(artist, song); | ||
let genre = await this.fetchItunesGenre(artist, song).catch(e => { | ||
return ""; | ||
}); | ||
// try cleaning up the song name | ||
@@ -259,3 +261,5 @@ if (!genre && song) { | ||
} | ||
genre = await this.fetchItunesGenre(artist, song); | ||
genre = await this.fetchItunesGenre(artist, song).catch(e => { | ||
return ""; | ||
}); | ||
} | ||
@@ -266,3 +270,5 @@ if (!genre && artist && artist.indexOf(",") !== -1) { | ||
artist = artist.split(",")[0].trim(); | ||
genre = await this.fetchItunesGenre(artist, song); | ||
genre = await this.fetchItunesGenre(artist, song).catch(e => { | ||
return ""; | ||
}); | ||
} | ||
@@ -269,0 +275,0 @@ return genre; |
@@ -532,3 +532,5 @@ "use strict"; | ||
if (!genre || genre === "") { | ||
genre = await this.getGenreFromSpotify(artist, spotifyArtistId); | ||
genre = await this.getGenreFromSpotify(artist, spotifyArtistId).catch(e => { | ||
return ""; | ||
}); | ||
} | ||
@@ -535,0 +537,0 @@ return genre; |
@@ -206,3 +206,4 @@ "use strict"; | ||
// go through the tracks and update the artist with the fully populated one | ||
tracksToReturn.forEach(async (t) => { | ||
for (let z = 0; z < tracksToReturn.length; z++) { | ||
const t = tracksToReturn[z]; | ||
const trackArtistIds = t.artists.map((artist) => { | ||
@@ -223,7 +224,17 @@ return artist.id; | ||
// make sure we use the highest frequency genre | ||
genre = musicClient.getHighestFrequencySpotifyGenre(t.artists[0].genres); | ||
try { | ||
genre = musicClient.getHighestFrequencySpotifyGenre(t.artists[0].genres); | ||
} | ||
catch (e) { | ||
// | ||
} | ||
} | ||
if (!genre) { | ||
// get the genre | ||
genre = await musicController.getGenre(t.artist, t.name); | ||
try { | ||
genre = await musicController.getGenre(t.artist, t.name); | ||
} | ||
catch (e) { | ||
// | ||
} | ||
} | ||
@@ -234,3 +245,3 @@ if (genre) { | ||
} | ||
}); | ||
} | ||
} | ||
@@ -240,3 +251,7 @@ } | ||
if (includeAudioFeaturesData) { | ||
const spotifyAudioFeatures = await audioStat.getSpotifyAudioFeatures(ids); | ||
const spotifyAudioFeatures = await audioStat | ||
.getSpotifyAudioFeatures(ids) | ||
.catch(e => { | ||
return null; | ||
}); | ||
if (spotifyAudioFeatures && spotifyAudioFeatures.length > 0) { | ||
@@ -243,0 +258,0 @@ // "id": "4JpKVNYnVcJ8tuMKjAj50A", |
import axios, { AxiosInstance } from "axios"; | ||
import { MusicStore } from "./store"; | ||
import { CodyResponse, CodyResponseType } from "./models"; | ||
import { join } from "path"; | ||
const querystring = require("querystring"); | ||
@@ -278,3 +279,5 @@ | ||
): Promise<string> { | ||
let genre = await this.fetchItunesGenre(artist, song); | ||
let genre = await this.fetchItunesGenre(artist, song).catch(e => { | ||
return ""; | ||
}); | ||
// try cleaning up the song name | ||
@@ -294,3 +297,5 @@ if (!genre && song) { | ||
} | ||
genre = await this.fetchItunesGenre(artist, song); | ||
genre = await this.fetchItunesGenre(artist, song).catch(e => { | ||
return ""; | ||
}); | ||
} | ||
@@ -302,3 +307,6 @@ | ||
artist = artist.split(",")[0].trim(); | ||
genre = await this.fetchItunesGenre(artist, song); | ||
genre = await this.fetchItunesGenre(artist, song).catch(e => { | ||
return ""; | ||
}); | ||
} | ||
@@ -305,0 +313,0 @@ |
@@ -628,3 +628,8 @@ import { MusicUtil } from "./util"; | ||
if (!genre || genre === "") { | ||
genre = await this.getGenreFromSpotify(artist, spotifyArtistId); | ||
genre = await this.getGenreFromSpotify( | ||
artist, | ||
spotifyArtistId | ||
).catch(e => { | ||
return ""; | ||
}); | ||
} | ||
@@ -631,0 +636,0 @@ |
@@ -244,3 +244,4 @@ import { MusicUtil } from "./util"; | ||
// go through the tracks and update the artist with the fully populated one | ||
tracksToReturn.forEach(async (t: Track) => { | ||
for (let z = 0; z < tracksToReturn.length; z++) { | ||
const t: Track = tracksToReturn[z]; | ||
const trackArtistIds: string[] = t.artists.map( | ||
@@ -268,12 +269,20 @@ (artist: any) => { | ||
// make sure we use the highest frequency genre | ||
genre = musicClient.getHighestFrequencySpotifyGenre( | ||
t.artists[0].genres | ||
); | ||
try { | ||
genre = musicClient.getHighestFrequencySpotifyGenre( | ||
t.artists[0].genres | ||
); | ||
} catch (e) { | ||
// | ||
} | ||
} | ||
if (!genre) { | ||
// get the genre | ||
genre = await musicController.getGenre( | ||
t.artist, | ||
t.name | ||
); | ||
try { | ||
genre = await musicController.getGenre( | ||
t.artist, | ||
t.name | ||
); | ||
} catch (e) { | ||
// | ||
} | ||
} | ||
@@ -284,3 +293,3 @@ if (genre) { | ||
} | ||
}); | ||
} | ||
} | ||
@@ -291,5 +300,7 @@ } | ||
if (includeAudioFeaturesData) { | ||
const spotifyAudioFeatures = await audioStat.getSpotifyAudioFeatures( | ||
ids | ||
); | ||
const spotifyAudioFeatures = await audioStat | ||
.getSpotifyAudioFeatures(ids) | ||
.catch(e => { | ||
return null; | ||
}); | ||
if (spotifyAudioFeatures && spotifyAudioFeatures.length > 0) { | ||
@@ -296,0 +307,0 @@ // "id": "4JpKVNYnVcJ8tuMKjAj50A", |
{ | ||
"name": "cody-music", | ||
"version": "2.8.2", | ||
"version": "2.8.4", | ||
"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", |
553069
13438