Youtube´dan video çekmek için kullanılan PHP script.

nssasmazNursin ŞaşmazAvatar

Youtube videolarını çekmeye yarayan PHP script

 

<?

if($q){

$q = ereg_replace(´[[:space:]]+´, ´/´, trim($q));

$i = 25;

$youtubefeed = "http://gdata.youtube.com/feeds/api/videos/-/{$q}";

//$youtubefeed = "http://gdata.youtube.com/feeds/api/videos/-/{$q}?orderby=viewCount&max-results={$i}";

$sxml = simplexml_load_file($youtubefeed);

$counts = $sxml->children(´http://a9.com/-/spec/opensearchrss/1.0/´);

$total = $counts->totalResults; 

$startOffset = $counts->startIndex; 

$endOffset = ($startOffset-1) + $counts->itemsPerPage;       

foreach ($sxml->entry as $entry) {

// media nesnelerini al

$media = $entry->children(´http://search.yahoo.com/mrss/´);

// youtube player urlsini al

$attrs = $media->group->player->attributes();

$watch = $attrs[´url´]; 

// video ön izleme resmini al

$attrs = $media->group->thumbnail[0]->attributes();

$thumbnail = $attrs[´url´]; 

// <yt:duration> video süresini al

$yt = $media->children(´http://gdata.youtube.com/schemas/2007´);

$attrs = $yt->duration->attributes();

$length = $attrs[´seconds´]; 

// <gd:rating> video reytingini al

$gd = $entry->children(´http://schemas.google.com/g/2005´); 

if ($gd->rating) {

$attrs = $gd->rating->attributes();

$rating = $attrs[´average´]; 

} else {

$rating = 0; 

}

$timecode = sprintf("%0.2f", $length/60);

$timecode = str_replace(´.´, ´:´, $timecode);

$tmp = explode(´=´,$watch)

/* kayıtları yaz

//echo "URL : {$watch}, Önizleme resmi : <img src="$thumbnail"/>n";

echo "İzleme linki <a href="{$watch}"> Başlık : {$media->group->title}</a><br/>n";

echo "Süre : [" . $tmp[1] . "]<br/>n";

*/

?>

<span class="clear"></span> 

<div class="item"> 

<a class="song"  onclick="dinle(´<?=$tmp[1];?>´);" href="javascript:void(0);" title="<?echo $media->group->title;?>">

        [<?echo $timecode;?>] <?echo $media->group->title;?>

        </a> 

<span class="clear"></span> 

</div> 

<?

}

echo "<br/>";

}

?>

Kunth adlı phpkodlari.com üyesinin bu sayafadaki cevabıdır.

Gitme vakti gelince gitmek mi zordur kalmak mı?
2010-02-25 10:31:40 Edit:2010-02-25 10:34:58

zipli

Nursin bu tip uzun kodları zipleyip atsan daha iyi olur. çünkü bazı noktalama işaretleri bozuluyor.

Her programcı birgün Php yi tadacaktır
2010-02-25 12:10:58 Edit:2010-02-25 14:15:31

nasıl

hocam peki bu script i nasıl kullancağız

2010-02-28 18:35:09

nasıl

KunthMesut Cemil ASLANAvatar

kopyala, boş bir dosyaya yapıştır, uzantısını php olarak kaydet, server tarafına yükle, çalıştır.

Kunth, just kunth...
2010-03-01 00:00:59

nasıl

hocam yaptım localda çaliştirdim bir birine girmiş kodlar çıkıyor local'denmi kaynaklanıyor acaba?

2010-03-01 19:00:07 Edit:2010-03-02 14:19:37

MynakTurkmynak turkAvatar

script buraya yazıldığı için bazı karakterlerde sorun yaşayabilirsiniz.

örneğin : ´ olan yerlere " işeretiyle değiştirin.

artı çalışması için kodun başına şunları yazmanız gerekir.

$q = $_GET["q"];

çalışmtırmak için ise;

localhost/dosyaismi.php?q=aranacakKelime

kodu bizimle paylaşan arkadaşa burdan sonsuz teşekkürler.

youtube api hakkında Türkçe kaynak yoktu bu ilk oldu sanırım :)

2010-03-05 01:54:08

problem

Arkadaşlar bn bunu çaliştiramdım dediğiniz uyguladım ama problem var aşağıdaki gibi yardım ederseniz seviniim yada doğru scripti upload eerseniz çok güzel olur

children("http://a9.com/-/spec/opensearchrss/1.0/"); $total = $counts->totalResults; $startOffset = $counts->startIndex; $endOffset = ($startOffset-1) + $counts->itemsPerPage; foreach ($sxml->entry as $entry) { // media nesnelerini al $media = $entry->children("http://search.yahoo.com/mrss/"); // youtube player urlsini al $attrs = $media->group->player->attributes(); $watch = $attrs["url"]; // video ön izleme resmini al $attrs = $media->group->thumbnail[0]->attributes(); $thumbnail = $attrs["url"]; // video süresini al $yt = $media->children("http://gdata.youtube.com/schemas/2007"); $attrs = $yt->duration->attributes(); $length = $attrs["seconds"]; // video reytingini al $gd = $entry->children("http://schemas.google.com/g/2005"); if ($gd->rating) { $attrs = $gd->rating->attributes(); $rating = $attrs["average"]; } else { $rating = 0; } $timecode = sprintf("%0.2f", $length/60); $timecode = str_replace(".", ":", $timecode); $tmp = explode("=",$watch) /* kayıtları yaz //echo "URL : {$watch}, Önizleme resmi : n"; echo "İzleme linki Başlık : {$media->group->title}
n"; echo "Süre : [" . $tmp[1] . "]
n"; */ ?>  

"; } ?>
2010-03-05 12:56:51

MynakTurkmynak turkAvatar

eve gidince dosya olarak upload ederim dostum. ama sanki senin localhosttan kaynaklanıyor hata :)

2010-03-05 14:15:48

hımm

hımm olabilir ama sanmıyorum yinede yapcağınız upload için teşekkürler

2010-03-05 18:45:06

MynakTurkmynak turkAvatar

http://www.tekdosya.com/files/RQ40199SH/5f9dd462c453806cf2fb619b8ce39afb/youtube.zip.html

buyur dostum dosyayı çalışması ;

localhost/youtube.php?q=duman

2010-03-05 22:49:44

phpkodlari.com © 2009 Herkes Php öğrenecek
Eglence ve Oyun: Gamikro