youtube function problem

Discussion in 'Programming' started by Mr.samy, Apr 22, 2009.

  1. #1
    Hello ,

    i have an function used it to get youtube videos link from feeds

    as : http://www.youtube.com/rss/tag/sports.rss

    the function is

    
    	function getYoutubeResult($query, $is_cached, $delete_older_than, $min_cache_size)
    	{
    		$h=$this->LoadCache('Y_'.$this->EncodeS(strtolower($query)).".gz", $delete_older_than);
    		$cached=$h!="";
    		if ($h=="") $h=$this->downloadPage("http://www.youtube.com/rss/tag/" . urlencode($query).".rss");
    		$result=array();
    		$array=array();
    		preg_match_all("|<item>(.*?)</item>|s", $h, $array);
    		$cache="";
    		for($i = 0; $i < count($array[1]); $i++)
    		{
    			if (!$cached) $cache.="<item>". $array[1][$i]."</item>";
    			$l = array();
    			$l["title"] = $this->strip_tag("title", $array[1][$i]);
    
    			$z=$array[1][$i];
    			$l["url"] = str_replace("&amp;", "&", $this->strip_tag("link", $array[1][$i]));
    			preg_match("|<p>(.*?)</p>|si", $z, $a);
    			$l["desc"] = $a[1];
    			$l["pubDate"] = $this->strip_tag("pubDate", $array[1][$i]);
    			preg_match("|<media:thumbnail url=\"(.*?)\"|si", $z, $a);
    			$l["img"] = $a[1];
    			preg_match("|<media:category label=\"Tags\">(.*?)</media:category>|si", $z, $a);
    			$lol=explode(" ",$a[1]);
    			$l["tags"]=array();
    			for ($i2=0;$i2<count($lol);$i2++)
    			{
    				$tag=array();
    				$tag["e"]=$this->EncodeS($lol[$i2]);
    				$tag["d"]=$lol[$i2];
    				$l["tags"][]=$tag;
    			}
    
    			preg_match("|<enclosure url=\"(.*?)\"|si", $z, $a);
    			$l["url_swf"] = $a[1];
    			$result[] = $l;
    		}
    		if ((!$cached)&&($is_cached)&&(strlen($cache)>$min_cache_size)) $this->SaveCache('Y_'.$this->EncodeS(strtolower($query)).".gz", $cache);
    		return $result;
    	}
    }
    
    PHP:
    the $query is the word which i search about it

    the problem here the video link return with this format

    http://youtube.com/?v=ID

    and i want it in this format

    http://youtube.com/watch?v=ID

    Best regards
     
    Mr.samy, Apr 22, 2009 IP
  2. sliver

    sliver Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    maybe this can help you
     
    sliver, Apr 22, 2009 IP
  3. Mr.samy

    Mr.samy Member

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    Very good ..

    thanks man i fixed it from your link :) [​IMG]
     
    Mr.samy, Apr 22, 2009 IP