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 myusername@apple.com 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
@kukat
Copy link
Author

kukat commented Aug 28, 2015

another solution using Cookie Export to export cookies to cookies.txt

aria2c -c -x10 -s10 -U 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:33.0) Gecko/20100101 Firefox/33.0' --load-cookies=cookies.txt https://developer.apple.com/services-account/download\?path\=/iOS/iOS_9_beta_5/iOS_9_beta_5__iPhone_5s_Model_A1457_A1518_A1528_A1530__13A4325c.zip

@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