forked from GitHub/dbot
fix for new web api
This commit is contained in:
parent
7964bb9e88
commit
ef86954025
@ -287,8 +287,15 @@ var lastfm = function(dbot) {
|
|||||||
output += ' - http://youtu.be/' + link;
|
output += ' - http://youtu.be/' + link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbot.api.spotify.spotifySearch(term, function(body, t) {
|
||||||
|
if(body) {
|
||||||
|
output += ' - ' + t;
|
||||||
|
}
|
||||||
|
|
||||||
event.reply(output);
|
event.reply(output);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
if(err == 'no_user') {
|
if(err == 'no_user') {
|
||||||
event.reply('Unknown LastFM user.');
|
event.reply('Unknown LastFM user.');
|
||||||
|
@ -16,7 +16,7 @@ var spotify = function(dbot) {
|
|||||||
*/
|
*/
|
||||||
this.spotifyRegex = /(\b(https?:\/\/open.spotify.com\/(artist|track|album)\/\w*|spotify:(artist|track|album):\w*)\b)/ig;
|
this.spotifyRegex = /(\b(https?:\/\/open.spotify.com\/(artist|track|album)\/\w*|spotify:(artist|track|album):\w*)\b)/ig;
|
||||||
this.spotifyLookup = 'http://ws.spotify.com/lookup/1/.json';
|
this.spotifyLookup = 'http://ws.spotify.com/lookup/1/.json';
|
||||||
this.spotifySearch = 'http://ws.spotify.com/search/1/track.json';
|
this.spotifySearch = 'https://api.spotify.com/v1/search';
|
||||||
this.youtubeRegex = /^http:\/\/(?:www\.)?youtube.com\/watch\?v=\w+(&\S*)?$/
|
this.youtubeRegex = /^http:\/\/(?:www\.)?youtube.com\/watch\?v=\w+(&\S*)?$/
|
||||||
this.spotifyText = '\u00039spotify\u000f';
|
this.spotifyText = '\u00039spotify\u000f';
|
||||||
|
|
||||||
@ -52,14 +52,15 @@ var spotify = function(dbot) {
|
|||||||
'spotifySearch': function(query, callback) {
|
'spotifySearch': function(query, callback) {
|
||||||
request({
|
request({
|
||||||
'url': this.spotifySearch,
|
'url': this.spotifySearch,
|
||||||
'qs': { 'q': query },
|
'qs': { 'q': query, 'type': 'track' },
|
||||||
'json': true
|
'json': true
|
||||||
}, function(error, response, body) {
|
}, function(error, response, body) {
|
||||||
if(!error && response.statusCode == 200) {
|
if(!error && response.statusCode == 200) {
|
||||||
if(_.has(body, 'tracks') && body.tracks[0] && _.has(body.tracks[0], 'href')) {
|
if(_.has(body, 'tracks') && body.tracks.items[0] && _.has(body.tracks.items[0], 'href')) {
|
||||||
var t = body.tracks[0].href;
|
var t = body.tracks.items[0].href;
|
||||||
t = t.replace(/:/g, '/');
|
///*t = t.replace(/:/g, '/');
|
||||||
t = t.replace(/spotify/, 'http://open.spotify.com');
|
t = t.replace(/api.spotify.com\/v1\/tracks/,
|
||||||
|
'open.spotify.com/track');
|
||||||
callback(body, t);
|
callback(body, t);
|
||||||
} else {
|
} else {
|
||||||
callback(false);
|
callback(false);
|
||||||
@ -75,10 +76,10 @@ var spotify = function(dbot) {
|
|||||||
this.api.spotifySearch(query, function(body, t) {
|
this.api.spotifySearch(query, function(body, t) {
|
||||||
if(body) {
|
if(body) {
|
||||||
event.reply(dbot.t('found', {
|
event.reply(dbot.t('found', {
|
||||||
'artist': _.map(body.tracks[0].artists, function(a) {
|
'artist': _.map(body.tracks.items[0].artists, function(a) {
|
||||||
return a.name }).join(', '),
|
return a.name }).join(', '),
|
||||||
'album': body.tracks[0].album.name,
|
'album': body.tracks.items[0].album.name,
|
||||||
'track': body.tracks[0].name,
|
'track': body.tracks.items[0].name,
|
||||||
'url': t
|
'url': t
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user