日記/2009-11-8
最終更新時間:2009年11月08日 17時34分57秒
YouTube プラグインのニコニコ動画外部プレイヤー対応
2009/10/29のニコニコ動画(9)の新機能対応で、外部プレイヤー対応がなされました。従来は、提携先のブログにのみ外部プレイヤーを埋め込むことができたわけですが、今回の対応でどこにでも埋め込めるようになりました。
そこで、FreeStyleWiki本家のサイトに投稿されているYouTube プラグインを、この外部プレイヤー対応に改造してみました。
と言っても、リンク先のURLを書き換えて、プレイヤーのデフォルトのサイズをYouTubeのと同じにしただけ。
--- YouTube.pm.org 2007-11-15 23:12:59.000000000 +0900 +++ YouTube.pm 2009-11-08 17:18:07.000000000 +0900 @@ -76,7 +76,7 @@ my $item = shift; my $id; - if ( $item =~ m/http:\/\/www\.nicovideo\.jp\/watch\/(sm[0-9]*)/ ) { + if ( $item =~ m/http:\/\/www\.nicovideo\.jp\/watch\/([a-z0-9]*)/ ) { $id = $1; } @@ -91,7 +91,7 @@ my $nicoID = getNicoID($item); - my $buf = "<iframe width=\"". $width . "\" height=\"". $height . "\" src=\"http://www.nicovideo.jp/thumb/" . $nicoID . "\" scrolling=\"no\" style=\"border:solid 1px #CCC;\" frameborder=\"0\"><a href=\"http://www.nicovideo.jp/watch/" . $nicoID . "\">【ニコニコ動画】</a></iframe>"; + my $buf = "<script type=\"text/javascript\" src=\"http://ext.nicovideo.jp/thumb_watch/".$nicoID."?w=".$width."&h=".$height."\"></script>"; return $buf; } @@ -108,8 +108,8 @@ $item = Util::escapeHTML($item); if (($item =~ m/^http:\/\/www\.nicovideo\.jp/ )) { - $width = ($width eq "")? 312 : int($width); - $height = ($height eq "")? 176 : int($height); + $width = ($width eq "")? 425 : int($width); + $height = ($height eq "")? 355 : int($height); $buf = embed_nicovideo($item, $width, $height); }
サンプル表示
サンプル表示は以下のようになります。
{{youtube http://www.nicovideo.jp/watch/1254473673}}
追記
本家のページにもコメントしておきました。