Skip to content

Instantly share code, notes, and snippets.

@song940
Created March 11, 2014 03:28
Show Gist options
  • Save song940/9478970 to your computer and use it in GitHub Desktop.
Save song940/9478970 to your computer and use it in GitHub Desktop.
HappyCast.net Episodes Downloader .
#encoding = utf-8
require "nokogiri"
require "open-uri"
def fetch_page(i)
page_url = "http://happycasts.net/episodes/#{i}"
begin
doc = Nokogiri::HTML(open(page_url))
link = doc.css('a.download').first
link.attributes['href'].to_s
rescue
puts "404 not found."
end
end
def fetch_video
n = 1
while (video_url = fetch_page(n)) =~ /mov/ do
filename = File.basename(video_url)
puts "Download video #{filename}"
if File.exist? filename
puts "#{filename} already exist ."
else
`wget #{video_url}`
end
n = n + 1
end
end
def main
fetch_video
end
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment