From f1434ea9769e34d3dcaab1b2df46b360a4524152 Mon Sep 17 00:00:00 2001 From: "H. C. Kruse" Date: Tue, 10 Sep 2024 15:10:32 +0200 Subject: [PATCH] fix: Fix loading thumbs for video playlists Fixes #97 --- README.md | 1 + resources/fetchers/fetchFactory.js | 5 ++++- resources/fetchers/niconico.js | 5 ----- resources/fetchers/oembed.js | 5 +++++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 582ad7c..e019e8a 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,7 @@ Note that this implementation differs from EmbedVideo v2.x in the following area * In the old implementation nothing was shown * No `style` attribute can be set * Video lists are not supported +* This currently disregards `$wgEmbedVideoFetchExternalThumbnails` and will fetch thumbnails upon clicking a link ### Example ```mediawiki diff --git a/resources/fetchers/fetchFactory.js b/resources/fetchers/fetchFactory.js index 9721043..3885abb 100644 --- a/resources/fetchers/fetchFactory.js +++ b/resources/fetchers/fetchFactory.js @@ -48,9 +48,12 @@ const fetchFactory = function (service) { fetcher = oEmbedFetchers.wistia; break; case 'youtube': + fetcher = oEmbedFetchers.youtube; + break; case 'youtubevideolist': case 'youtubeplaylist': - fetcher = oEmbedFetchers.youtube; + urlManipulation = false; + fetcher = oEmbedFetchers.youtubeplaylist; break; // Missing CORS diff --git a/resources/fetchers/niconico.js b/resources/fetchers/niconico.js index ddfb4cb..baa7e2e 100644 --- a/resources/fetchers/niconico.js +++ b/resources/fetchers/niconico.js @@ -22,11 +22,6 @@ const fetcher = function (url) { const thumbMatcher = new RegExp(/(.*)<\/thumbnail_url>/); const durationMatcher = new RegExp(/(.*)<\/length>/); - console.log(text); - console.log(titleMatcher.match(text)); - console.log(thumbMatcher.match(text)); - console.log(durationMatcher.match(text)); - return { title: titleMatcher.match(text) ? titleMatcher.match(text)[1] : null, thumbnail: thumbMatcher.match(text) ? thumbMatcher.match(text)[1] : null, diff --git a/resources/fetchers/oembed.js b/resources/fetchers/oembed.js index 5a068b8..078d157 100644 --- a/resources/fetchers/oembed.js +++ b/resources/fetchers/oembed.js @@ -2,6 +2,10 @@ const youtube = function(url) { return oembed('https://www.youtube-nocookie.com/oembed?url=https://www.youtube.com/watch?v=' + url); }; +const youtubeplaylist = function(url) { + return oembed('https://www.youtube-nocookie.com/oembed?url=' + url); +}; + const vimeo = function(url) { return oembed('https://vimeo.com/api/oembed.json?url=https://vimeo.com/' + url); }; @@ -82,6 +86,7 @@ module.exports = { kakaotv, loom, youtube, + youtubeplaylist, vimeo, spotifyalbum, spotifyartist,