Skip to content

Instantly share code, notes, and snippets.

@onoakino
Forked from manishpathak99/xcode-downloader.rb
Created May 25, 2020 03:01
Show Gist options
  • Save onoakino/ac12b8c5e2f5762b5f4cb4c89ff2cec8 to your computer and use it in GitHub Desktop.
Save onoakino/ac12b8c5e2f5762b5f4cb4c89ff2cec8 to your computer and use it in GitHub Desktop.
Script for reliably downloading binaries (e.g. Xcode) from Apple's CDN
#!/usr/bin/env ruby
print "What is the URL of your Apple Downloads resource?\nURL:"
url = gets.strip
print "What is the ADCDownloadAuth cookie token:\nADCDownloadAuth: "
token = gets.strip
command = "aria2c --header \"Host: adcdownload.apple.com\" --header \"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\" --header \"Upgrade-Insecure-Requests: 1\" --header \"Cookie: ADCDownloadAuth=#{token}\" --header \"User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 10_1 like Mac OS X) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/10.0 Mobile/14B72 Safari/602.1\" --header \"Accept-Language: en-us\" -x 16 -s 16 #{url} -d ~/Downloads"
exec(command)
@onoakino
Copy link
Author

How to use:

Steps to download xcode with resume functionality

1- Install View Cookies extension for firefox.
2- Copy script Ian Dundas save asdownload_xcode.rb
3-Edit the script
4- Open firefox (Safari, Chrome), then open https://developer.apple.com/download/
5- Log in with apple id account
6- Click Download then click save File
7- Show all downloads on firefox, then on xcode download process, right click, copy download link. This is my https://download.developer.apple.com/Developer_Tools/Xcode_9_beta_5/Xcode_9_beta_5.xip link.
8- Run the script download_xcode.rb
9- Will be asked to enter the download link, paste the link earlier.
then it will be prompted to enter a cookie ADCDownloadAuth
10- Go back to page https://developer.apple.com/download/ then press cmd+ i, go to Cookies tab
On Safari > Develop > Show Page Resources > Storage
On Chrome, install "Cookies.txt" extension by Genuinous
11- Search cookie named ADCDownloadAuthand copy valueit
Done, the download will start with resume support.

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