Jun 19, 2006
YouTube API にチャレンジ
YouTube とは
YouTube はビデオ共有サービスらしい。 しばらく前から話題になっていて気にはなっていたのだが、なかなか使ってみる機会がなかった。 調べてみたら API が公開されているということだったので、とりあえず API だけ遊んでみることにした。
- YouTube
- http://www.youtube.com/
- Developer APIs
- http://www.youtube.com/dev
試してみる
YouTube API を使用するには、YouTube のアカウントが必要。 まずは YouTube アカウント作成から行ってみた。
- YouTube SignUp から YouTube のアカウントを作成。
- developer profile で Developer ID を取得。
User Profile の取得
YouTube API は REST を採用している。
User Profile は下記の URL にアクセスすることで取得できる。
http://www.youtube.com/api2_rest?method=youtube.users.get_profile&dev_id=[Developer ID]&user=[プロファイルを取得したいユーザID]
<?xml version="1.0" encoding="utf-8"?>
<ut_response status="ok">
<user_profile>
<first_name />
<last_name />
<about_me />
<age>55</age>
<video_upload_count>0</video_upload_count>
<video_watch_count>0</video_watch_count>
<homepage />
<hometown />
<gender>m</gender>
<occupations />
<companies />
<city />
<country>JP</country>
<books />
<hobbies />
<movies />
<relationship />
<friend_count>0</friend_count>
<favorite_video_count>0</favorite_video_count>
<currently_on>true</currently_on>
</user_profile>
</ut_response>
Vide リストを取得
YouTube では Video にタグ付けができるらしい。
現在(2006/06/19) の YouTube API では Video リストはタグ単位、ユーザ単位で取得できる。
とりあえず "cat" というタグのついた Video リストを取得してみた。
URL は下記の通り。
http://www.youtube.com/api2_rest?method=youtube.videos.list_by_tag&dev_id=[Developer ID]&tag=cat
<?xml version="1.0" encoding="utf-8"?>
<ut_response status="ok">
<video_list>
<video>
<author />
<id>HsNYrJDwguo</id>
<title>cat</title>
<length_seconds>183</length_seconds>
<rating_avg>3.46</rating_avg>
<rating_count>54</rating_count>
<description>cat</description>
<view_count>51380</view_count>
<upload_time>1145383314</upload_time>
<comment_count>33</comment_count>
<tags>cat</tags>
<url>http://www.youtube.com/?v=HsNYrJDwguo</url>
<thumbnail_url>http://sjl-static6.sjl.youtube.com/vi/HsNYrJDwguo/2.jpg</thumbnail_url>
</video>
snip...
</video_list>
</ut_response>
TrackBack ping me at
http://www.in-vitro.jp/blog/index.cgi/WebService/20060619_01.trackback
writeback message: Ready to post a comment.
