YouTubeのFLVファイルの場所を探すphpプログラムです。
以前はget_video.phpに動画の固有IDを渡すだけでOKだったんですが、最近はいくつかクエリを追加しないとダメなようです。
ですので、いったんphpでYouTubeのサイトを取得し、正規表現で動画に必要なクエリ文字を抽出しています。
結構使うので関数化しました。
<?php //url => http://www.youtube.com/watch?v=動画の固有ID function getflvurl( $url ){ $getstringdata = file_get_contents( $url ); // FLVファイルを取得するための名前 $pattern = '/video_id=.*\&title=/'; preg_match( $pattern , $getstringdata , $matches); $rfname = "http://www.youtube.com/get_video.php?{$matches[0]}"; return $rfname; } ?>
flexでの実用はこんな感じ。
http://moeten.info/flex/20080223_youtube/bin/main.html