From 8a29eb8f50f998ca70ba8d3259cdea91261d1e43 Mon Sep 17 00:00:00 2001 From: Jonathan Cremin Date: Wed, 3 Dec 2014 23:32:49 +0000 Subject: [PATCH] Improve spotify searching --- lib/rdio.js | 6 +++--- lib/spotify.js | 12 ++++++------ public/stylesheets/style.css | 1 + views/album.ejs | 2 +- views/index.ejs | 2 +- views/track.ejs | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/rdio.js b/lib/rdio.js index cfa62cb..bd62197 100644 --- a/lib/rdio.js +++ b/lib/rdio.js @@ -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 } diff --git a/lib/spotify.js b/lib/spotify.js index 8359f76..46944b7 100644 --- a/lib/spotify.js +++ b/lib/spotify.js @@ -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); diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index 3c62a06..1c25dc9 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -53,6 +53,7 @@ h2 { left: 25px; } .source-service { + border-radius: 5px; background: #eee; } .album-artwork { diff --git a/views/album.ejs b/views/album.ejs index 1d767b3..5749646 100644 --- a/views/album.ejs +++ b/views/album.ejs @@ -7,7 +7,7 @@ - + diff --git a/views/index.ejs b/views/index.ejs index 46f67b1..4fa8d38 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -7,7 +7,7 @@ - + diff --git a/views/track.ejs b/views/track.ejs index 33aa3bb..71d6c4a 100644 --- a/views/track.ejs +++ b/views/track.ejs @@ -7,7 +7,7 @@ - +