Skip to content

Instantly share code, notes, and snippets.

@tippenein
Last active December 15, 2015 21:49
Show Gist options
  • Save tippenein/5328240 to your computer and use it in GitHub Desktop.
Save tippenein/5328240 to your computer and use it in GitHub Desktop.
pull podcasts from jet set planet page.
#!/usr/bin/ruby
#file: get_jetset.rb
require 'net/http'
require 'open-uri'
path = '/home/tippenein/podcasts/jet-set-planet/'
uri = URI('http://kfai.org/jet-set-planet')
body = Net::HTTP.get(uri)
body.scan(/https?:\/\/[\S]+.mp3/).each do |link|
filename = link.match(/([^\/]+$)/).to_s
path_to_file = File.join(path, filename)
unless Dir.entries(path).include? filename
puts "pulling from #{link}"
open(path_to_file, 'wb') do |file|
puts "saving #{file}"
file << open(link).read
end
else
puts "#{filename} is already in the archive"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment