Created
December 1, 2011 15:46
-
-
Save nobusue/1417709 to your computer and use it in GitHub Desktop.
G* Advent Calendar 2011/12/02: G*といえば猫、ということでYouTubeから子猫動画をランダムに再生
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
?category=kittenのところを変更すれば、他のキーワードでも検索できます。
詳細はhttp://code.google.com/intl/ja/apis/youtube/2.0/developers_guide_protocol_category_keyword_browsing.html 参照。