Skip to content

Commit

Permalink
feat: Add Wistia service
Browse files Browse the repository at this point in the history
Implements #79
  • Loading branch information
octfx committed Feb 24, 2024
1 parent 108cbb0 commit a4cdb46
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ As of version 3.x, EmbedVideo supports embedding video content from the followin
| [Spotify](http://spotify.com/) | `spotifytrack` - Song embed | 6ZFbXIJkuI1dVNWvzJzown | https://open.spotify.com/track/6ZFbXIJkuI1dVNWvzJzown |
| [Twitch](http://www.twitch.tv) | `twitch` - Live Streams | `twitchvod` - Archived Videos on Demand | twitchplayspokemon |
| [Vimeo](http://www.vimeo.com) | `vimeo` | 105035718 | http://vimeo.com/105035718 |
| [Wistia](http://wistia.com) | `wistia` | 62svuailn2 | https://softwareag-2.wistia.com/medias/62svuailn2 |
| [YouTube](http://www.youtube.com/) | `youtube` - Single Videos | pSsYTj9kCHE | https://www.youtube.com/watch?v=pSsYTj9kCHE |
| [YouTube](http://www.youtube.com/) | `youtubeplaylist` - Playlists | PLY0KbDiiFYeNgQkjujixr7qD-FS8qecoP | https://www.youtube.com/embed/?listType=playlist&list=PLY0KbDiiFYeNgQkjujixr7qD-FS8qecoP |
| [YouTube](http://www.youtube.com/) | `youtubevideolist` - Video List | pSsYTj9kCHE - urlargs=playlist=pSsYTj9kCHE,pSsYTj9kCHE | https://www.youtube.com/embed/pSsYTj9kCHE?playlist=pSsYTj9kCHE,pSsYTj9kCHE |
Expand Down
1 change: 1 addition & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"embedvideo-service-twitch": "Twitch",
"embedvideo-service-videolink": "Video Link",
"embedvideo-service-vimeo": "Vimeo",
"embedvideo-service-wistia": "Wistia",
"embedvideo-service-youtube": "YouTube",
"embedvideo-service-localvideo": "Local File",
"embedvideo-service-externalvideo": "External Video",
Expand Down
4 changes: 4 additions & 0 deletions includes/EmbedService/EmbedServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ final class EmbedServiceFactory {
TwitchVod::class,
VideoLink::class,
Vimeo::class,
Wistia::class,
YouTube::class,
YouTubeOEmbed::class,
YouTubePlaylist::class,
Expand Down Expand Up @@ -128,6 +129,9 @@ public static function newFromName( string $serviceName, string $id ): AbstractE
case 'vimeo':
return new Vimeo( $id );

case 'wistia':
return new Wistia( $id );

case 'youtubeoembed':
return new YouTubeOEmbed( $id );

Expand Down
50 changes: 50 additions & 0 deletions includes/EmbedService/Wistia.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare( strict_types=1 );

namespace MediaWiki\Extension\EmbedVideo\EmbedService;

final class Wistia extends AbstractEmbedService {

/**
* @inheritDoc
*/
public function getBaseUrl(): string {
return '//fast.wistia.net/embed/iframe/%1$s';
}

/**
* @inheritDoc
*/
protected function getUrlRegex(): array {
return [
'/(?:.+)?(?:wistia\.com|wi\.st)\/(?:medias|embed)\/(.*)/'
];
}

/**
* @inheritDoc
*/
protected function getIdRegex(): array {
return [
'#([\w]+)$#is'
];
}

/**
* @inheritDoc
*/
public function getPrivacyPolicyUrl(): ?string {
return 'https://wistia.com/privacy';
}

/**
* @inheritDoc
*/
public function getCSPUrls(): array {
return [
'https://wistia.com',
'https://fast.wistia.com',
];
}
}
3 changes: 3 additions & 0 deletions resources/fetchers/fetchFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const fetchFactory = function (service) {
case 'vimeo':
fetcher = oEmbedFetchers.vimeo;
break;
case 'wistia':
fetcher = oEmbedFetchers.wistia;
break;
case 'youtube':
case 'youtubevideolist':
case 'youtubeplaylist':
Expand Down
5 changes: 5 additions & 0 deletions resources/fetchers/oembed.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const ccc = function(url) {
return oembed('https://media.ccc.de/public/oembed?url=https://media.ccc.de/v/' + url);
};

const wistia = function(url) {
return oembed('http://fast.wistia.net/oembed?url=http://fast.wistia.net/embed/iframe/' + url);
};

const oembed = function(url) {
return fetch(url, {
credentials: "omit",
Expand Down Expand Up @@ -76,5 +80,6 @@ module.exports = {
spotifytrack,
soundcloud,
ccc,
wistia,
oembed,
};

0 comments on commit a4cdb46

Please sign in to comment.