SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist John D's Avatar
    Join Date
    Jun 2003
    Location
    Derry, Ireland
    Posts
    426
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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
    CanaryHotspot.com - Canary Island forum and information
    InternationalChatForum.com - International Travel Chat Forum and information

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Have you looked at the API ?

    PHP Code:
    <?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>\n"$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>
    */
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Member autowww's Avatar
    Join Date
    Nov 2010
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AnthonySterling View Post
    Have you looked at the API ?

    PHP Code:
    <?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>\n"$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

  4. #4
    SitePoint Evangelist John D's Avatar
    Join Date
    Jun 2003
    Location
    Derry, Ireland
    Posts
    426
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Anthony,

    Thanks very much for the reply

    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
    CanaryHotspot.com - Canary Island forum and information
    InternationalChatForum.com - International Travel Chat Forum and information


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •