magpieRSS problem youtube RSS

Discussion in 'XML & RSS' started by driesdk, Aug 6, 2006.

  1. #1
    Hi, I found this script, to parse youtube videostills of a specified tag on my home page, but it shows every item on the rss page, i want them to show only 6 items, I cant get it to work with the script, ill post the script, can somebody help me out with this one? thanks
    require_once('rss_fetch.inc');
    
    $tag = "http://www.youtube.com/rss/tag/".$video.".rss";
    if ( $video ) {
    echo "<table border='0'>";
    	$rss = fetch_rss( $tag );
    	$numvideos = 0;
    	foreach ($rss->items as $item) {
    	if ($numvideos == 2 || $numvideos == 4 || $numvideos == 6 || $numvideos == 0){ echo "</tr><tr>";}
    	$numvideos++;
             preg_match('/img src="(.*)\.jpg"/',$item["description"],$imgUrlMatches);
    
                 $imgurl = $imgUrlMatches[0];
                 $title = $item["title"];
                 $url = $item["link"];
    
                 echo "<td align='center'><a href=\"$url\">"
                     ."<$imgurl alt=\"$title\"/>"
                     ."</a>\n</td>";
             
    	}
    echo "</table>";
    }
    Code (markup):
    This is the code, it works perfectly, and the way it is now, its showing, 2 images next to eachother, than the next images, untill six, and then, all the other items of the feed are shown, I dont want them to be there.
    This is how it shows now: darkcentral.net/test/searchvideosF.php
    Greetz
     
    driesdk, Aug 6, 2006 IP
  2. rosytoes

    rosytoes Peon

    Messages:
    230
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    add below $numvideos++;
    if ($numvideos > 6) break;
     
    rosytoes, Aug 6, 2006 IP
  3. driesdk

    driesdk Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks alot for the fast reply, it did the job perfectly.
    Greetz
     
    driesdk, Aug 6, 2006 IP
  4. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Could this script be used to parse the keyword tags so that they are displayed on another page in your site?
     
    Luke Jones, Jul 13, 2007 IP