From 2d95978829ff396892bcdd76129e615a0fe458d2 Mon Sep 17 00:00:00 2001 From: Szymon Nowak Date: Tue, 15 Jul 2014 11:34:12 +0200 Subject: [PATCH] Allow to search for Spotify playlists by Spotify URI. Search query should look like e.g.: "spotify:user:spotify:playlist:2Qi8yAzfj1KavAhWz1gaem" --- webclient/js/library.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/webclient/js/library.js b/webclient/js/library.js index 1abf0e1..ec45d1b 100644 --- a/webclient/js/library.js +++ b/webclient/js/library.js @@ -18,7 +18,7 @@ function initSearch() { if ((value.length < 100) && (value.length > 0)) { showLoading(true); - //hide ios/android keyboard + //hide ios/android keyboard document.activeElement.blur(); $("input").blur(); @@ -27,10 +27,19 @@ function initSearch() { delete customTracklists['albumresultscache']; delete customTracklists['trackresultscache']; $("#searchresults").hide(); - mopidy.library.search({ - any: [value] - }).then(processSearchResults, console.error); -// console.log('search sent', value); + + var query = {}, + uris = []; + + if (value.match(/^spotify:/)) { + query = {uri: [value]}; + uris = ["spotify:"]; + } else { + query = {any: [value]}; + } + + mopidy.library.search(query, uris).then(processSearchResults, console.error); + // console.log('search sent', value); } }