From 79eaf8c56e51f370620f3b4b62ddfd6a67fcd0d7 Mon Sep 17 00:00:00 2001 From: reality Date: Wed, 24 Jul 2013 18:06:39 +0000 Subject: [PATCH] fix youtube again --- modules/youtube/youtube.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/youtube/youtube.js b/modules/youtube/youtube.js index 9c24705..30bc33f 100644 --- a/modules/youtube/youtube.js +++ b/modules/youtube/youtube.js @@ -24,6 +24,12 @@ var youtube = function(dbot) { if(_.isObject(body) && _.has(body, 'feed') && _.has(body.feed, 'entry') && _.has(body.feed.entry[0], 'yt$statistics')) { var v = body.feed.entry[0]; + if(!_.has(v, 'yt$rating')) { + v['yt$rating'] = { + 'numLikes': 0, + 'numDislikes': 0 + }; + } event.reply(dbot.t('yt_video', { 'title': v.title['$t'], 'plays': v['yt$statistics'].viewCount, @@ -48,13 +54,13 @@ var youtube = function(dbot) { 'json': true }, function(error, response, body) { if(_.isObject(body) && _.has(body, 'entry')) { + var v = body.entry; if(!_.has(v, 'yt$rating')) { v['yt$rating'] = { 'numLikes': 0, 'numDislikes': 0 }; } - var v = body.entry; event.reply(dbot.t('yt_video', { 'title': v.title['$t'], 'plays': v['yt$statistics'].viewCount,