Skip to content

Instantly share code, notes, and snippets.

@elecnix
Created November 29, 2008 17:10
Show Gist options
  • Save elecnix/30258 to your computer and use it in GitHub Desktop.
Save elecnix/30258 to your computer and use it in GitHub Desktop.
Downloads podcasts from grailspodcast.com
#!/usr/bin/ruby
# Downloads podcasts from http://www.grailspodcast.com
# Creates files named like this example:
# grails_podcast_episode_17 - Interview with Jason Rudolph.mp3
require 'rubygems'
require 'mechanize'
agent = WWW::Mechanize.new do |a|
a.user_agent_alias = 'Mac Safari'
end
archive = agent.get("http://www.grailspodcast.com/blog/list?offset=0&max=1000&sort=created&order=desc")
mp3s = archive.links.select do |link|
begin
link.uri.to_s.include? ".mp3"
rescue
end
end
puts "Found #{mp3s.size} MP3s"
captions = archive.links.select do |link|
link.text.include? "Grails Podcast Episode"
end
puts "Found #{captions.size} captions"
i=0
mp3s.each do |mp3|
cap = captions[i].text.split(':')[1]
cap = " -#{cap}" unless cap == nil
cap = '' if cap == nil
file = mp3.uri.to_s.split('/')[-1].insert(-5, cap)
`wget -N #{mp3} -O "#{file}"`
i+=1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment