Ver Mensaje Individual
  #4 (permalink)  
Antiguo 22/10/2010, 00:49
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: Generar una ID aleatoria de un vídeo de Youtube con Javascript

Lo que normalmente se hace en esos casos es tomar el rss del canal de youtube que quieras y tomar los datos desde ahí. Una vez que tengas la información, no te será difícil mostrar lo que quieras randomizando el orden.
Un ejemplo basado en lenguaje de servidor:
Código PHP:
<?php 
$titulo
=array();
$imagenes=array();
$descripcion=array();
$swf=array();
$sxmlsimplexml_load_file('http://gdata.youtube.com/feeds/api/users/bicentenariolab/uploads');
foreach(
$sxml->entry as $entry){
    
$media $entry->children('http://search.yahoo.com/mrss/');
      
      
// get video player URL
      
$attrs $media->group->content[0]->attributes();
      
$watch $attrs['url']; 
      
      
// get video thumbnail
      
$attrs $media->group->thumbnail[0]->attributes();
      
$thumbnail $attrs['url']; 
            
      
// get <yt:duration> node for video length
      
$yt $media->children('http://gdata.youtube.com/schemas/2007');
      
$attrs $yt->duration->attributes();
      
$length $attrs['seconds']; 
      
      
// get <yt:stats> node for viewer statistics
      
$yt $entry->children('http://gdata.youtube.com/schemas/2007');
      
$attrs $yt->statistics->attributes();
      
$viewCount $attrs['viewCount']; 
      
      
// get <gd:rating> node for video ratings
      
$gd $entry->children('http://schemas.google.com/g/2005'); 
      if (
$gd->rating) {
        
$attrs $gd->rating->attributes();
        
$rating $attrs['average']; 
      } else {
        
$rating 0
      } 
    
$titulo[]=$media->group->title;
     
$imagenes[] = $thumbnail;
    
$fecha_unix strtotime($entry->published);
    
$hoy=time();
    
$fecha='<span style="color:#848585"> hace '.ceil(($hoy-$fecha_unix)/(24*60*60)).' d&iacute;as</span>';
    
$descripcion[]='<span style="color:#848585">Subido por</span> <span style="color:#0d3046">'.$entry->author->name.'</span> '.$fecha;
    
$w=explode('?',$watch);
    
$swf[]= $watch[0];
}
?>
<pre><?php print_r($swf);?></pre>