ようこそお客さん

worstman.net/Blog


次の記事   前の記事

2007/11/10(土) worstman.net/Scrap を Pornput.com に対応させてみた

告知::サイト 最低人間 はてなブックマーク数
 他のみんながたんぶらーに投稿する中、自宅サーバで gelato というオープンソースのシステムを使ってたんぶらーチックな物を公開している worstman.net/Scrap ですが、デフォルトでは Youtube と Vimeo にしか対応していないので、ゆーすけべー氏の影響でエロサイト関連を追加してみることにした。


 pornput.com という「YouTube+Digg」のようなサイトなのですが、ネタエロも多そうなので対応させてみることにしました。一応自分用のメモ。

classes/functions.php
function isVimeoVideo($videoUrl) {
 の前に以下を追加。
function isPornputVideo($videoUrl) {
 if (beginsWith($videoUrl, "http://www.pornput.com/view/"))
   return true;
  else
   return false;
}

function getPornputVideoUrl($videoUrl) {
 return array_pop(explode("/view/",$videoUrl));
}

classes/gelato.class.php
function getVideoPlayer($url) {
 if (isYoutubeVideo($url)) {
  $id_video = getYoutubeVideoUrl($url);
  return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.youtube.com/v/".$id_video."\"><param name=\"movie\" value=\"http://www.youtube.com/v/".$id_video."\" /></object>\n";
 } elseif (isVimeoVideo($url)) {
  $id_video = getVimeoVideoUrl($url);
  return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\"><param name=\"movie\" value=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\" /></object>\n";
 } else {
  return "This URL is not a supported video (YouTube or Vimeo)";
 }		
}
 を以下のように修正。
function getVideoPlayer($url) {
 if (isYoutubeVideo($url)) {
  $id_video = getYoutubeVideoUrl($url);
  return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.youtube.com/v/".$id_video."\"><param name=\"movie\" value=\"http://www.youtube.com/v/".$id_video."\" /></object>\n";
 } elseif (isVimeoVideo($url)) {
  $id_video = getVimeoVideoUrl($url);
  return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\"><param name=\"movie\" value=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\" /></object>\n";
 } elseif (isPornputVideo($url)) {
  $id_video = getPornputVideoUrl($url);
  return "\t\t\t<iframe src=\"http://www.pornput.com/embed/".$id_video."\" width=\"500\" height=\"393\" frameborder=\"0\"></iframe>\n";
 } else {
  return "This URL is not a supported video (YouTube or Vimeo)";
 }		
}

 というわけで今後 Scrap にエロが投稿される頻度が上がると思います。えぇ。


#  非公開コメント   

  • TB-URL  http://worstman.net/blog/098/tb/

次の記事   前の記事