View Single Post
Old 02-09-2010, 08:10 PM   PM User | #1
ilie88
New to the CF scene

 
Join Date: Feb 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
ilie88 is an unknown quantity at this point
Exclamation Hi All, i need some Help Please

Quote:
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


PHP Code:
<?


// ################# 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$outPREG_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($v012) == '<yt:duration') { 

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

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

  }

  

  if (
substr($v014) == '<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($v010) == '<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($v07) == '</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";

?>

Last edited by ilie88; 02-09-2010 at 09:52 PM..
ilie88 is offline   Reply With Quote