Skip to content

Commit a4372fc

Browse files
committed
Merge branch 'release/v3.0.9'
2 parents a274f46 + 47bf756 commit a4372fc

14 files changed

+232
-75
lines changed

.phpcs.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPrivate" />
55
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationProtected" />
66
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPublic" />
7+
<exclude name="MediaWiki.Commenting.FunctionComment.ParamPassByReference" />
78
</rule>
89
<file>.</file>
910
<arg name="extensions" value="php"/>

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -221,18 +221,20 @@ or
221221

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

224-
| Site | Service Name(s) | ID Example | URL Example(s) |
225-
|----------------------------------------------------------|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|
226-
| [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 |
227-
| [SoundCloud](http://soundcloud.com/) | `soundcloud` | | https://soundcloud.com/skrillex/skrillex-rick-ross-purple-lamborghini |
228-
| [Spotify](http://spotify.com/) | `spotifyalbum` - Album embed | 1EoDsNmgTLtmwe1BDAVxV5 | https://open.spotify.com/album/1EoDsNmgTLtmwe1BDAVxV5 |
229-
| [Spotify](http://spotify.com/) | `spotifyartist` - Artist embed | 06HL4z0CvFAxyc27GXpf02 | https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02 |
230-
| [Spotify](http://spotify.com/) | `spotifytrack` - Song embed | 72jCZdH0Lhg93z6Z4hBjgj | https://open.spotify.com/track/72jCZdH0Lhg93z6Z4hBjgj |
231-
| [Twitch](http://www.twitch.tv) | `twitch` - Live Streams | `twitchvod` - Archived Videos on Demand | twitchplayspokemon |
232-
| [Vimeo](http://www.vimeo.com) | `vimeo` | 105035718 | http://vimeo.com/105035718 |
233-
| [YouTube](http://www.youtube.com/) | `youtube` - Single Videos | pSsYTj9kCHE | https://www.youtube.com/watch?v=pSsYTj9kCHE |
234-
| [YouTube](http://www.youtube.com/) | `youtubeplaylist` - Playlists | PLY0KbDiiFYeNgQkjujixr7qD-FS8qecoP | https://www.youtube.com/embed/?listType=playlist&list=PLY0KbDiiFYeNgQkjujixr7qD-FS8qecoP |
235-
| [YouTube](http://www.youtube.com/) | `youtubevideolist` - Video List | pSsYTj9kCHE - urlargs=playlist=pSsYTj9kCHE,pSsYTj9kCHE | https://www.youtube.com/embed/pSsYTj9kCHE?playlist=pSsYTj9kCHE,pSsYTj9kCHE |
224+
| Site | Service Name(s) | ID Example | URL Example(s) |
225+
|----------------------------------------------------------|---------------------------------|--------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
226+
| [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 |
227+
| [Bilibili](https://www.bilibili.com/) | `bilibili` | BV1Hz4y1k7ae | https://player.bilibili.com/player.html?bvid=1Hz4y1k7ae&amp;page=1 |
228+
| [Niconico](http://nicovideo.jp/) | `niconico` | sm40807360 | https://embed.nicovideo.jp/watch/sm40807360 |
229+
| [SoundCloud](http://soundcloud.com/) | `soundcloud` | | https://soundcloud.com/skrillex/skrillex-rick-ross-purple-lamborghini |
230+
| [Spotify](http://spotify.com/) | `spotifyalbum` - Album embed | 1EoDsNmgTLtmwe1BDAVxV5 | https://open.spotify.com/album/1EoDsNmgTLtmwe1BDAVxV5 |
231+
| [Spotify](http://spotify.com/) | `spotifyartist` - Artist embed | 06HL4z0CvFAxyc27GXpf02 | https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02 |
232+
| [Spotify](http://spotify.com/) | `spotifytrack` - Song embed | 72jCZdH0Lhg93z6Z4hBjgj | https://open.spotify.com/track/72jCZdH0Lhg93z6Z4hBjgj |
233+
| [Twitch](http://www.twitch.tv) | `twitch` - Live Streams | `twitchvod` - Archived Videos on Demand | twitchplayspokemon |
234+
| [Vimeo](http://www.vimeo.com) | `vimeo` | 105035718 | http://vimeo.com/105035718 |
235+
| [YouTube](http://www.youtube.com/) | `youtube` - Single Videos | pSsYTj9kCHE | https://www.youtube.com/watch?v=pSsYTj9kCHE |
236+
| [YouTube](http://www.youtube.com/) | `youtubeplaylist` - Playlists | PLY0KbDiiFYeNgQkjujixr7qD-FS8qecoP | https://www.youtube.com/embed/?listType=playlist&list=PLY0KbDiiFYeNgQkjujixr7qD-FS8qecoP |
237+
| [YouTube](http://www.youtube.com/) | `youtubevideolist` - Video List | pSsYTj9kCHE - urlargs=playlist=pSsYTj9kCHE,pSsYTj9kCHE | https://www.youtube.com/embed/pSsYTj9kCHE?playlist=pSsYTj9kCHE,pSsYTj9kCHE |
236238

237239
### New Services
238240
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`.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "starcitizenwiki/embedvideo",
3-
"version": "3.0.8",
3+
"version": "3.0.9",
44
"type": "mediawiki-extension",
55
"description": "Adds a parser function embedding video from popular sources.",
66
"license": "MIT",

extension.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "EmbedVideo",
3-
"version": "3.0.8",
3+
"version": "3.0.9",
44
"author": [
5+
"Octfx",
6+
"Alistair3149",
57
"Jim R. Wilson",
68
"Andrew Whitworth",
79
"Alexia E. Smith",
8-
"Cameron M. Chunn",
9-
"Octfx",
10-
"Alistair3149"
10+
"Cameron M. Chunn"
1111
],
1212
"url": "https://github.com/StarCitizenWiki/mediawiki-extensions-EmbedVideo",
1313
"descriptionmsg": "embedvideo-description",

i18n/he.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
{
22
"@metadata": {
33
"authors": [
4+
"Amire80",
45
"Nimrod Rak"
56
]
67
},
7-
"embedvideo-description": "הגרסה ה-forked הזו מוסיפה פונקציית מעבד להטמעת סרטונים ממקורות פופולריים.",
8-
"embedvideo-error-missingparams": "ל-EmbedVideo חסר פרמטר חובה.",
8+
"embedvideo-description": "הגרסה החלופית (forked) הזאת מוסיפה פונקציית מפענח להטבעת סרטונים ממקורות פופולריים.",
9+
"embedvideo-play": "לנגן סרטון",
10+
"embedvideo-error-missingparams": "ל־EmbedVideo חסר פרמטר חובה.",
911
"embedvideo-error-service": "EmbedVideo לא מזהה את שירות הסרטונים \"$1\".",
10-
"embedvideo-error-id": "EmbedVideo קיבל id רע \"$2\" עבור השרות \"$1\".",
11-
"embedvideo-error-alignment": "EmbedVideo קיבל ערך לא חוקי עבור הפרמטר alignment \"$1\". הערכים החוקיים הם \"left\", \"center\", \"right\" או \"inline\".",
12-
"embedvideo-error-valignment": "EmbedVideo קיבל ערך לא חוקי עבור הפרמטר valignment \"$1\". הערכים החוקיים הם \"top\", \"middle\", \"bottom\" או \"baseline\".",
12+
"embedvideo-error-id": "EmbedVideo קיבל מזהה רע \"$2\" עבור השירות \"$1\".",
13+
"embedvideo-error-alignment": "EmbedVideo קיבל ערך לא תקין עבור הפרמטר alignment \"$1\". הערכים התקינים הם \"left\", \"center\", \"right\" או \"inline\".",
14+
"embedvideo-error-valignment": "EmbedVideo קיבל ערך לא תקין עבור הפרמטר valignment \"$1\". הערכים התקינים הם \"top\", \"middle\", \"bottom\" או \"baseline\".",
1315
"embedvideo-error-urlargs": "EmbedVideo קיבל רשימה של ארגומנטי URL שהכילו מידע פגום או ארגומנטים ריקים.",
14-
"embedvideo-error-unknown": "EmbedVideo נתקל בשגיאה לא ידועה כשניסה לייצר את בלוק הטמעת הסרטון הזה. ($1)",
16+
"embedvideo-error-unknown": "EmbedVideo נתקל בשגיאה לא ידועה כשניסה לייצר את בלוק הטבעת הסרטון הזה. ($1)",
1517
"apihelp-embedvideo-summary": "קבל קוד הטמעת סרטון עבור הפרמטרים שהתקבלו.",
1618
"apihelp-embedvideo-param-service": "שם השירות (youtube, twitch וכו')",
1719
"apihelp-embedvideo-param-dimensions": "רוחב נומרי (100) או רוחב לפי גובה (100x100)",

i18n/zh-hant.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"@metadata": {
33
"authors": [
4-
"Kly"
4+
"Kly",
5+
"Lakejason0"
56
]
67
},
78
"embedvideo-description": "此分叉版本添加可用於內嵌來自熱門來源的影片之解析功能。",
@@ -16,7 +17,7 @@
1617
"embedvideo-error-valignment": "給予了 EmbedVideo 直向調準參數「$1」一個無效的值。有效值為「top」、「middle」、「bottom」、或是「baseline」。",
1718
"embedvideo-error-urlargs": "EmbedVideo 接收到包含異常資料或是引數為空白的 URL 引數清單。",
1819
"embedvideo-error-unknown": "EmbedVideo 在嘗試產生影片內嵌區塊時發生未知錯誤。($1)",
19-
"embedvideo-error-evp_deprecated": "#evp 解析函式在 EmbedVideo 2.0 已棄用。請將您的解析函式標籤轉換成 #ev。",
20+
"embedvideo-error-evp_deprecated": "#evp 解析器函數在 EmbedVideo 2.0 已棄用。請將您的解析器函數標籤轉換成 #ev。",
2021
"embedvideo-error-container": "提供給「container」的參數無效。",
2122
"embedvideo-video-long-desc": "$1,編解碼器 $2,長度 $3,$4 x $5 像素,總體 $6",
2223
"embedvideo-audio-long-desc": "$1,編解碼器 $2,長度 $3,總體 $4",

includes/EmbedService/AbstractEmbedService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public function setHeight( $height = null ): void {
247247

248248
$ratio = $this->getAspectRatio() ?? ( 16 / 9 );
249249

250-
$this->height = round( $this->getWidth() / $ratio );
250+
$this->height = round( (int)$this->getWidth() / $ratio );
251251
}
252252

253253
/**

includes/EmbedService/Bilibili.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
declare( strict_types=1 );
4+
5+
namespace MediaWiki\Extension\EmbedVideo\EmbedService;
6+
7+
final class Bilibili extends AbstractEmbedService {
8+
/**
9+
* @inheritDoc
10+
*/
11+
public function getBaseUrl(): string {
12+
return '//player.bilibili.com/player.html?bvid=%1$s';
13+
}
14+
15+
/**
16+
* @inheritDoc
17+
*/
18+
public function getAspectRatio(): ?float {
19+
return 16 / 9;
20+
}
21+
22+
/**
23+
* @inheritDoc
24+
*/
25+
protected function getDefaultWidth(): int {
26+
return 640;
27+
}
28+
29+
/**
30+
* @inheritDoc
31+
*/
32+
protected function getDefaultHeight(): int {
33+
return 360;
34+
}
35+
36+
/**
37+
* @inheritDoc
38+
*/
39+
protected function getUrlRegex(): array {
40+
return [
41+
'#bilibili\.com/(?:BV|AV)([\d\w]+)#is',
42+
];
43+
}
44+
45+
/**
46+
* @inheritDoc
47+
*/
48+
protected function getIdRegex(): array {
49+
return [
50+
'#^(?:BV|AV)([\d\w]+)$#is',
51+
];
52+
}
53+
54+
/**
55+
* @inheritDoc
56+
*/
57+
public function getCSPUrls(): array {
58+
return [
59+
'https://bilibili.com',
60+
'https://player.bilibili.com',
61+
];
62+
}
63+
64+
/**
65+
* Add '&page=1' if not set through parser
66+
*
67+
* @return string
68+
*/
69+
public function getUrl(): string {
70+
$page = 'page=1';
71+
if ( $this->getUrlArgs() !== false ) {
72+
$page = $this->getUrlArgs();
73+
}
74+
75+
return sprintf( '%s&%s', parent::getUrl(), $page );
76+
}
77+
}

includes/EmbedService/EmbedHtmlFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static function toHtml( AbstractEmbedService $service, array $config = []
3434
return self::makeIframe( $service );
3535
}
3636

37-
$width = $service->getWidth();
37+
$width = (int)$service->getWidth();
3838
$widthPad = $width + 8;
3939

4040
$config = array_merge(

includes/EmbedService/EmbedServiceFactory.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ final class EmbedServiceFactory {
2525
*/
2626
private static $availableServices = [
2727
ArchiveOrg::class,
28+
Bilibili::class,
29+
Niconico::class,
2830
SoundCloud::class,
2931
SpotifyAlbum::class,
3032
SpotifyArtist::class,
@@ -49,6 +51,13 @@ public static function newFromName( string $serviceName, string $id ): AbstractE
4951
case 'archiveorg':
5052
return new ArchiveOrg( $id );
5153

54+
case 'bilibili':
55+
return new Bilibili( $id );
56+
57+
case 'nicovideo':
58+
case 'niconico':
59+
return new Niconico( $id );
60+
5261
case 'soundcloud':
5362
return new SoundCloud( $id );
5463

includes/EmbedService/Niconico.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
declare( strict_types=1 );
4+
5+
namespace MediaWiki\Extension\EmbedVideo\EmbedService;
6+
7+
final class Niconico extends AbstractEmbedService {
8+
/**
9+
* @inheritDoc
10+
*/
11+
public function getBaseUrl(): string {
12+
return '//embed.nicovideo.jp/watch/%1$s';
13+
}
14+
15+
/**
16+
* @inheritDoc
17+
*/
18+
public function getAspectRatio(): ?float {
19+
return 16 / 9;
20+
}
21+
22+
/**
23+
* @inheritDoc
24+
*/
25+
protected function getDefaultWidth(): int {
26+
return 640;
27+
}
28+
29+
/**
30+
* @inheritDoc
31+
*/
32+
protected function getDefaultHeight(): int {
33+
return 360;
34+
}
35+
36+
/**
37+
* @inheritDoc
38+
*/
39+
protected function getUrlRegex(): array {
40+
return [
41+
'#nicovideo\.jp/watch/((?:[a-zA-Z]{2})?[\d]+)#is',
42+
];
43+
}
44+
45+
/**
46+
* @inheritDoc
47+
*/
48+
protected function getIdRegex(): array {
49+
return [
50+
'#^((?:[a-zA-Z]{2})?[\d]+)$#is',
51+
];
52+
}
53+
54+
/**
55+
* @inheritDoc
56+
*/
57+
public function getCSPUrls(): array {
58+
return [
59+
'https://www.nicovideo.jp',
60+
'https://embed.nicovido.jp',
61+
];
62+
}
63+
}

includes/EmbedService/Twitch/TwitchClip.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ protected function getUrlRegex(): array {
2222
];
2323
}
2424

25-
public function getCSPUrls(): array
26-
{
25+
/**
26+
* @inheritDoc
27+
*/
28+
public function getCSPUrls(): array {
2729
return [
2830
'https://player.twitch.tv',
2931
'https://clips.twitch.tv',

includes/Media/AudioHandler.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ public function parseTimeString( $time ) {
9797
/**
9898
* Merge a parameter array into a string appropriate for inclusion in filenames
9999
*
100-
* @param array $parameters Array of parameters that have been through normaliseParams.
100+
* @param array $params Array of parameters that have been through normaliseParams.
101101
* @return string
102102
*/
103-
public function makeParamString( $parameters ): string {
103+
public function makeParamString( $params ): string {
104104
// Width does not matter to video or audio.
105105
return '';
106106
}
@@ -121,34 +121,34 @@ public function parseParamString( $string ): array {
121121
* Should be idempotent.
122122
* Returns false if the parameters are unacceptable and the transform should fail
123123
*
124-
* @param stdClass|File $file
125-
* @param array &$parameters
124+
* @param stdClass|File $image
125+
* @param array $params
126126
* @return bool Success
127127
*/
128-
public function normaliseParams( $file, &$parameters ): bool {
128+
public function normaliseParams( $image, &$params ): bool {
129129
global $wgEmbedVideoDefaultWidth;
130130

131-
if ( isset( $parameters['width'] ) && $parameters['width'] > 0 ) {
132-
$parameters['width'] = (int)$parameters['width'];
131+
if ( isset( $params['width'] ) && $params['width'] > 0 ) {
132+
$params['width'] = (int)$params['width'];
133133
} else {
134-
$parameters['width'] = $wgEmbedVideoDefaultWidth;
134+
$params['width'] = $wgEmbedVideoDefaultWidth;
135135
}
136136

137-
if ( isset( $parameters['start'] ) ) {
138-
$parameters['start'] = $this->parseTimeString( $parameters['start'] );
139-
if ( $parameters['start'] === false ) {
140-
unset( $parameters['start'] );
137+
if ( isset( $params['start'] ) ) {
138+
$params['start'] = $this->parseTimeString( $params['start'] );
139+
if ( $params['start'] === false ) {
140+
unset( $params['start'] );
141141
}
142142
}
143143

144-
if ( isset( $parameters['end'] ) ) {
145-
$parameters['end'] = $this->parseTimeString( $parameters['end'] );
146-
if ( $parameters['end'] === false ) {
147-
unset( $parameters['end'] );
144+
if ( isset( $params['end'] ) ) {
145+
$params['end'] = $this->parseTimeString( $params['end'] );
146+
if ( $params['end'] === false ) {
147+
unset( $params['end'] );
148148
}
149149
}
150150

151-
$parameters['page'] = 1;
151+
$params['page'] = 1;
152152

153153
return true;
154154
}

0 commit comments

Comments
 (0)