mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 14:29:29 +01:00
soundcloud module [#524]
This commit is contained in:
parent
62871dc80e
commit
291bff50da
5
modules/soundcloud/config.json
Normal file
5
modules/soundcloud/config.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"client_id": "391bcf67b5ad70fd64c6a4f79374f2f4",
|
||||
"outputPrefix": "\u000307soundcloud\u000f",
|
||||
"dependencies": [ "link" ]
|
||||
}
|
41
modules/soundcloud/soundcloud.js
Normal file
41
modules/soundcloud/soundcloud.js
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Module Name: soundcloud
|
||||
* Description: Various SoundCloud functionality
|
||||
*/
|
||||
var _ = require('underscore')._,
|
||||
request = require('request');
|
||||
|
||||
var soundcloud = function(dbot) {
|
||||
this.ApiRoot = 'http://api.soundcloud.com';
|
||||
|
||||
this.onLoad = function() {
|
||||
dbot.api.link.addHandler(this.name,
|
||||
/https?:\/\/(www\.)?soundcloud\.com\//,
|
||||
function(event, match, name) {
|
||||
var url = match.input;
|
||||
request.get(this.ApiRoot + '/resolve.json', {
|
||||
'qs': {
|
||||
'client_id': this.config.client_id,
|
||||
'url': url
|
||||
},
|
||||
'json': true
|
||||
}, function(error, response, body) {
|
||||
if(response.statusCode == 200) {
|
||||
if(body.kind == 'track') {
|
||||
event.reply(dbot.t('sc_track', {
|
||||
'title': body.title,
|
||||
'artist': body.user.username,
|
||||
'genre': body.genre.trim(),
|
||||
'plays': body.playback_count,
|
||||
'favs': body.favoritings_count
|
||||
}));
|
||||
}
|
||||
}
|
||||
});
|
||||
}.bind(this));
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
exports.fetch = function(dbot) {
|
||||
return new soundcloud(dbot);
|
||||
};
|
5
modules/soundcloud/strings.json
Normal file
5
modules/soundcloud/strings.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"sc_track": {
|
||||
"en": "[{title} by {artist} — {genre} — \u000312▶\u000f{plays} \u000304♥\u000f{favs}]"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user