diff --git a/lib/services/spotify/index.js b/lib/services/spotify/index.js index f3dd065..2af1d5d 100644 --- a/lib/services/spotify/index.js +++ b/lib/services/spotify/index.js @@ -86,6 +86,7 @@ export function* search(data) { } const results = yield spotify.searchAsync({query: query, type: type}); + if (!results[type + "s"].items[0]) { return {service: "spotify"}; } else { @@ -97,7 +98,7 @@ export function* search(data) { results[type + "s"].items.forEach(function(item) { const albumName = data.type == "album" ? item.name : item.album.name; - const matches = albumName.match(/^[^\(\[]+/); + const matches = cleanParam(albumName).match(/^[^\(\[]+/); if(choppedAlbum.indexOf(matches[0]) >= 0) { found = item; } diff --git a/test/services/spotify.js b/test/services/spotify.js index 7c59b4a..ed229fc 100644 --- a/test/services/spotify.js +++ b/test/services/spotify.js @@ -19,6 +19,11 @@ describe('Spotify', function(){ const result = yield spotify.search({type: 'album', artist: {name: 'David Guetta'}, name: 'Listen (Deluxe)'}); result.name.should.equal('Listen (Deluxe)'); }); + + it('should find album with colon in name by search', function* (){ + const result = yield spotify.search({type: 'album', artist: {name: 'Various Artists'}, name: 'The Get Down Part II: Original Soundtrack From The Netflix Original Series'}); + result.name.should.equal('The Get Down Part II: Original Soundtrack From The Netflix Original Series'); + }); }); describe('parseUrl', function(){