Addic73d Posted July 18, 2011 Report Posted July 18, 2011 (edited) getTrailersFromYoutube.php<?phpsession_start();function veziArray($array) {echo '<pre>';print_r($array);echo '</pre>';}function xmlstr($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len);}$trailereNoi = array('Kung Fu Panda 2', 'John Carter', 'Zookeeper', 'Animals United', 'Magic Trip', 'Crazy, Stupid, Love.', 'Amigo', 'Higher Ground', 'Contagion', 'The Devil\'s Double', 'Friends with Benefits', 'Harry Potter and the Deathly Hallows - Part 2', 'The Pirates! Band of Misfits', 'Hugo', 'Winnie the Pooh');foreach($trailereNoi as $nume) {$sursa = file('http://www.youtube.com/results?search_query='.urlencode($nume).'official+trailer+2011+[HD]+&aq=f');$i = 380;while($i <= 420) {$link = $sursa[$i];$getLink = xmlstr($link, ' <a href="', '"');$completeLink = 'http://www.youtube.com'.$getLink;if(strlen($completeLink) == 42) {// echo "<a href=$completeLink>$nume</a><br />";echo '<a href="trailer.php?film='.urlencode($nume).'&link='.$getLink.'">'.$nume.'</a><br />';} $i++; } }?>trailer.php<?phpfunction veziArray($array) {echo '<pre>';print_r($array);echo '</pre>';}function xmlstr($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len);}if(isset($_GET['link'])) {$link = $_GET['link'];$trailerPage = file_get_contents('http://www.youtube.com'.$link);$trailer = xmlstr($trailerPage, '<embed type="application/x-shockwave-flash"', 'bgcolor="#000000">');echo '<embed type="application/x-shockwave-flash"'.$trailer.'bgcolor="#000000">';}?>L-am testet pe localhost si merge foarte bine, cu optiunea ca getTrailersFromYoutube.php se incarca mai greu datorita faptului ca nu am stat sa filtrez continutul in care s-a facut search.Ideea e ca, in momentul in care verific script-ul din exteriorul localhost-ului, sau il pun pe host in locul trailerului imi apare "Am intampinat o eroare, incercati mai tarziu".Ceva idei?? Edited July 18, 2011 by Addic73d Quote