Skip to content

Instantly share code, notes, and snippets.

@nobusue
Created December 1, 2011 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nobusue/1417709 to your computer and use it in GitHub Desktop.
Save nobusue/1417709 to your computer and use it in GitHub Desktop.
G* Advent Calendar 2011/12/02: G*といえば猫、ということでYouTubeから子猫動画をランダムに再生
def feed = new XmlSlurper().parse(
"http://gdata.youtube.com/feeds/api/videos?category=kitten")
def uri = feed.entry[(int)(Math.random()*feed.itemsPerPage.toInteger())]
.link.find{it.@rel == 'alternate'}.@href
java.awt.Desktop.getDesktop().browse(new URI(uri.toString()))
@nobusue
Copy link
Author

nobusue commented Dec 1, 2011

?category=kittenのところを変更すれば、他のキーワードでも検索できます。
詳細はhttp://code.google.com/intl/ja/apis/youtube/2.0/developers_guide_protocol_category_keyword_browsing.html 参照。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment