Skip to content

Commit

Permalink
fix: Fix loading thumbs for video playlists
Browse files Browse the repository at this point in the history
Fixes #97
  • Loading branch information
octfx committed Sep 10, 2024
1 parent 07e4fa3 commit f1434ea
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion resources/fetchers/fetchFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions resources/fetchers/niconico.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ const fetcher = function (url) {
const thumbMatcher = new RegExp(/<thumbnail_url>(.*)<\/thumbnail_url>/);
const durationMatcher = new RegExp(/<length>(.*)<\/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,
Expand Down
5 changes: 5 additions & 0 deletions resources/fetchers/oembed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down Expand Up @@ -82,6 +86,7 @@ module.exports = {
kakaotv,
loom,
youtube,
youtubeplaylist,
vimeo,
spotifyalbum,
spotifyartist,
Expand Down

0 comments on commit f1434ea

Please sign in to comment.