-
Notifications
You must be signed in to change notification settings - Fork 0
/
apple-download
executable file
·41 lines (32 loc) · 1.07 KB
/
apple-download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env ruby
def canRun?(command)
system("which #{command} > /dev/null 2>&1")
end
begin
downloadApp = "aria2c"
if !canRun?(downloadApp)
abort("\"#{downloadApp}\" is not available. Please install with: brew install #{downloadApp}")
end
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 = <<-EOF.gsub(/\s+/, " ").strip
#{downloadApp}
--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
EOF
print "% #{command}".gsub(" -", "\n -").gsub(url, "\n #{url}"), "\n"
exec(command)
rescue Exception => e
print "\n"
exit
end