Improve spotify searching

This commit is contained in:
Jonathan Cremin 2014-12-03 23:32:49 +00:00
parent 9210a94163
commit 8a29eb8f50
6 changed files with 13 additions and 12 deletions

View file

@ -26,7 +26,7 @@ module.exports.lookupId = function(id, next) {
id: id,
name: result.name,
url: result.shortUrl,
artwork: result.icon.replace("http:", "").replace("square-200", "square-500"),
artwork: result.icon.replace("http:", "").replace("square-200", "square-250"),
artist: {
name: result.artist
}
@ -64,7 +64,7 @@ module.exports.lookupUrl = function(url, next) {
id: id,
name: result.name,
url: result.shortUrl,
artwork: result.icon.replace("http:", "").replace("square-200", "square-500"),
artwork: result.icon.replace("http:", "").replace("square-200", "square-250"),
artist: {
name: result.artist
}
@ -99,7 +99,7 @@ module.exports.search = function(data, next) {
id: id,
name: result.name,
url: result.shortUrl,
artwork: result.icon.replace("http:", "").replace("square-200", "square-500"),
artwork: result.icon.replace("http:", "").replace("square-200", "square-250"),
artist: {
name: result.artist
}

View file

@ -18,7 +18,7 @@ module.exports.lookupId = function(id, type, next) {
id: data.id,
name: data.name,
url: "https://play.spotify.com/" + type + "/" + data.id,
artwork: data.images ? data.images[0].url.replace("http:", "") : data.album.images[0].url.replace("http:", ""),
artwork: data.images ? data.images[1].url.replace("http:", "") : data.album.images[1].url.replace("http:", ""),
artist: {
name: artist.name
}
@ -30,7 +30,7 @@ module.exports.lookupId = function(id, type, next) {
id: data.id,
name: data.name,
url: "https://play.spotify.com/" + type + "/" + data.id,
artwork: data.images ? data.images[0].url.replace("http:", "") : data.album.images[0].url.replace("http:", ""),
artwork: data.images ? data.images[1].url.replace("http:", "") : data.album.images[1].url.replace("http:", ""),
artist: {
name: artist.name
},
@ -47,19 +47,19 @@ module.exports.search = function(data, next) {
var type = data.type;
if (type == "album") {
query = data.artist.name + " " + data.name;
query = "artist:" + data.artist.name.replace(":", "") + " album:" + data.name.replace(":", "");
} else if (type == "track") {
query = data.artist.name + " " + data.album.name + " " + data.name;
query = "artist:" + data.artist.name.replace(":", "") + " album:" + data.album.name.replace(":", "") + " track:" + data.name.replace(":", "");
}
query = query.replace(":", "");
spotify.search({query: query, type: type}, function(err, data) {
if ( err ) {
console.log('Error occurred: ' + err);
return;
}
console.log(data[type + "s"].items[1])
var item = data[type + "s"].items[0];
module.exports.lookupId(item.id, type, next);

View file

@ -53,6 +53,7 @@ h2 {
left: 25px;
}
.source-service {
border-radius: 5px;
background: #eee;
}
.album-artwork {

View file

@ -7,7 +7,7 @@
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,700' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Open+Sans:400,300,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="/stylesheets/style.css">
</head>

View file

@ -7,7 +7,7 @@
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,700' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Open+Sans:400,300,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="/stylesheets/style.css">
</head>

View file

@ -7,7 +7,7 @@
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,700' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Open+Sans:400,300,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="/stylesheets/style.css">
</head>