Skip to content

Instantly share code, notes, and snippets.

Created May 19, 2013 17:19
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 anonymous/5608328 to your computer and use it in GitHub Desktop.
Save anonymous/5608328 to your computer and use it in GitHub Desktop.
gsl.rb
#!/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