Created
May 19, 2013 17:19
-
-
Save anonymous/5608328 to your computer and use it in GitHub Desktop.
gsl.rb
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
#!/usr/bin/env ruby | |
# | |
# Created by: esdf | |
# GSL VOD parser | |
require 'net/http' | |
require 'rexml/document' | |
uri = URI.parse('http://api.justin.tv/api/channel/archives/gomtv.xml?limit=10'); | |
begin | |
response = Net::HTTP.get_response(uri); | |
if response.code != "200" | |
raise | |
end | |
rescue | |
puts "Failed to fetch the vods :/" | |
exit 1 | |
end | |
begin | |
xmlDoc = REXML::Document.new response.body | |
rescue | |
puts "Bad XML :/" | |
exit 1 | |
end | |
xmlDoc.elements.each('objects/object') { | |
|object| | |
puts "%s - %s - %s (Part %s)\n" % | |
[ | |
object.elements['title'].text, | |
object.elements['created_on'].text, | |
object.elements['video_file_url'].text, | |
object.elements['broadcast_part'].text | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment