mirror of
https://github.com/reality/dbot.git
synced 2024-12-24 03:33:07 +01:00
fix youtube search [#543]
This commit is contained in:
parent
55d8e9257e
commit
26eebdab98
@ -16,13 +16,12 @@ var youtube = function(dbot) {
|
||||
'~youtube': function(event) {
|
||||
request.get(this.ApiRoot + '/videos', {
|
||||
'qs': _.extend(this.params, {
|
||||
'q': encodeURIComponent(event.input[1]),
|
||||
'q': event.input[1],
|
||||
'max-results': 1
|
||||
}),
|
||||
'json': true
|
||||
}, function(error, response, body) {
|
||||
if(_.isObject(body) && _.has(body, 'feed') && _.has(body.feed,
|
||||
'entry') && _.has(body.feed.entry[0], 'yt$statistics')) {
|
||||
if(_.isObject(body) && _.has(body, 'feed') && _.has(body.feed, 'entry')) {
|
||||
var v = body.feed.entry[0];
|
||||
if(!_.has(v, 'yt$rating')) {
|
||||
v['yt$rating'] = {
|
||||
@ -30,6 +29,9 @@ var youtube = function(dbot) {
|
||||
'numDislikes': 0
|
||||
};
|
||||
}
|
||||
if(!_.has(v, 'yt$statistics')) {
|
||||
v['yt$statistics'] = { 'viewCount': 0 };
|
||||
}
|
||||
event.reply(dbot.t('yt_video', {
|
||||
'title': v.title['$t'],
|
||||
'plays': v['yt$statistics'].viewCount,
|
||||
|
Loading…
Reference in New Issue
Block a user