Skip to content

Instantly share code, notes, and snippets.

@kukat
Forked from derencius/xcode.rb
Last active September 13, 2016 07:18
Show Gist options
  • Save kukat/6341318 to your computer and use it in GitHub Desktop.
Save kukat/6341318 to your computer and use it in GitHub Desktop.
aria2 downloader
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
@mantislin
Copy link

mantislin commented Sep 13, 2016

Tried @kukat 's Cookie Export one, it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment