forked from GitHub/dbot
Merge pull request #278 from tmenari/master
[spotify] show title when searching
This commit is contained in:
commit
d4f69eb54f
@ -44,13 +44,14 @@ var spotify = function(dbot) {
|
|||||||
json: true
|
json: true
|
||||||
}, function(error, response, body) {
|
}, function(error, response, body) {
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
|
var spotify = "\u00039spotify\u000f";
|
||||||
if (_.has(body, 'tracks') && body.tracks[0] && _.has(body.tracks[0], 'href')) {
|
if (_.has(body, 'tracks') && body.tracks[0] && _.has(body.tracks[0], 'href')) {
|
||||||
var t = body.tracks[0].href;
|
var t = body.tracks[0].href;
|
||||||
t = t.replace(/:/g, '/');
|
t = t.replace(/:/g, '/');
|
||||||
t = t.replace(/spotify/, 'http://open.spotify.com');
|
t = t.replace(/spotify/, 'http://open.spotify.com');
|
||||||
event.reply(t);
|
event.reply(dbot.t("found", {s: spotify, artist: _.map(body.tracks[0].artists, function(a) { return a.name }).join(', '), album: body.tracks[0].album.name, track: body.tracks[0].name, url: t}));
|
||||||
} else {
|
} else {
|
||||||
event.reply(dbot.t("not-found", {s: "\u00039spotify\u000f"}));
|
event.reply(dbot.t("not-found", {s: spotify}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -8,6 +8,9 @@
|
|||||||
"track": {
|
"track": {
|
||||||
"english": "{s} [track] {artist} - {track} (from {album})"
|
"english": "{s} [track] {artist} - {track} (from {album})"
|
||||||
},
|
},
|
||||||
|
"found": {
|
||||||
|
"english": "{s} [{url}] {artist} - {track} (from {album})"
|
||||||
|
},
|
||||||
"not-found": {
|
"not-found": {
|
||||||
"english": "{s} No results."
|
"english": "{s} No results."
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user