...

View Full Version : Hi All, i need some Help Please



ilie88
02-09-2010, 08:10 PM
It can be programmatically accessed through the YouTube Data API by looking for the yt:format=5 <media:content> URL. This format will not be available if embedding has been disabled by the uploader.
<media:content url="http://www.youtube.com/v/VIDEO_ID" type="application/x-shockwave-flash" medium="video"
isDefault="true" expression="full" duration="100" yt:format="5"/>

Hi, this php code is from mi search site and use the gdata api key of youtube, the code works fine but i need to ad this line yt:format="5" because if not in search ar added Even the videos with embed disabled this line yt:format="5" ignores the videos with embed disabled please help if Samoan can help me tank you sow much have a great day/night



<?


// ################# Start recognize SEO Url data #############################



$p_url = explode('/',$_SERVER['REQUEST_URI']);

$seo_title = array_pop($p_url);



preg_match_all("|page([0-9]*).html|U", $seo_title, $out, PREG_PATTERN_ORDER);

$_GET['p'] = $out[1][0];



if (empty($_GET['p'])) {

$_GET['p'] = 1;

}



if ($_GET['p']>0) {

$seo_title = array_pop($p_url);

}



if(empty($seo_title)) {

$seo_title = array_pop($p_url);

}



$seo_title = urldecode($seo_title);



$i=0;

$stop = false;

while($i<count($keyword_list)) {

if($seo_title == SeoTitleEncode($keyword_list[$i])) {

$_GET['q'] = $keyword_list[$i];

}

$i++;

}


if (empty($_GET['q'])) {

$_GET['q'] = $seo_title;

}

if (empty($_GET['orderby'])) {
$orderby = "relevance";
}else{
$orderby = $_GET['orderby'];
}

// ################# Start getting Youtube GData ##############################



$keyword = str_replace("-"," ",urldecode($_GET['q']));
$video_list = YT_ListByTag($keyword, $_GET['p'], $orderby);



// ################# Start parse xml attributes manually ######################





if($_GET['p'] == 1) {

stripTags($_GET['q']);
}




preg_match_all('/<[^>]+>/s',$video_list[1],$tags);



$i=0;

foreach ($tags[0] as $k => $v) {



$v = str_replace('"',"\'",$v);



if (substr($v, 0, 12) == '<yt:duration') {

preg_match("/seconds='(.*)'/i", $v, $matches);

$video_list[0][entry][$i][duration] = $matches[1];

}



if (substr($v, 0, 14) == '<yt:statistics') {

preg_match("/viewCount='(.*)' favoriteCount/i", $v, $matches);

$video_list[0][entry][$i][view_count] = $matches[1];


preg_match("/favoriteCount='(.*)'/i", $v, $matches);

$video_list[0][entry][$i][favorite_count] = $matches[1];

}



if (substr($v, 0, 10) == '<gd:rating') {

preg_match("/numRaters='(.*)' average/i", $v, $matches);

$video_list[0][entry][$i][rating_num_raters] = $matches[1];



preg_match("/average='(.*)'/i", $v, $matches);

$video_list[0][entry][$i][rating_average] = $matches[1];

}



if (substr($v, 0, 7) == '</entry') {

$i++;

}

}



// ################# Start construct video data ###############################



if(is_array($video_list[0][entry])) {

foreach($video_list[0][entry] as $k => $v) {

$id_raw = explode('/',$video_list[0][entry][$k][id]);



$video_list[0][entry][$k][id] = array_pop($id_raw);

$video_list[0][entry][$k][author] = $video_list[0][entry][$k][author][0][name];

$video_list[0][entry][$k][description] = $video_list[0][entry][$k]['media:group'][0]['media:description'];

$video_list[0][entry][$k][category] = $video_list[0][entry][$k]['media:group'][0]['media:category'];

$video_list[0][entry][$k][thumbnail][0] = "http://img.youtube.com/vi/" . $video_list[0][entry][$k][id] . "/0.jpg";

$video_list[0][entry][$k][thumbnail][1] = "http://img.youtube.com/vi/" . $video_list[0][entry][$k][id] . "/1.jpg";

$video_list[0][entry][$k][thumbnail][2] = "http://img.youtube.com/vi/" . $video_list[0][entry][$k][id] . "/2.jpg";

$video_list[0][entry][$k][thumbnail][3] = "http://img.youtube.com/vi/" . $video_list[0][entry][$k][id] . "/3.jpg";



$keywords_raw = explode(',',$video_list[0][entry][$k]['media:group'][0]['media:keywords']);



$i=0;

foreach($keywords_raw as $k2 => $v2) {

$video_list[0][entry][$k][keywords][$i] = trim($v2);

$i++;

}

}

}



// ################# Start calculate pagination ###############################



if((($_GET['p']) * $config['list_per_page']) < $video_list[0]['opensearch:totalresults']) {

$next_page = $_GET['p'] + 1;

}

if($_GET['p']>1) {

$prev_page = $_GET['p'] - 1;

}



// ################# Start assign template variables ##########################



$tpl->assign('total',ceil($video_list[0]['opensearch:totalresults'] / $config['list_per_page']));
$tpl->assign('videos',$video_list[0][entry]);
$tpl->assign('keyword',$keyword);
$tpl->assign('next_page',$next_page);
$tpl->assign('prev_page',$prev_page);
$tpl->assign('curr_page',$_GET['p']);
$tpl->assign('cid',$_GET['id']);
$tpl->assign('orderby',$orderby);
$tpl->assign('list_mode',$config["search_videos_view_mode"]);


$tpl->display('list.html');

include "footer.php";

?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum