Youtuba Apiの簡単な使い方
そういやyoutube apiの説明してるサイトってあんま無かった気がするので簡単な説明
以下の順番で行えばいいはず
1. youtube.comとブラウザに打ち込んでyoutubeサイトに移動
2. 一番下に移動してHelp&infoにあるDeveloper APIs をクリック
3. Developer idを取得
4. sampleをみて実行したりして遊ぶ
5. プログラムに反映させる
apiの返り値はXMLになってるので情報を加工するに当たっては正規表現の使用が必須となりまする。
ちょっと飽きたのでここまで(ぇ
-
-
- -
-
youtube dev_docsの説明を見る
Video Viewing
youtube.videos.get_details
youtube.videos.list_by_tag (with paging)
youtube.videos.list_by_user (with paging)
youtube.videos.list_featured
youtube.videos.list_by_related (with paging)
youtube.videos.list_by_playlist (with paging)
youtube.videos.list_popular
youtube.videos.list_by_category_and_tag (with paging)
実際に見るのはここら辺になると思います その中でも一番使うのはtagになりますのでその詳細についてみてみるといいと思います
youtube.videos.list_by_tag (API Function Reference)
DescriptionLists all videos that have the specified tag
Parametersmethod: youtube.videos.list_by_tag (only needed as an explicit parameter for REST calls)
dev_id: Your developer ID. Please request one if you don't already have one.
tag: The tag to search for
(optional) page: The "page number" of results you want to retrieve (e.g. 1, 2, 3)
(optional) per_page: The number of results you want to retrieve per page (default 20, maximum 100)
Example Call
http://www.youtube.com/api2_rest?method=youtube.videos.list_by_tag&dev_id=dev_id&tag=tag&page=page&per_page=per_page
Example Response
k0gEeue2sLk
My First Motion Picture
16
3.75
10
This is the video description shown on the YouTube site.
170
1121398533
1
feature film documentary
http://www.youtube.com/watch?v=k04Eeue24Lk
http://static.youtube.com/get_still?video_id=k04Eeue24Lk
ok
tagの説明はちなみにこれです
method: youtube.videos.list_by_tag (only needed as an explicit parameter for REST calls)
dev_id: Your developer ID. Please request one if you don't already have one.
tag: The tag to search for
(optional) page: The "page number" of results you want to retrieve (e.g. 1, 2, 3)
(optionとして取得したデータのどのページからデータを取ってくるか決めることができる)
(optional) per_page: The number of results you want to retrieve per page (default 20, maximum 100)
(表示するページ数、デフォルトが20で、20~100まで?指定できる)
Example Call
http://www.youtube.com/api2_rest?method=youtube.videos.list_by_tag&dev_id=dev_id&tag=tag&page=page&per_page=per_page
これを見て色々と実験することになります
たとえば以下の内容をアドレスに打ち込むとharuhiタグで取得できるXMLが現れてくるはずです
ただしdev_id=your_idの部分は自分のidに変えてください
http://www.youtube.com/api2_rest?method=youtube.videos.list_by_tag&dev_id=your_id&tag=haruhi
取得されるXMLはこんな感じです
50117
Song Title: "Hare Hare Yukai(JPN) / Sunny Sunny Fun(ENG)" by Aya Hirano, Minori Chihara and Yuko Goto, the respective voices of the characters Haruhi Suzumiya, Yuki Nagato and Mikuru Asahina from the series.
Let's buy a more beautiful DVD version when liking it.
(ENG) http://www.asosbrigade.com/
(JPN) http://www.haruhi.tv/
(JPN) http://www.kyotoanimation.co.jp/haruhi/
517435
1169737580
666
Suzumiya Haruhi No Yuuutsu Melancholy Ending ED Full Dance Special Version 涼宮 ハルヒ 涼宮ハルヒ スペシャル バージョン
http://www.youtube.com/?v=N7ggMWYHUtc
http://img.youtube.com/vi/N7ggMWYHUtc/2.jpg
unavail
あとはこれを加工すればいろいろとできると思います。