diff --git a/js/plugins.js b/js/plugins.js index 1880d3e..73d9c13 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -127,6 +127,29 @@ plugins.factory('userPlugins', function() { var urlRegexp = RegExp(/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/); + /* + * Spotify Embedded Player + * + * See: https://developer.spotify.com/technologies/widgets/spotify-play-button/ + * + */ + + var spotifyPlugin = new Plugin(function(message) { + var addMatch = function(match) { + var ret = ''; + for(i in match) { + var id = match[i].substr(match[i].length-22, match[i].length); + ret += ''; + } + return ret; + }; + var match = message.match(/spotify:track:([a-zA-Z-0-9]{22})/g); + var ret = addMatch(match); + ret += addMatch(message.match(/open.spotify.com\/track\/([a-zA-Z-0-9]{22})/g)); + return ret; + }); + spotifyPlugin.name = 'Spotify track' + /* * YouTube Embedded Player * @@ -172,6 +195,6 @@ plugins.factory('userPlugins', function() { imagePlugin.name = 'image'; return { - plugins: [youtubePlugin, imagePlugin] + plugins: [youtubePlugin, imagePlugin, spotifyPlugin] } });