Skip to content

Commit

Permalink
Merge pull request #31 from szimek/search_spotify_playlist
Browse files Browse the repository at this point in the history
Allow to search for Spotify playlists by Spotify URI.
  • Loading branch information
woutervanwijk committed Sep 18, 2014
2 parents af88b39 + 736ebce commit 461b74b
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions webclient/js/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -27,10 +27,27 @@ function initSearch() {
delete customTracklists['albumresultscache'];
delete customTracklists['trackresultscache'];
$("#searchresults").hide();
mopidy.library.search({
any: [value]
}).then(processSearchResults, console.error);
// console.log('search sent', value);

mopidy.getUriSchemes().then(function (schemes) {
var query = {},
uris = [];

var regexp = $.map(schemes, function (scheme) {
return '^' + scheme + ':';
}).join('|');

var match = value.match(regexp);
if (match) {
var scheme = match[0];
query = {uri: [value]};
uris = [scheme];
} else {
query = {any: [value]};
}

mopidy.library.search(query, uris).then(processSearchResults, console.error);
// console.log('search sent', value);
});
}
}

Expand Down

0 comments on commit 461b74b

Please sign in to comment.