title: youtube api filtered search
body: <p>I have a music site that use Youtube Api. I want to filter the videos by size. Because when there is a high quality video, concert shows etc. streaming can hobble at low speed internet connections.
  Also, i want to show pure music videos. I don't want show concert record, cover or remix etc. Which way do i fallow to filter original music records.</p>
  
  <p>By the way search codes i am using are</p>
  
  <pre><code> /*
  $params: string, artist_name - song
  returns an array &gt;&gt; video_id, video name, video length
  */      
  function youtube_find_video($params)
  {
      str_replace("'", "", $params);
      $q = preg_replace('/[[:space:]]/', '/', trim($params));
      $q = utf8_decode(utf8_encode($q));
      $replacements = array(',', '?', '!', '.');
      $q = str_replace($replacements, "", $q);
      $feedURL = "http://gdata.youtube.com/feeds/api/videos/-/{$q}?orderby=relevance&amp;max-results=1";
      $sxml = simplexml_load_file($feedURL);
      if(!$sxml)
      {
          return false;
      }       
      else{
          $entry  = $sxml-&gt;entry;
          if(!$entry)
          {
              return false;
          }
  
          // get nodes in media: namespace for media information
          $media = $entry-&gt;children('http://search.yahoo.com/mrss/');
  
          if($media)
          {
              // get video player URL
              $attrs = $media-&gt;group-&gt;player-&gt;attributes();
              $url = $attrs['url'];
              if(!$url)
              {
                  return false;
                  break;
              }
              parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars );
              $watch['id'] = $my_array_of_vars['v'];
  
              // get video name
              $watch['name'] = $media-&gt;group-&gt;title;
  
              // get &lt;yt:duration&gt; node for video length[minute]
              $yt = $media-&gt;children('http://gdata.youtube.com/schemas/2007');
              $attrs = $yt-&gt;duration-&gt;attributes();
              $watch['length'] = sprintf("%0.2f", $attrs['seconds']/60);
  
              $watch = simplexml_kurtul($watch); 
              return $watch;           
          }
  
          else
          {
              return false;
          }
      }
  
  
  }     
  </code></pre>