Improve spotify searching
This commit is contained in:
parent
9210a94163
commit
8a29eb8f50
6 changed files with 13 additions and 12 deletions
|
@ -26,7 +26,7 @@ module.exports.lookupId = function(id, next) {
|
||||||
id: id,
|
id: id,
|
||||||
name: result.name,
|
name: result.name,
|
||||||
url: result.shortUrl,
|
url: result.shortUrl,
|
||||||
artwork: result.icon.replace("http:", "").replace("square-200", "square-500"),
|
artwork: result.icon.replace("http:", "").replace("square-200", "square-250"),
|
||||||
artist: {
|
artist: {
|
||||||
name: result.artist
|
name: result.artist
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ module.exports.lookupUrl = function(url, next) {
|
||||||
id: id,
|
id: id,
|
||||||
name: result.name,
|
name: result.name,
|
||||||
url: result.shortUrl,
|
url: result.shortUrl,
|
||||||
artwork: result.icon.replace("http:", "").replace("square-200", "square-500"),
|
artwork: result.icon.replace("http:", "").replace("square-200", "square-250"),
|
||||||
artist: {
|
artist: {
|
||||||
name: result.artist
|
name: result.artist
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ module.exports.search = function(data, next) {
|
||||||
id: id,
|
id: id,
|
||||||
name: result.name,
|
name: result.name,
|
||||||
url: result.shortUrl,
|
url: result.shortUrl,
|
||||||
artwork: result.icon.replace("http:", "").replace("square-200", "square-500"),
|
artwork: result.icon.replace("http:", "").replace("square-200", "square-250"),
|
||||||
artist: {
|
artist: {
|
||||||
name: result.artist
|
name: result.artist
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ module.exports.lookupId = function(id, type, next) {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
name: data.name,
|
name: data.name,
|
||||||
url: "https://play.spotify.com/" + type + "/" + data.id,
|
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: {
|
artist: {
|
||||||
name: artist.name
|
name: artist.name
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ module.exports.lookupId = function(id, type, next) {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
name: data.name,
|
name: data.name,
|
||||||
url: "https://play.spotify.com/" + type + "/" + data.id,
|
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: {
|
artist: {
|
||||||
name: artist.name
|
name: artist.name
|
||||||
},
|
},
|
||||||
|
@ -47,19 +47,19 @@ module.exports.search = function(data, next) {
|
||||||
var type = data.type;
|
var type = data.type;
|
||||||
|
|
||||||
if (type == "album") {
|
if (type == "album") {
|
||||||
query = data.artist.name + " " + data.name;
|
query = "artist:" + data.artist.name.replace(":", "") + " album:" + data.name.replace(":", "");
|
||||||
} else if (type == "track") {
|
} 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) {
|
spotify.search({query: query, type: type}, function(err, data) {
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
console.log('Error occurred: ' + err);
|
console.log('Error occurred: ' + err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(data[type + "s"].items[1])
|
||||||
|
|
||||||
var item = data[type + "s"].items[0];
|
var item = data[type + "s"].items[0];
|
||||||
|
|
||||||
module.exports.lookupId(item.id, type, next);
|
module.exports.lookupId(item.id, type, next);
|
||||||
|
|
|
@ -53,6 +53,7 @@ h2 {
|
||||||
left: 25px;
|
left: 25px;
|
||||||
}
|
}
|
||||||
.source-service {
|
.source-service {
|
||||||
|
border-radius: 5px;
|
||||||
background: #eee;
|
background: #eee;
|
||||||
}
|
}
|
||||||
.album-artwork {
|
.album-artwork {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<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="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="/stylesheets/style.css">
|
<link rel="stylesheet" href="/stylesheets/style.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<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="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="/stylesheets/style.css">
|
<link rel="stylesheet" href="/stylesheets/style.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<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="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="/stylesheets/style.css">
|
<link rel="stylesheet" href="/stylesheets/style.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue