Skip to content

Commit

Permalink
feat: Add Wistia / Spotify Shows / Episodes
Browse files Browse the repository at this point in the history
Implements #79
Implements #81
Implements #82
  • Loading branch information
octfx committed Feb 24, 2024
1 parent 6598098 commit 4df3b8a
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 20 deletions.
43 changes: 23 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,26 +260,29 @@ or

As of version 3.x, EmbedVideo supports embedding video content from the following services:

| Site | Service Name(s) | ID Example | URL Example(s) |
|----------------------------------------------------------|---------------------------------|--------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| [Archive.org Videos](https://archive.org/details/movies) | `archiveorg` | electricsheep-flock-244-80000-6 | https://archive.org/details/electricsheep-flock-244-80000-6<br/>https://archive.org/embed/electricsheep-flock-244-80000-6 |
| [Bandcamp](https://bandcamp.com/) | `bandcamp` | 1003592798 | https://emptyhousesmusic.bandcamp.com/album/empty-houses (Click on share/embed, and copy the id after `album=`) |
| [Bilibili](https://www.bilibili.com/) | `bilibili` | BV1Hz4y1k7ae | https://player.bilibili.com/player.html?bvid=1Hz4y1k7ae&amp;page=1 |
| [DailyMotion](https://dailymotion.com/) | `dailymotion` | x1adiiw_archer-waking-up-as-h-jon-benjamin_shortfilms | http://www.dailymotion.com/video/x1adiiw_archer-waking-up-as-h-jon-benjamin_shortfilms |
| [KakaoTV](https://tv.kakao.com/) | `kakaotv` | 301157950 | https://play-tv.kakao.com/embed/player/cliplink/301157950 |
| [Loom](https://www.loom.com/) | `loom` | e5b8c04bca094dd8a5507925ab887002 | https://www.loom.com/share/e5b8c04bca094dd8a5507925ab887002 |
| [NaverTV](https://tv.naver.com/) | `navertv` | 27831593 | https://tv.naver.com/embed/27831593 |
| [Niconico](http://nicovideo.jp/) | `niconico` | sm40807360 | https://embed.nicovideo.jp/watch/sm40807360 |
| SharePoint | `sharepoint` | Not Applicable | https://[SUB].sharepoint.com/sites/[PATH]/_layouts/15/embed.aspx?UniqueId=[ID]&embed=[...] |
| [SoundCloud](http://soundcloud.com/) | `soundcloud` | | https://soundcloud.com/skrillex/skrillex-rick-ross-purple-lamborghini |
| [Spotify](http://spotify.com/) | `spotifyalbum` - Art embed | 3B61kSKTxlY36cYgzvf3cP | https://open.spotify.com/album/3B61kSKTxlY36cYgzvf3cP |
| [Spotify](http://spotify.com/) | `spotifyartist` - Artist embed | 0YC192cP3KPCRWx8zr8MfZ | https://open.spotify.com/artist/0YC192cP3KPCRWx8zr8MfZ |
| [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 |
| [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 |
| Site | Service Name(s) | ID Example | URL Example(s) |
|----------------------------------------------------------|-------------------------------------|--------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| [Archive.org Videos](https://archive.org/details/movies) | `archiveorg` | electricsheep-flock-244-80000-6 | https://archive.org/details/electricsheep-flock-244-80000-6<br/>https://archive.org/embed/electricsheep-flock-244-80000-6 |
| [Bandcamp](https://bandcamp.com/) | `bandcamp` | 1003592798 | https://emptyhousesmusic.bandcamp.com/album/empty-houses (Click on share/embed, and copy the id after `album=`) |
| [Bilibili](https://www.bilibili.com/) | `bilibili` | BV1Hz4y1k7ae | https://player.bilibili.com/player.html?bvid=1Hz4y1k7ae&amp;page=1 |
| [DailyMotion](https://dailymotion.com/) | `dailymotion` | x1adiiw_archer-waking-up-as-h-jon-benjamin_shortfilms | http://www.dailymotion.com/video/x1adiiw_archer-waking-up-as-h-jon-benjamin_shortfilms |
| [KakaoTV](https://tv.kakao.com/) | `kakaotv` | 301157950 | https://play-tv.kakao.com/embed/player/cliplink/301157950 |
| [Loom](https://www.loom.com/) | `loom` | e5b8c04bca094dd8a5507925ab887002 | https://www.loom.com/share/e5b8c04bca094dd8a5507925ab887002 |
| [NaverTV](https://tv.naver.com/) | `navertv` | 27831593 | https://tv.naver.com/embed/27831593 |
| [Niconico](http://nicovideo.jp/) | `niconico` | sm40807360 | https://embed.nicovideo.jp/watch/sm40807360 |
| SharePoint | `sharepoint` | Not Applicable | https://[SUB].sharepoint.com/sites/[PATH]/_layouts/15/embed.aspx?UniqueId=[ID]&embed=[...] |
| [SoundCloud](http://soundcloud.com/) | `soundcloud` | | https://soundcloud.com/skrillex/skrillex-rick-ross-purple-lamborghini |
| [Spotify](http://spotify.com/) | `spotifyalbum` - Art embed | 3B61kSKTxlY36cYgzvf3cP | https://open.spotify.com/album/3B61kSKTxlY36cYgzvf3cP |
| [Spotify](http://spotify.com/) | `spotifyartist` - Artist embed | 0YC192cP3KPCRWx8zr8MfZ | https://open.spotify.com/artist/0YC192cP3KPCRWx8zr8MfZ |
| [Spotify](http://spotify.com/) | `spotifytrack` - Song embed | 6ZFbXIJkuI1dVNWvzJzown | https://open.spotify.com/track/6ZFbXIJkuI1dVNWvzJzown |
| [Spotify](http://spotify.com/) | `spotifyshow` - Podcasts / Shows | 7AWhoFQ3SIkEc6Yp1aOiIM | https://open.spotify.com/show/7AWhoFQ3SIkEc6Yp1aOiIM |
| [Spotify](http://spotify.com/) | `spotifyepisode` - Podcast episodes | 11mET6sr9ghOJ6mi4lmZmZ | https://open.spotify.com/episode/11mET6sr9ghOJ6mi4lmZmZ |
| [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 |

### New Services
New services can be requested by using the following [link](https://github.com/StarCitizenWiki/mediawiki-extensions-EmbedVideo/issues/new?assignees=&labels=enhancement&template=embed-service-request.md&title=Embed+Service+Request%3A+Service+Name) or clicking `New Issue`.
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
16 changes: 16 additions & 0 deletions includes/EmbedService/EmbedServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use InvalidArgumentException;
use MediaWiki\Extension\EmbedVideo\EmbedService\Spotify\SpotifyAlbum;
use MediaWiki\Extension\EmbedVideo\EmbedService\Spotify\SpotifyArtist;
use MediaWiki\Extension\EmbedVideo\EmbedService\Spotify\SpotifyEpisode;
use MediaWiki\Extension\EmbedVideo\EmbedService\Spotify\SpotifyShow;
use MediaWiki\Extension\EmbedVideo\EmbedService\Spotify\SpotifyTrack;
use MediaWiki\Extension\EmbedVideo\EmbedService\Twitch\Twitch;
use MediaWiki\Extension\EmbedVideo\EmbedService\Twitch\TwitchClip;
Expand Down Expand Up @@ -38,12 +40,15 @@ final class EmbedServiceFactory {
SoundCloud::class,
SpotifyAlbum::class,
SpotifyArtist::class,
SpotifyShow::class,
SpotifyEpisode::class,
SpotifyTrack::class,
Twitch::class,
TwitchClip::class,
TwitchVod::class,
VideoLink::class,
Vimeo::class,
Wistia::class,
YouTube::class,
YouTubeOEmbed::class,
YouTubePlaylist::class,
Expand Down Expand Up @@ -113,6 +118,14 @@ public static function newFromName( string $serviceName, string $id ): AbstractE
case 'spotifytrack':
return new SpotifyTrack( $id );

case 'spotifypodcast':
case 'spotifyshow':
return new SpotifyShow( $id );

case 'spotifypodcastepisode':
case 'spotifyepisode':
return new SpotifyEpisode( $id );

case 'twitch':
return new Twitch( $id );

Expand All @@ -128,6 +141,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
23 changes: 23 additions & 0 deletions includes/EmbedService/Spotify/SpotifyEpisode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare( strict_types=1 );

namespace MediaWiki\Extension\EmbedVideo\EmbedService\Spotify;

class SpotifyEpisode extends SpotifyAlbum {
/**
* @inheritDoc
*/
public function getBaseUrl(): string {
return 'https://open.spotify.com/episode/%1$s';
}

/**
* @inheritDoc
*/
protected function getUrlRegex(): array {
return [
'#open\.spotify\.com/episode/([a-zA-Z0-9]+)#is',
];
}
}
23 changes: 23 additions & 0 deletions includes/EmbedService/Spotify/SpotifyShow.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare( strict_types=1 );

namespace MediaWiki\Extension\EmbedVideo\EmbedService\Spotify;

class SpotifyShow extends SpotifyAlbum {
/**
* @inheritDoc
*/
public function getBaseUrl(): string {
return 'https://open.spotify.com/show/%1$s';
}

/**
* @inheritDoc
*/
protected function getUrlRegex(): array {
return [
'#open\.spotify\.com/show/([a-zA-Z0-9]+)#is',
];
}
}
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',
];
}
}
9 changes: 9 additions & 0 deletions resources/fetchers/fetchFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,18 @@ const fetchFactory = function (service) {
case 'spotifytrack':
fetcher = oEmbedFetchers.spotifytrack;
break;
case 'spotifyshow':
fetcher = oEmbedFetchers.spotifyshow;
break;
case 'spotifyepisode':
fetcher = oEmbedFetchers.spotifyepisode;
break;
case 'vimeo':
fetcher = oEmbedFetchers.vimeo;
break;
case 'wistia':
fetcher = oEmbedFetchers.wistia;
break;
case 'youtube':
case 'youtubevideolist':
case 'youtubeplaylist':
Expand Down
15 changes: 15 additions & 0 deletions resources/fetchers/oembed.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ const spotifytrack = function(url) {
return oembed('https://open.spotify.com/oembed?url=https://open.spotify.com/track/' + url);
};

const spotifyepisode = function(url) {
return oembed('https://open.spotify.com/oembed?url=https://open.spotify.com/episode/' + url);
};

const spotifyshow = function(url) {
return oembed('https://open.spotify.com/oembed?url=https://open.spotify.com/show/' + url);
};

const soundcloud = function(url) {
const queryParser = require('./queryKeyParser.js').queryKeyParser;

Expand All @@ -41,6 +49,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 @@ -73,8 +85,11 @@ module.exports = {
vimeo,
spotifyalbum,
spotifyartist,
spotifyepisode,
spotifyshow,
spotifytrack,
soundcloud,
ccc,
wistia,
oembed,
};

0 comments on commit 4df3b8a

Please sign in to comment.