Skip to content

Instantly share code, notes, and snippets.

@viking
Last active October 1, 2020 15:32
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 viking/cf6d24198a38b6979652 to your computer and use it in GitHub Desktop.
Save viking/cf6d24198a38b6979652 to your computer and use it in GitHub Desktop.
Script to download songs by coda
require 'rss'
require 'uri'
url = 'http://coda.s3m.us/feed/'
URI.open(url) do |rss|
feed = RSS::Parser.parse(rss, false)
feed.items.each do |item|
if item.enclosure
url = URI.parse(item.enclosure.url)
filename = File.basename(url.path)
if !File.exist?(filename)
puts "Fetching #{item.title}..."
URI.open(url) do |data|
File.open(filename, 'w') { |f| f.write(data.read) }
end
sleep 1
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment