From 03067f97d66241198c919838db77066a5b265519 Mon Sep 17 00:00:00 2001 From: Scritches Date: Wed, 7 Mar 2018 17:30:35 -0500 Subject: [PATCH] Added support for the minified youtube links returned by the ~yt command --- modules/spotify/spotify.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/spotify/spotify.js b/modules/spotify/spotify.js index dacb765..d28a335 100644 --- a/modules/spotify/spotify.js +++ b/modules/spotify/spotify.js @@ -17,7 +17,8 @@ var spotify = function(dbot) { this.spotifyRegex = /(\b(https?:\/\/open.spotify.com\/(artist|track|album)\/\w*|spotify:(artist|track|album):\w*)\b)/ig; this.spotifyLookup = 'http://ws.spotify.com/lookup/1/.json'; this.spotifySearch = 'https://api.spotify.com/v1/search'; - this.youtubeRegex = /^http:\/\/(?:www\.)?youtube.com\/watch\?v=\w+(&\S*)?$/ + this.youtubeRegex = /^http:\/\/(?:www\.)?youtube.com\/watch\?v=\w+(&\S*)?$/; + this.youtubeMiniRegex = /^https?:\/\/youtu\.be\/\w+$/; this.spotifyText = '\u00039spotify\u000f'; this.lookup = function(link, callback) { @@ -94,7 +95,7 @@ var spotify = function(dbot) { lastLink = event.params[1]; } - if(lastLink.match(this.youtubeRegex)) { + if(lastLink.match(this.youtubeRegex) | lastLink.match(this.youtubeMiniRegex)) { dbot.api.link.getTitle(lastLink, function(title) { name = title.replace(' - YouTube', ''); this.api.spotifySearch(name, function(body, t) {