Skip to content

Commit

Permalink
feat: Add Spotify Shows / Episodes
Browse files Browse the repository at this point in the history
Implements #81
Implements #82
  • Loading branch information
octfx committed Feb 24, 2024
1 parent a4cdb46 commit c83bf37
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 21 deletions.
44 changes: 23 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,27 +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 |
| [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 |
| 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
12 changes: 12 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,6 +40,8 @@ final class EmbedServiceFactory {
SoundCloud::class,
SpotifyAlbum::class,
SpotifyArtist::class,
SpotifyShow::class,
SpotifyEpisode::class,
SpotifyTrack::class,
Twitch::class,
TwitchClip::class,
Expand Down Expand Up @@ -114,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 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',
];
}
}
6 changes: 6 additions & 0 deletions resources/fetchers/fetchFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ 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;
Expand Down
10 changes: 10 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 Down Expand Up @@ -77,6 +85,8 @@ module.exports = {
vimeo,
spotifyalbum,
spotifyartist,
spotifyepisode,
spotifyshow,
spotifytrack,
soundcloud,
ccc,
Expand Down

0 comments on commit c83bf37

Please sign in to comment.