<?php
/**
* class.videoportalplayer.php (php4)
* Replace Links to videos from videoportal sites with embeded players.
* supported: youtube.com, video.google.com, clipfish.de, myvideo.de, videotube.de, myspacetv.com, ugv.abcnews.go.com
* only links with an @ in front !
* @author Bernd Essl <bernd_at_b23.at>
* @copyright Bernd Essl <bernd_at_b23.at>
* @license license http://gnu.org/copyleft/gpl.html GNU GPL
* @link http://b23.at/
* @version $Id: class.videoportalplayer.php 15 2007-10-07 15:48:10Z bernd $
*/
class VideoportalPlayer
{
var $width = 425;
var $height = 350;
function _setReplace($posting, $results, $tmpl_player, $index=1)
{
foreach($results as $item)
$posting = str_replace($item[0], str_replace('[ID]', $item[$index], $tmpl_player), $posting);
return $posting;
}
function getYoutube($posting)
{
#@http://www.youtube.com/watch?v=fvjT5FrWpS0
#@http://uk.youtube.com/watch?v=3_1Y8UoLIu4
$tmpl_player= '<object width="'.$this->width.'" height="'.$this->height.'">
<param name="movie" value="http://www.youtube.com/v/[ID]"></param>
<param name="wmode" value="transparent"></param>
<embed src="http://www.youtube.com/v/[ID]" type="application/x-shockwave-flash" wmode="transparent" width="'.$this->width.'" height="'.$this->height.'"></embed>
</object>';
preg_match_all('/@http:\/\/(www\.|uk\.)?youtube\.com\/watch\?v=([\d\w-_]+)/', $posting, $results, PREG_SET_ORDER);
if($results)
$posting = $this->_setReplace($posting, $results, $tmpl_player, $index=2);
return $posting;
}
function getGoogle($posting)
{
#@http://video.google.com/googleplayer.swf?docId=-2205197918273229623
#@http://video.google.com/videoplay?docid=-2205197918273229623
$tmpl_player= '<object type="application/x-shockwave-flash" data="http://video.google.com/googleplayer.swf?docId=[ID]" height="'.$this->height.'" width="'.$this->width.'">
<param name="movie" value="http://video.google.com/googleplayer.swf?docId=[ID]">
</object>';
preg_match_all('/@http:\/\/video\.google\.com\/(googleplayer\.swf|videoplay)\?doc[Ii]d=([\d-]+)/', $posting, $results, PREG_SET_ORDER); #funny one google :)
if($results)
$posting = $this->_setReplace($posting, $results, $tmpl_player, $index=2);
return $posting;
}
function getClipfish($posting)
{
#@http://www.clipfish.de/player.php?videoid=MTk0ODU4fDEw
$tmpl_player = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'.$this->width.'" height="'.$this->height.'" id="player" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="http://www.clipfish.de/videoplayer.swf?as=0&videoid=[ID]&r=1" />
<param name="wmode" value="transparent">
<param name="quality" value="high" />
<param name="bgcolor" value="#999999" />
<embed src="http://www.clipfish.de/videoplayer.swf?as=0&videoid=[ID]&r=1" quality="high" bgcolor="#999999" width="'.$this->width.'" height="'.$this->height.'" name="player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
</object>';
preg_match_all('/@http:\/\/www\.clipfish\.de\/player\.php\?videoid=([\d\w-_]+)/', $posting, $results, PREG_SET_ORDER);
if($results)
$posting = $this->_setReplace($posting, $results, $tmpl_player);
return $posting;
}
function getMyvideo($posting)
{
#@http://www.myvideo.de/watch/65741
$tmpl_player = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'.$this->width.'" height="'.$this->height.'"><param name="movie" value="http://www.myvideo.de/movie/[ID]"></param><embed src="http://www.myvideo.de/movie/[ID]" width="'.$this->width.'" height="'.$this->height.'" type="application/x-shockwave-flash"></embed></object>';
preg_match_all('/@http:\/\/www\.myvideo\.de\/watch\/([\d]+)/', $posting, $results, PREG_SET_ORDER);
if($results)
$posting = $this->_setReplace($posting, $results, $tmpl_player);
return $posting;
}
function getVideotube($posting)
{
#@http://videotube.de/watch/31603
$tmpl_player = '<object type="application/x-shockwave-flash" data="http://www.videotube.de/ci/flash/videotube_player_4.swf?videoId=[ID]&svsf=0&lang=german&host=www.videotube.de" width="'.$this->width.'" height="'.$this->height.'" wmode="transparent"><param name="movie" value="http://www.videotube.de/ci/flash/videotube_player_4.swf?videoId=[ID]&svsf=0&lang=german&host=www.videotube.de" /></object>';
preg_match_all('/@http:\/\/videotube\.de\/watch\/([\d]+)/', $posting, $results, PREG_SET_ORDER);
if($results)
$posting = $this->_setReplace($posting, $results, $tmpl_player);
return $posting;
}
function getDailymotion($posting)
{
#disabled! i found no way to parse this portal
#the problem is that the url-ID and the videoplayer-ID is different.
return False;
}
function getMyspacetv($posting)
{
#@http://myspacetv.com/index.cfm?fuseaction=vids.individual&videoid=784348108
#@http://vids.myspace.com/index.cfm?fuseaction=vids.individual&VideoID=4592484
#contributed by Mariano Alborés
$tmpl_player = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'.$this->width.'" height="'.$this->height.'" id="player" align="middle"><embed src="http://lads.myspace.com/videos/myspacetv_vplayer0005.swf?fuseaction=vids.individual&videoid=[ID]" width="'.$this->width.'" height="'.$this->height.'" flashvars="m=[ID]&type="application/x-shockwave-flash"></embed></object>';
preg_match_all('/@http:\/\/(myspacetv|vids\.myspace)\.com\/index\.cfm\?fuseaction=vids.individual&(videoid|VideoID)=([\d\w-_]+)/', $posting, $results, PREG_SET_ORDER);
print $result;
if($results)
$posting = $this->_setReplace($posting, $results, $tmpl_player, $index=3);
return $posting;
}
function getAbcnews($posting)
{
#@http://ugv.abcnews.go.com/player.aspx?id=570913
$tmp_player = '<embed width="'.$this->width.'" height="'.$this->height.'" wmode="transparent" flashvars="file=http://ugv.abcnews.go.com/ChannelRssHandler.ashx%3fcontentItemID%3d[ID]%26mi%3d1&autostart=false&overstretch=false&LinkOnScreenClick=0&InitialVolume=40" quality="high" name="mpl" id="mpl" src="http://ugv.abcnews.go.com/dbox/3/flvplayer_abc_small.swf" type="application/x-shockwave-flash"/>';
preg_match_all('/@http:\/\/ugv\.abcnews\.go\.com\/player\.aspx\?id=([\d]+)/', $posting, $results, PREG_SET_ORDER);
if ($results)
$posting = $this->_setReplace($posting, $results, $tmp_player, $index=1);
return $posting;
}
}
?>