Skip to content

Instantly share code, notes, and snippets.

@closer
Created February 1, 2014 16:24
Show Gist options
  • Select an option

  • Save closer/8754589 to your computer and use it in GitHub Desktop.

Select an option

Save closer/8754589 to your computer and use it in GitHub Desktop.
Download tracks
require "mechanize"
agent = Mechanize.new
release = agent.get "http://maltinerecords.cs8.biz/release.html"
release.links.each do |link|
next unless link.text =~ /^\[MARU/
title = link.text.gsub(/\//, ":")
tracks = link.click.links.select{|l| l.href=~ /(mp3)$/ }
tracks.each_with_index do |track, n|
track_name = track.text.gsub(/\//, ":")
filename = "./down/#{title}/#{"%02d" % (n + 1)}_#{track_name}.mp3"
next if File.exist? filename
begin
track.click.save(filename)
rescue => e
puts e.message
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment