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.66 to 2.6.67

1

dist/lib/client.d.ts

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

getGenreFromItunes(artist: string, songName?: string): Promise<string>;
findNameFromItunesResponse(resp: any): any;
/**

@@ -20,0 +21,0 @@ * Refresh the spotify access token

52

dist/lib/client.js

@@ -76,2 +76,3 @@ "use strict";

async getGenreFromItunes(artist, songName = "") {
let genre = "";
// try from itunes

@@ -81,25 +82,36 @@ // search?term=${terms}&limit=3

terms = terms.trim();
const api = `search?term=${encodeURIComponent(terms)}`;
return itunesSearchClient
.get(api)
.then(resp => {
let secondaryGenreName = "";
if (resp.data && resp.data.resultCount > 0) {
for (let i = 0; i < resp.data.resultCount; i++) {
let result = resp.data.results[i];
if (result.kind === "song" && result.primaryGenreName) {
return result.primaryGenreName;
}
else if (result.primaryGenreName) {
secondaryGenreName = result.primaryGenreName;
}
}
}
return secondaryGenreName;
})
.catch(err => {
console.error("Unable to retrieve genre from itunes search: ", err.message);
let api = `search?term=${encodeURIComponent(terms)}`;
let resp = await itunesSearchClient.get(api).catch(err => {
return "";
});
if (resp) {
genre = await this.findNameFromItunesResponse(resp);
}
else {
// try without the artist, just the song name
api = `search?term=${encodeURIComponent(songName)}`;
resp = await itunesSearchClient.get(api).catch(err => {
return "";
});
if (resp) {
genre = await this.findNameFromItunesResponse(resp);
}
}
return genre;
}
findNameFromItunesResponse(resp) {
let genre = "";
if (resp.data && resp.data.resultCount > 0) {
for (let i = 0; i < resp.data.resultCount; i++) {
let result = resp.data.results[i];
if (result.kind === "song" && result.primaryGenreName) {
return result.primaryGenreName;
}
else if (result.primaryGenreName) {
genre = result.primaryGenreName;
}
}
}
return genre;
}
/**

@@ -106,0 +118,0 @@ * Refresh the spotify access token

@@ -84,2 +84,4 @@ import axios, { AxiosInstance } from "axios";

): Promise<string> {
let genre = "";
// try from itunes

@@ -89,28 +91,36 @@ // search?term=${terms}&limit=3

terms = terms.trim();
const api = `search?term=${encodeURIComponent(terms)}`;
return itunesSearchClient
.get(api)
.then(resp => {
let secondaryGenreName = "";
if (resp.data && resp.data.resultCount > 0) {
for (let i = 0; i < resp.data.resultCount; i++) {
let result = resp.data.results[i];
if (result.kind === "song" && result.primaryGenreName) {
return result.primaryGenreName;
} else if (result.primaryGenreName) {
secondaryGenreName = result.primaryGenreName;
}
}
}
return secondaryGenreName;
})
.catch(err => {
console.error(
"Unable to retrieve genre from itunes search: ",
err.message
);
let api = `search?term=${encodeURIComponent(terms)}`;
let resp = await itunesSearchClient.get(api).catch(err => {
return "";
});
if (resp) {
genre = await this.findNameFromItunesResponse(resp);
} else {
// try without the artist, just the song name
api = `search?term=${encodeURIComponent(songName)}`;
resp = await itunesSearchClient.get(api).catch(err => {
return "";
});
if (resp) {
genre = await this.findNameFromItunesResponse(resp);
}
}
return genre;
}
findNameFromItunesResponse(resp: any) {
let genre = "";
if (resp.data && resp.data.resultCount > 0) {
for (let i = 0; i < resp.data.resultCount; i++) {
let result = resp.data.results[i];
if (result.kind === "song" && result.primaryGenreName) {
return result.primaryGenreName;
} else if (result.primaryGenreName) {
genre = result.primaryGenreName;
}
}
}
return genre;
}
/**

@@ -117,0 +127,0 @@ * Refresh the spotify access token

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

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