-
-
Save kukat/6341318 to your computer and use it in GitHub Desktop.
aria2 downloader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'mechanize' | |
if ARGV.size < 3 | |
puts %q{Usage: ruby xcode.rb USERNAME PASSWORD "DOWNLOAD_URL" [WGET_PARAMS]} | |
puts %q{Example: ruby xcode.rb [email protected] 123456 "https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4_and_ios_sdk_4.3__final/xcode_4_and_ios_sdk_4.3__final.dmg" } | |
exit | |
end | |
a = Mechanize.new { |agent| | |
agent.user_agent_alias = 'Mac Safari' | |
} | |
a.get('https://developer.apple.com/') do |page| | |
member_page = a.click(page.link_with(:text => /Member Center/)) | |
login = member_page.form_with(:name => 'appleConnectForm') do |form| | |
form.theAccountName = ARGV[0] | |
form.theAccountPW = ARGV[1] | |
end.submit | |
a.redirect_ok = false | |
download_page = a.get(ARGV[2]) | |
system %Q{ aria2c -c -s10 -x10 #{download_page.response["location"]} --header "Cookie: #{download_page.response["set-cookie"]}" #{ARGV[3]}} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
another solution using Cookie Export to export cookies to
cookies.txt