Skip to content

Instantly share code, notes, and snippets.

@dulltz
Last active December 27, 2015 03:40
Show Gist options
  • Select an option

  • Save dulltz/c9ffc69e69b9e2956674 to your computer and use it in GitHub Desktop.

Select an option

Save dulltz/c9ffc69e69b9e2956674 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'open-uri'
base_urls = %w(http://mgkkk.cocolog-nifty.com/blog/files/
http://mgkkk.la.coocan.jp/podcast/
)
start_i = ARGV[0].nil? ? 0 : ARGV[0].to_i
end_i = ARGV[1].nil? ? 211 : ARGV[1].to_i
base_i=0
for i in start_i..end_i
begin
puts "start dl:\t#{base_urls[base_i]}episode#{i}.mp4"
open(base_urls[base_i] + "episode#{i}.m4a") do |dlfile|
File.open("episode#{i}.m4a", "wb") do |output|
output.puts dlfile.read
end
end
puts "done dl:\t#{base_urls[base_i]}episode#{i}.mp4"
rescue OpenURI::HTTPError => e
base_i += 1
break if base_urls[base_i].nil?
retry
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment