Jack Phoenix has uploaded a new change for review.
https://gerrit.wikimedia.org/r/275271
Change subject: [WIP/EXPERIMENTAL] Version 1.5.3 -- use HTML5 instead of Flash
for YouTube videos
......................................................................
[WIP/EXPERIMENTAL] Version 1.5.3 -- use HTML5 instead of Flash for YouTube
videos
Also improved YouTube embedding support so that it *theoretically*
supports YouTube's short "youtu.be" share URLs.
Code sorta copypasted from the YouTube extension, but then again I also
played a part in getting that code there in the first place.
Change-Id: I0f051bcfe9fb9d4d33b2e60c416a127681a5e18d
---
M Video.php
M extension.json
M providers/YouTubeVideo.php
3 files changed, 29 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Video
refs/changes/71/275271/1
diff --git a/Video.php b/Video.php
index 768d8b2..c6b04e6 100644
--- a/Video.php
+++ b/Video.php
@@ -15,7 +15,7 @@
// Extension credits that show up on Special:Version
$wgExtensionCredits['other'][] = array(
'name' => 'Video',
- 'version' => '1.5.3',
+ 'version' => '1.5.4',
'author' => array( 'David Pean', 'Jack Phoenix', 'John Du Hart' ),
'description' => 'Allows new Video namespace for embeddable media on
supported sites',
'url' => 'https://www.mediawiki.org/wiki/Extension:Video',
diff --git a/extension.json b/extension.json
index 4692c93..fc83163 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
{
"name": "Video",
- "version": "1.5.3",
+ "version": "1.5.4",
"author": [
"David Pean",
"Jack Phoenix",
diff --git a/providers/YouTubeVideo.php b/providers/YouTubeVideo.php
index c77f2fe..e544511 100644
--- a/providers/YouTubeVideo.php
+++ b/providers/YouTubeVideo.php
@@ -2,16 +2,40 @@
class YouTubeVideoProvider extends BaseVideoProvider {
- protected $videoIdRegex = '/.*v=([A-Za-z0-9-_]+).*/';
+ // @see
http://linuxpanda.wordpress.com/2013/07/24/ultimate-best-regex-pattern-to-get-grab-parse-youtube-video-id-from-any-youtube-link-url/
+ protected $videoIdRegex =
'~(?:http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[a-z0-9;:@?&%=+\/\$_.-]*~i';
- protected $embedTemplate = '<object width="$width"
height="$height"><param name="movie"
value="http://www.youtube.com/v/$video_id&fs=1"></param><param name="wmode"
value="transparent"></param><param name="allowFullScreen"
value="true"></param><embed src="http://www.youtube.com/v/$video_id&fs=1"
type="application/x-shockwave-flash" wmode="transparent" allowFullScreen="true"
width="$width" height="$height"></embed></object>';
+ protected $embedTemplate = '<iframe width="$width" height="$height"
src="https://www.youtube.com/embed/$video_id" frameborder="0"
allowfullscreen></iframe>';
protected function getRatio() {
- return 425 / 355;
+ return 560 / 315;
+ }
+
+ /**
+ * Function to extract the video ID
+ *
+ * @param string $url Video URL
+ * @return string Video ID
+ */
+ protected function extractVideoId( $url ) {
+ $matches = array();
+
+ if ( preg_match( $this->videoIdRegex, $url, $matches ) ) {
+ $this->videoId = $matches[1];
+ } elseif ( preg_match( '/([0-9A-Za-z_-]+)/', $url, $matches ) )
{
+ $this->videoId = $matches[1];
+ }
+
+ if ( isset( $this->videoId ) && $this->videoID !== null ) {
+ return $this->videoId;
+ } else {
+ return null;
+ }
}
public static function getDomains() {
return array(
+ 'youtu.be',
'youtube.com',
// YouTube's "enhanced privacy mode", in which "YouTube
won’t
// store information about visitors on your web page
unless they
--
To view, visit https://gerrit.wikimedia.org/r/275271
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0f051bcfe9fb9d4d33b2e60c416a127681a5e18d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Video
Gerrit-Branch: master
Gerrit-Owner: Jack Phoenix <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits