A script to automatically add youtube videos containing a word?

Hey,

I wanted to know if there is a script that will add youtube videos automatically (Or set to search daily) that contain certain words?

This is to add youtube videos for my local area, so I would be searching by the city name.

Thanks

Have you looked at the API ? :slight_smile:


<?php
function youTubeVideoFeed($keywords, array $params = array()){
  return new SimpleXMLElement(
    'http://gdata.youtube.com/feeds/api/videos?v=2&' . http_build_query(array('q' => urlencode($keywords)) + $params),
    null,
    true
  );
}

$videos = youTubeVideoFeed('derry ireland', array('orderby' => 'relevance', 'format' => 5, 'max-results' => 5));

foreach($videos->entry as $video){
  printf("<a href=\\"%s\\">%s</a>\
", $video->link[0]['href'], htmlentities($video->title));
}

/*
  <a href="http://www.youtube.com/watch?v=EKWWJog-Hbk&feature=youtube_gdata">A DRIVE AROUND DERRY CITY, IRELAND (part one)</a>
  <a href="http://www.youtube.com/watch?v=I0Qc4Cg5glY&feature=youtube_gdata">Ireland / Derry</a>
  <a href="http://www.youtube.com/watch?v=B4uIM0VPUXE&feature=youtube_gdata">VINNY COYLE, DERRY . Civil Rights.IRELAND</a>
  <a href="http://www.youtube.com/watch?v=CN7K7GNa7O0&feature=youtube_gdata">&quot;SHADOW BOXER IN NEW YORK&quot; with &quot;Ireland's JOHN DUDDY&quot;, The Derry Destroyer!</a>
  <a href="http://www.youtube.com/watch?v=oY62RZpoCZo&feature=youtube_gdata">(London)Derry. City and Murals. Northern Ireland</a>
*/
?>

Nice one, i could use this. Thank’s

Hey Anthony,

Thanks very much for the reply :slight_smile:

I will have to read up about the API, I’m not sure how it works through that code.

Does that search/display videos automatically with the search term?

Thanks again Anthony :slight_smile: