From e9605b60d3cb0003c06616a0593117d9faa1b829 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 13 Oct 2013 04:17:17 +0000 Subject: [PATCH] i think this do it --- modules/youtube/youtube.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/youtube/youtube.js b/modules/youtube/youtube.js index 5d976bc..2454534 100644 --- a/modules/youtube/youtube.js +++ b/modules/youtube/youtube.js @@ -29,8 +29,7 @@ var youtube = function(dbot) { v['yt$statistics'] = { 'viewCount': 0 }; } - var link = v.link[0].href.match(this.LinkRegex)[2]; - return dbot.t('yt_video', { + var res = dbot.t('yt_video', { 'title': v.title['$t'], 'plays': v['yt$statistics'].viewCount.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"), 'author': v.author[0].name['$t'], @@ -38,7 +37,14 @@ var youtube = function(dbot) { 'dislikes': v['yt$rating'].numDislikes, 'minutes': minutes, 'seconds': seconds - }) + ' - ' + 'http://youtu.be/' + link; + }); + + var link = v.link[0].href.match(this.LinkRegex) + if(!_.isUndefined(link)) { + res += ' - ' + link[2]; + } + + return res; }.bind(this) };