From 326a82ad8fa1fa3f95dd73cd2553bba9af07f905 Mon Sep 17 00:00:00 2001
From: moo <34907770+moo-the-cow@users.noreply.github.com>
Date: Mon, 18 Apr 2022 09:50:44 +0200
Subject: [PATCH 1/2] added twitch clips plugin
---
src/js/plugins.js | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/src/js/plugins.js b/src/js/plugins.js
index 7e8a15a..3aa5d21 100644
--- a/src/js/plugins.js
+++ b/src/js/plugins.js
@@ -230,6 +230,29 @@ plugins.factory('userPlugins', function() {
return element.prop('outerHTML');
}
});
+
+ /*
+ * Twitch Clips Embedded Player
+ *
+ * See: https://dev.twitch.tv/docs/embed/video-and-clips/#non-interactive-iframes-for-clips
+ */
+
+ var twitchClipsPlugin = new UrlPlugin('TwitchClips video', function(url) {
+ var regex = /(?:https?:\/\/)?clips\.twitch\.tv\/([^\?\&\/\s]+)/i,
+ match = url.match(regex);
+
+ if (match){
+ var clipId = match[1];
+ var embedurl = "https://clips.twitch.tv/embed?clip=" + clipId + "&parent=" + window.location.hostname;
+
+ var element = angular.element('')
+ .attr('src', embedurl)
+ .attr('width', '560')
+ .attr('height', '315')
+ .attr('allowfullscreen', 'true');
+ return element.prop('outerHTML');
+ }
+ });
/*
* Dailymotion Embedded Player
@@ -590,7 +613,7 @@ plugins.factory('userPlugins', function() {
});
return {
- plugins: [youtubePlugin, dailymotionPlugin, allocinePlugin, imagePlugin, videoPlugin, audioPlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, gistPlugin, pastebinPlugin, giphyPlugin, tweetPlugin, streamablePlugin, tikTokPlugin]
+ plugins: [youtubePlugin, twitchClipsPlugin, dailymotionPlugin, allocinePlugin, imagePlugin, videoPlugin, audioPlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, gistPlugin, pastebinPlugin, giphyPlugin, tweetPlugin, streamablePlugin, tikTokPlugin]
};
From bf47792b6713ca4f4bd459c567318783db2d5fec Mon Sep 17 00:00:00 2001
From: moo <34907770+moo-the-cow@users.noreply.github.com>
Date: Mon, 18 Apr 2022 14:03:48 +0200
Subject: [PATCH 2/2] added embedded videos,streams,clips for twitch
---
src/js/plugins.js | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/src/js/plugins.js b/src/js/plugins.js
index 3aa5d21..e7421f8 100644
--- a/src/js/plugins.js
+++ b/src/js/plugins.js
@@ -232,12 +232,12 @@ plugins.factory('userPlugins', function() {
});
/*
- * Twitch Clips Embedded Player
+ * Twitch Embedded Player
*
* See: https://dev.twitch.tv/docs/embed/video-and-clips/#non-interactive-iframes-for-clips
*/
- var twitchClipsPlugin = new UrlPlugin('TwitchClips video', function(url) {
+ var twitchPlugin = new UrlPlugin('Twitch video', function(url) {
var regex = /(?:https?:\/\/)?clips\.twitch\.tv\/([^\?\&\/\s]+)/i,
match = url.match(regex);
@@ -251,6 +251,23 @@ plugins.factory('userPlugins', function() {
.attr('height', '315')
.attr('allowfullscreen', 'true');
return element.prop('outerHTML');
+ }
+
+ var regex = /(?:https?:(?:\/\/www\.)?)?twitch\.tv\/(?:videos\/(\d+)|(\w+))/i,
+ match = url.match(regex);
+ if (match) {
+ var mediaType = "video";
+ if(match[1] === undefined) {
+ mediaType = "channel";
+ }
+ var mediaId = match[1] === undefined ? match[2] : match[1];
+ var embedurl = "https://player.twitch.tv/?" + mediaType + "=" + mediaId + "&parent=" + window.location.hostname + "&autoplay=false&muted=true";
+ var element = angular.element('')
+ .attr('src', embedurl)
+ .attr('width', '560')
+ .attr('height', '315')
+ .attr('allowfullscreen', 'true');
+ return element.prop('outerHTML');
}
});
@@ -613,7 +630,7 @@ plugins.factory('userPlugins', function() {
});
return {
- plugins: [youtubePlugin, twitchClipsPlugin, dailymotionPlugin, allocinePlugin, imagePlugin, videoPlugin, audioPlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, gistPlugin, pastebinPlugin, giphyPlugin, tweetPlugin, streamablePlugin, tikTokPlugin]
+ plugins: [youtubePlugin, twitchPlugin, dailymotionPlugin, allocinePlugin, imagePlugin, videoPlugin, audioPlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, gistPlugin, pastebinPlugin, giphyPlugin, tweetPlugin, streamablePlugin, tikTokPlugin]
};