Arkadaşlar merhaba benim elimde bi plugin var ama sadece belirli sitelerden video çekebiliyorum bu embed olayınıda düzenleyemedim birinci olarak aşağıda düzenlenecek yeri buldum ancak yapamadım yardım edebilirmisiniz.
<?php
class pevid_fetcher
{
public $error, $flvurl, $img, $embed, $url;
private $type, $content, $error_codes, $messages, $extra;
public function __construct($url)
{
$this->error = false;
$this->messages = array(13500109, 13500110, 13500111, 13500112, 13500113, 13500114);
$this->http = new pevid_http();
// check if $url is valid
if(preg_match('/http:\/\/www\.youtube\.com\/watch\?v=[^&]+/', $url, $match))
{
$this->type = 'youtube';
}
elseif(preg_match('/http:\/\/blip\.tv\/file\/[0-9]+/', $url, $match))
{
$this->type = 'bliptv';
}
elseif(preg_match('/http:\/\/(.*?)break\.com\/(.*?)\/(.*?)\.html/', $url, $match))
{
$this->type = 'break';
}
elseif(preg_match('/http:\/\/www\.metacafe\.com\/watch\/(.*?)\/(.*?)\//', $url, $match))
{
$this->type = 'metacafe';
}
elseif(preg_match('/http:\/\/video\.google\.com\/videoplay\?docid=[^&]+/', $url, $match))
{
$this->type = 'google';
}
elseif(preg_match('/http:\/\/www\.ebaumsworld\.com\/video\/watch\/(.*?)\//', $url, $match))
{
$this->type = 'ebaumsworld';
}
elseif(preg_match('/http:\/\/(www\.)*vimeo\.com\/[0-9]{1,10}/', $url, $match))
{
$this->type = 'vimeo';
}
elseif(preg_match('/http:\/\/vids\.myspace\.com\/index\.cfm\?fuseaction=vids\.individual(&|&)(videoid|VideoID)=[0-9]+/', $url, $match))
{
$this->type = 'myspace';
}
if ($this->type == 'youtube')
{
$this->http->use_webproxy();
}
// no errors, continue...
if(isset($this->type))
{
$this->url = str_replace('&', '&', $match[0]);
if($this->http->fetchContent($this->url))
{
$this->content = $this->http->content;
$this->http->flush();
}
else
{
$this->triggerError(0);
}
}
else
{
$this->triggerError(1);
}
}
private function triggerError($id, $extra = NULL)
{
if ($this->error === false)
{
$this->error = true;
$this->error_id = $id;
(!is_null($extra)) ? $this->extra = $extra : NULL;
}
}
public function fetchError($id)
{
if (empty($id))
{
$msg = SE_Language::_get($this->messages[$this->error_id]);
}
else
{
$msg = SE_Language::_get($this->messages[$id]);
}
(!empty($this->extra)) ? $msg = str_replace('{$extra}', $this->extra, $msg) : NULL;
return $msg;
}
public function fetchType()
{
if (!empty($this->type))
{
return $this->type;
}
return false;
}
public function fetchFlv()
{
if($this->FLV_direct())
{
return true;
}
elseif ($this->FLV_keepvid())
{
return true;
}
$this->triggerError(2);
return false;
}
public function FLV_keepvid()
{
$kurl = 'http://keepvid.com/?url='.urlencode($this->url);
if($this->http->fetchContent($kurl))
{
$kcontent = $this->http->content;
$this->http->flush();
if (preg_match_all('/\/save-video.mp4\?(.*?)"/', $kcontent, $kmatch))
{
if($this->http->fetchHeader(urldecode($kmatch[1][0])))
{
$this->flvurl = urldecode($kmatch[1][0]);
return true;
}
}
elseif (preg_match_all('/\/save-video.flv\?(.*?)"/', $kcontent, $kmatch))
{
if($this->http->fetchHeader(urldecode($kmatch[1][0])))
{
$this->flvurl = urldecode($kmatch[1][0]);
return true;
}
}
}
return false;
}
public function FLV_direct()
{
switch ($this->type)
{
case "youtube":
if (preg_match("/\"fmt_url_map\": \"(.*?)\"/", $this->content, $matches))
{
$fmt_url_map = urldecode($matches[1]);
$pevids = explode(",", $fmt_url_map);
foreach($pevids as $pevid)
{
$pevid = urldecode($pevid);
$info = explode("|", $pevid);
$pevid_url[$info[0]] = $info[1];
}
}
if (!empty($pevid_url[18]))
{
$this->flvurl = $pevid_url[18];
}
elseif (!empty($pevid_url[34]))
{
$this->flvurl = $pevid_url[34];
}
elseif (!empty($pevid_url[6]))
{
$this->flvurl = $pevid_url[6];
}
else
{
$this->flvurl = $pevid_url[5];
}
break;
case "bliptv":
preg_match_all('/"link" : "http:\/\/blip.tv\/file\/get\/(.*?)"/', $this->content, $result);
$bvids = $result[1];
foreach ($bvids as $key => $value)
{
if (strpos($value, '.mp4') !== false) {
if ($this->http->fetchHeader('http://blip.tv/file/get/'.$value))
{
$this->flvurl = $this->http->header['url'];
$this->http->flush();
}
}
}
foreach ($bvids as $key => $value)
{
if (strpos($value, '.flv') !== false && empty($this->flvurl))
{
if ($this->http->fetchHeader('http://blip.tv/file/get/'.$value))
{
$this->flvurl = $this->http->header['url'];
$this->http->flush();
}
}
}
break;
case "break":
preg_match('/sGlobalFileName=\'[^\']+/', $this->content, $resulta);
$resulta = str_replace('sGlobalFileName=\'', '', $resulta[0]);
preg_match('/sGlobalContentFilePath=\'[^\']+/', $this->content, $resultb);
$resultb = str_replace('sGlobalContentFilePath=\'', '', $resultb[0]);
$flvurl = 'http://video1.break.com/dnet/media/'.$resultb.'/'.$resulta.'.flv';
break;
case "metacafe":
preg_match('/mediaURL=(.*?)&/', $this->content, $result);
$flvurl = urldecode($result[1]);
break;
case "google":
preg_match('/http:\/\/(.*?)googlevideo.com\/videoplayback%3F[^\\\\]+/', $this->content, $result);
$flvurl = urldecode($result[0]);
break;
case "ebaumsworld":
preg_match('/rel=\"video_src\" href=\"http:\/\/www.ebaumsworld\.com\/mediaplayer.swf\?pageurl=(.*?)&file=(.*?)\.flv/', $this->content, $result);
$flvurl = $result[2].'.flv';
break;
case "vimeo":
$url = explode('/', $this->url);
$id = $url[3];
$url = "http://www.vimeo.com/moogaloop/load/clip:{$id}";
if ($this->http->fetchContent($url))
{
$xml = $this->http->content;
$this->http->flush();
preg_match('/ure>(.*?)<\/req/i', $xml, $sig);
preg_match('/ires>(.*?)<\/req/i', $xml, $exp);
if ($this->http->fetchHeader("http://www.vimeo.com/moogaloop/play/clip:{$id}/{$sig[1]}/{$exp[1]}/?q=sq"))
{
$this->flvurl = $this->http->header['url'];
$this->http->flush();
}
}
break;
case "myspace":
preg_match('/rel="image_src" href="(.*?)"/', $this->content, $result);
$exploded = explode('/', $result[1]);
preg_match('/_(.*?)\./', $exploded[count($exploded)-1], $result2);
$this->flvurl = "/{$exploded[count($exploded)-2]}/vid_{$result2[1]}.flv";
break;
}
if (isset($this->flvurl))
{
return true;
}
if (!empty($flvurl) && $this->http->fetchHeader($flvurl))
{
$this->flvurl = $this->http->header['url'];
$this->http->flush();
return true;
}
elseif ($this->type == 'metacafe')
{
if (preg_match('/itemID = \'yt-(.*?)\'/', $this->content, $result))
{
$this->triggerError(5, $result[1]);
}
}
return false;
}
function fetchEmbed()
{
switch ($this->type) {
case "youtube":
if (!preg_match('/type="text" value="Embedding disabled by request"/', $this->content))
{
$vid_embed_id = substr($this->url, strpos($this->url, "=")+1);
$vid_embed_url = "http://www.youtube.com/v/{$vid_embed_id}";
}
else
{
$this->triggerError(4);
return false;
}
break;
case "bliptv":
preg_match('/link rel="video_src" href="(.*?)"/', $this->content, $result);
$vid_embed_url = $result[1];
break;
case "break":
preg_match('/meta name="embed_video_url" content="(.*?)"/', $this->content, $result);
$vid_embed_url = $result[1];
break;
case "metacafe":
preg_match('/link rel="video_src" href="(.*?)"/', $this->content, $result);
$vid_embed_url = $result[1];
break;
case "google":
$vid_embed_id = substr($this->url, strpos($this->url, "=")+1);
$vid_embed_url = "http://video.google.com/googleplayer.swf?docid={$vid_embed_id}";
break;
case "vimeo":
preg_match('/[0-9]{1,10}/', $this->url, $match);
$vid_embed_id = $match[0];
$vid_embed_url = "http://vimeo.com/moogaloop.swf?clip_id={$vid_embed_id}&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&fullscreen=1";
break;
case "myspace":
preg_match('/link rel="video_src" href="(.*?)"/', $this->content, $result);
$vid_embed_url = $result[1];
break;
case "ebaumsworld":
preg_match('/link rel="video_src" href="(.*?)"/', $this->content, $result);
$vid_embed_url = 'http://www.ebaumsworld.com/player.swf';
$flashvars = explode("?", $result[1]);
$flashvars = $flashvars[1];
break;
}
if (!empty($vid_embed_url))
{
$this->embed = "<object width=\"640\" height=\"360\">".
"\n\t<param name=\"wmode\" value=\"transparent\"></param>".
"\n\t<param name=\"movie\" value=\"{$vid_embed_url}\"></param>".
"\n\t<param name=\"flashvars\" value=\"{$flashvars}\"></param>".
"\n\t<param name=\"allowFullScreen\" value=\"true\"></param>".
"\n\t<param name=\"allowscriptaccess\" value=\"always\"></param>".
"\n\t<embed id=\"VideoPlayback\" src=\"{$vid_embed_url}\" flashvars=\"{$flashvars}\"width=\"640\" height=\"360\" allowFullScreen=\"true\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" wmode=\"transparent\"></embed>".
"\n</object>";
return true;
}
$this->triggerError(2);
return false;
}
function fetchImg()
{
switch ($this->type) {
case "youtube":
$location_img_url = str_replace('http://www.youtube.com/watch?v=', '', $this->url);
$img = "http://img.youtube.com/vi/{$location_img_url}/1.jpg";
break;
case "bliptv":
preg_match('/rel=\"image_src\" href=\"http:\/\/[^\"]+/', $this->content, $result_img);
preg_match('/http:\/\/[^\"]+/', $result_img[0], $result_img);
$img = $result_img[0];
break;
case "break":
preg_match('/meta name=\"embed_video_thumb_url\" content=\"http:\/\/[^\"]+/', $this->content, $result_img);
preg_match('/http:\/\/[^\"]+/', $result_img[0], $result_img);
$img = $result_img[0];
break;
case "metacafe":
preg_match('/link rel=\"image_src\" href="(.*?)"/', $this->content, $result_img);
$img = $result_img[1];
break;
case "google":
preg_match('/http:\/\/[0-9]\.(.*?)\.com\/ThumbnailServer2%3Fapp%3D(.*?)%26contentid%3D(.*?)%26offsetms%3D(.*?)%26itag%3D(.*?)%26hl%3D(.*?)%26sigh%3D[^\\\\]+/', $this->content, $result);
$img = urldecode($result[0]);
break;
case "ebaumsworld":
preg_match('/link rel=\"image_src\" href="(.*?)"/', $this->content, $result_img);
$img = $result_img[1];
break;
case "vimeo":
$url = explode('/', $this->url);
$id = $url[3];
if ($this->http->fetchContent("http://www.vimeo.com/moogaloop/load/clip:{$id}"))
{
$xml = $this->http->content;
$this->http->flush();
preg_match('/nail>(.*?)<\/thumb/i', $xml, $result_img);
$img = $result_img[1];
}
break;
case "myspace":
preg_match('/rel="image_src" href="(.*?)"/', $this->content, $result_img);
$img = $result_img[1];
break;
}
if (!empty($img) && $this->http->fetchContent($img))
{
$this->img = $this->http->content;
$this->http->flush();
return true;
}
$this->triggerError(3);
return false;
}
public static function fetchProviders()
{
global $user, $vid_settings;
$provider = explode(",", $user->level_info[level_vid_prov]);
array_shift($provider);
$provider_disabled = explode(",", $vid_settings[disable]);
array_shift($provider_disabled);
$prov_number = count($provider);
for ($i=0; $i<count($provider_disabled); $i++)
{
for ($j=0; $j<$prov_number; $j++)
{
if ($provider[$j] == $provider_disabled[$i])
{
unset($provider[$j]);
}
}
}
$provider_keys = array_keys($provider);
for ($i=0; $i<count($provider); $i++)
{
$real_provider[$i] = $provider[$provider_keys[$i]];
}
$providers = $real_provider;
return $providers;
}
public static function getAllProviders()
{
$providers = array('Youtube.com',
'Video.Google.com',
'Metacafe.com',
'Break.com',
'Blip.tv',
'Ebaumsworld.com',
'Vimeo.com',
'Myspace.com');
$provider_types = array('youtube',
'google',
'metacafe',
'break',
'bliptv',
'ebaumsworld',
'vimeo',
'myspace');
$provider_ids = array('level_vid_prov0',
'level_vid_prov1',
'level_vid_prov2',
'level_vid_prov3',
'level_vid_prov4',
'level_vid_prov5',
'level_vid_prov6',
'level_vid_prov7');
$provider_examples = array('http://www.youtube.com/watch?v=0_fPV13lKm4',
'http://video.google.com/videoplay?docid=5733044300866646599',
'http://www.metacafe.com/watch/1306556/i_have_this_ball_funny_videos/',
'http://www.break.com/index/the-ultimate-parkour-jump.html',
'http://blip.tv/file/1854578/',
'http://www.ebaumsworld.com/video/watch/80500017/',
'http://www.vimeo.com/952354',
'http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=1693568');
$provider_imgs = array('imp_youtube.jpg',
'imp_gvideo.jpg',
'imp_mcafe.jpg',
'imp_break.jpg',
'imp_blip.jpg',
'imp_eworld.jpg',
'imp_vimeo.jpg',
'imp_mspace.jpg');
$provider_urls = array('http://www.youtube.com/',
'http://video.google.com/',
'http://www.metacafe.com/',
'http://www.break.com/',
'http://blip.tv/',
'http://www.ebaumsworld.com/',
'http://www.vimeo.com/',
'http://vids.myspace.com');
return array($providers, $provider_types, $provider_ids, $provider_examples, $provider_imgs, $provider_urls);
}
public static function getAdminType($level_info){
$level_info[level_vid_prov] = NULL;
$providers = self::getAllProviders();
for ($i=0; $i<count($providers[0]); $i++) {
$provider_name = 'level_vid_prov'.$i;
$level_info[$provider_name] = NULL;
if (isset($_POST[$provider_name])) { $level_info[$provider_name] = $_POST[$provider_name]; $level_info[level_vid_prov] .= ','.$providers[1][$i]; }
}
return $level_info;
}
public function fetchData()
{
switch ($this->type)
{
case "youtube":
$feed = explode("=", $this->url);
$feed = "http://gdata.youtube.com/feeds/api/videos/".$feed[1]."?v=2";
$newInfo = trim(@file_get_contents($feed));
$new_string = preg_replace("/\n|\r\n|\r$/", "<br>", $newInfo);
$newInfo = preg_replace("/>\s{2,}</", "> <", $new_string);
preg_match('/<media:title(.*?)<\/media:title>/', $newInfo, $result);
$title = $result[0];
preg_match('/<media:description(.*?)<\/media:description>/', $newInfo, $result);
$desc = preg_replace("/<br(.*?)>/", "\n", $result[0]);
preg_match('/<media:keywords(.*?)<\/media:keywords>/', $newInfo, $result);
$tags = str_replace(",", "", $result[0]);
break;
case "bliptv":
preg_match('/div id=\"EpisodeTitle\">(.*?)<\/div>/', $this->content, $result);
$title = $result[1];
preg_match('/div class=\'BlipDescription\'><p>(.*?)<\/p><\/div>/', $this->content, $result);
$desc = stripslashes(preg_replace("/<br(.*?)>/", "\n", $result[1]));
preg_match('/<a href=\'http:\/\/blip\.tv\/topics\/view\/(.*?)<\/a>\s/', $this->content, $result);
$tags = str_replace(",", "", $result[0]);
break;
case "metacafe":
$content = preg_replace("/\n|\r\n|\r$/", "", $this->content);
$content = preg_replace("/>\s{2,}</", "> <", $content);
preg_match('/<h1 id="ItemTitle" >(.*?)<\/h1>/', $content , $result);
$title = $result[1];
preg_match('/<div id="Desc">(.*?)<\/div>/', $content, $result);
$desc = str_replace("<br />", "\n", $result[1]);
preg_match('/meta name="Keywords" content="(.*?)"/', $content, $result);
$tags = str_replace(",", " ", $result[1]);
break;
case "break":
$content = preg_replace("/\n|\r\n|\r$/", "", $this->content);
$content = preg_replace("/>\s{2,}</", "> <", $content);
preg_match('/meta name="title" content="(.*?)"/', $content , $result);
$title = $result[1];
preg_match('/meta name="embed_video_description" id="vid_desc" content="(.*?)"/', $content, $result);
$desc = $result[1];
preg_match('/meta name="keywords" content="(.*?)"/', $content, $result);
$tags = str_replace(",", "", $result[1]);
break;
case "google":
$content = preg_replace("/\n|\r\n|\r$/", "", $this->content);
$content = preg_replace("/>\s{2,}</", "> <", $content);
preg_match('/<div class="medium bold" id=video-title>(.*?)<\/div>/', $content, $result);
$title = $result[1];
preg_match('/<span id=video-description>(.*?)<\/span>/', $content, $result);
$desc = $result[1];
$tags = "";
break;
case "ebaumsworld":
$content = preg_replace("/\n|\r\n|\r$/", "", $this->content);
$content = preg_replace("/>\s{2,}</", "> <", $content);
preg_match('/meta name="title" content="(.*?)"/', $content, $result);
$title = $result[1];
preg_match('/meta name="description" content="(.*?)"/', $content, $result);
$desc = html_entity_decode($result[1], ENT_QUOTES);
preg_match('/<p><span class="small">Tags:<\/span>(.*?)<\/p>/', $content, $result);
$tags = str_replace('<p><span class="small">Tags:</span>', '', $result[1]);
$tags = str_replace('</a>', ' ', $tags);
break;
case "vimeo":
$content = preg_replace("/\n|\r\n|\r$/", "<br>", $this->content);
$content = preg_replace("/>\s{2,}</", "> <", $content);
preg_match('/meta name="title" content="(.*?)"/', $this->content, $result);
$title = $result[1];
preg_match('/meta name="description" content="(.*?)"/', $content, $result);
$desc = preg_replace("/<br(.*?)>/", "\n", $result[1]);
preg_match('/meta name="keywords" content="(.*?)"/', $this->content, $result);
$tags = str_replace(',', ' ', $result[1]);
break;
case "myspace":
$content = preg_replace("/\n|\r\n|\r$/", "<br>", $this->content);
$content = preg_replace("/>\s{2,}</", "> <", $content);
preg_match('/<h1 id="tv_tbar_title">(.*?)<\/h1>/', $this->content, $result);
$title = $result[1];
preg_match('/meta name="description" content="(.*?)"/', $content, $result);
$desc = preg_replace("/<br(.*?)>/", "\n", $result[1]);
preg_match('/meta name="keywords" content="(.*?)"/', $this->content, $result);
$tags = str_replace(',', ' ', $result[1]);
break;
}
$this->data = array(trim(htmlspecialchars_decode(htmlentities(strip_tags($title), ENT_QUOTES, 'UTF-8'))), trim(htmlspecialchars_decode(htmlentities(strip_tags($desc), ENT_QUOTES, 'UTF-8'))), trim(htmlspecialchars_decode(htmlentities(strip_tags($tags), ENT_QUOTES, 'UTF-8'))));
return true;
} // END catchData() FUNCTION
}
?>