Blog

Resuming ADC downloads (‘cos Safari sucks)

So, Safari’s resume facility is just awful — it’ll randomly restart downloads from the beginning, clobbering anything that’s already been downloaded, and the resume button will frequently disappear entirely and mysteriously from the downloads window. And if the session has expired, it’ll cause all kinds of havoc.

Anyone downloading the gazillion-gb iOS/Mac SDK + XCode on a slow and/or expensive connection will know the sheer fisticuffs-inspiring irritation this creates — speaking personally, living on a mobile broadband connection that’s usually changed at £3 per gig and often runs about as fast as I could send the data via carrier pigeon, this usually makes me want to storm Cupertino with a pitchfork.

Okay, so I could probably use Firefox or something else, but instead I figured I’d whip up* a shell script that lets me use my favoured long-haul download tool – curl. And in case there were any other sufferers of insanely-priced broadband and Safari’s antisocial behaviour, I thought I’d share it.

It’ll ask for your Apple ID and password, and store it in the keychain for you, and it’ll resume from the current working directory.

Chuck it somewhere like /usr/local/bin, make sure it’s executable (chmod +x /usr/local/bin/adc_download.sh) and call it from Terminal like:

adc_download.sh https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4_gm_seed/xcode_4_gm_seed_.dmg

If you’ve already started the download in Safari, just grab the partially-downloaded file from within the .download package Safari creates.

Here ’tis:

ADC Download Script (on Github)

P.S. I’d be interested to see how incremental updates fare when transferred from an intermediate server with rsync. It’s rather bizarre that Apple reissue the whole 3.x gb SDK with each update, rather than offering a ‘patch’ (I guess Apple lives blithely in the world of cheap bandwidth!), and it makes me wonder whether there’d be sufficient correlation between versions to save some bandwidth by avoiding transferring the similarities…

* read: spend hours on, as is my way.

, , . Bookmark the permalink. Both comments and trackbacks are currently closed.

28 Comments

  1. Jon
    Posted February 5, 2011 at 10:25 pm | Permalink

    Safari resumed my Xcode4GM download just fine when I saw my download speed had dropped to almost nothing. Restarting resumed from the right place but with a different server so my speed was better.

    • Posted February 6, 2011 at 10:15 am | Permalink

      Yes, it does resume fine from time to time, especially if you restart immediately. I suspect the failure’s related to session expiry, and possibly quitting Safari.

  2. Sylvain Defresne
    Posted February 9, 2011 at 2:09 pm | Permalink

    Thank you for the script. It is also really useful for cheap broadband connection that are really instable (such as my connection that I have to restart every hour or so).

    • Posted February 9, 2011 at 3:58 pm | Permalink

      No worries! I’m glad to hear it’s of use to someone else too!

  3. Posted March 24, 2011 at 5:44 am | Permalink

    Thanks Michael, awesome script! The really cool part was I didn’t need to do anything besides downloading and running the script.

    My download always ended up dying in Chrome.

  4. dave
    Posted May 7, 2011 at 3:56 pm | Permalink

    Has anyone used this script to download XCode 4..2 and SDK 4.3? I cannot for the life of me get it to work. I keep getting an “Access Denied” message returned.

    I have double-checked my Apple ID and password, removed the “daw…” entries from Keychain, removed the adccookies.txt and tried every combination I can think of and no dice.

    Here’s the URL i’m trying to use– is it wrong? http://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.3__final/x code_4.0.2_and_ios_sdk_4.3_final.dmg

    • Posted May 7, 2011 at 8:21 pm | Permalink

      This appears to be either the wrong URL, or an issue with ADC – I’m getting the same “Access Denied” message even when I try to access the URL with Chrome.

    • jb
      Posted July 26, 2011 at 7:56 am | Permalink

      To fix this:

      1. Login to ADC with a browser.
      2. Click on Member Center.
      3. Accept the new and improved license terms from Apple.

      Proceed with download.

  5. dave
    Posted May 8, 2011 at 2:50 am | Permalink

    Hmm… not sure where I got that URL from. Logged in again and got this URL, appears to be working:

    https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/x code_4.0.2_and_ios_sdk_4.3/xcode_4.0.2_and_ios_sdk_4.3.dmg

  6. maverick
    Posted May 28, 2011 at 3:13 am | Permalink

    Thanks Mike, after wasting one full day on firefox and finally getting checksum error with the dmg ,I have switched to your script..hope it will run good tomorrow when its over !

  7. Posted May 31, 2011 at 10:12 pm | Permalink

    Great script, but doesn’t work for me as I get a web page asking which of the multiple teams I want the download for :-(

  8. Posted June 22, 2011 at 5:31 pm | Permalink

    Dude, sweet. This is just awesome. Many thanks.

  9. Posted July 11, 2011 at 6:59 pm | Permalink

    For a while, this was working for me, even though I’m on multiple teams, but now I’m seeing the same issue as Sam Joseph: it only serializes out the team picker page. Darn.

  10. Glen
    Posted August 21, 2011 at 1:29 am | Permalink

    Life saver.. Thanks for the work.

    Works great here.

    Glen.

  11. syntax error
    Posted May 16, 2012 at 3:21 pm | Permalink

    adc_download.sh: line 86: syntax error near unexpected token fi' adc_download.sh: line 86:fi’

    Snow Leopard 10.6.2

    • Posted May 16, 2012 at 5:44 pm | Permalink

      Oh, my – dunno how that happened, but an invalid character crept in there, perhaps when someone added a feature to it. I just fixed it; try again.

  12. Posted July 31, 2012 at 10:34 am | Permalink

    I’m creating a Mountain Lion bootstrap script and this is a life saver!

    Just wondering if you have this script in a vcs somewhere? I see you have a GitHub account, but could not find it there. This would make it easier to link to a specific version so my script does not stop working if adc_downloader.sh is changed in a non-backwards compatible way.

  13. Matt Hauck
    Posted August 19, 2012 at 11:54 pm | Permalink

    One more modification needed: Change the team login URL to https.

    teamloginURL=”https://developer.apple.com/devcenter/saveTeamSelection.action”

  14. smtabatabaie
    Posted May 19, 2013 at 1:21 am | Permalink

    Hi , I’m new to mac terminal . in recent days I’ve tried to download xcode 4.6 and everytime it finishes download the dmg file change to an 8kb file name login.html! I wanted to use your script to dowload it . I copied your script to my /usr/bin and ran it in terminal like this :

    adc_download.sh http://adcdownload.apple.com/Developer_Tools/xcode_4.6/xcode460417218a.dmg

    but every time I get this error : “0Warning: Failed to create the file xcode460417218a.dmg:permission denied” and “curl:(23) Failed writing body(0!=1130)”

    I’ll appreciate if you can help me with this . thanks

    • smtabatabaie
      Posted May 21, 2013 at 2:56 am | Permalink

      I put the script in my admin user directory ( not usr/bin) and it worked but after downloading 1.7GB dmg of xcode , I get the error that the image data is corrupted! :(

  15. Anthonia
    Posted May 20, 2013 at 12:33 pm | Permalink

    hey, michael I really have no idea how to do this. my problem is I can’t resume the download of a certain movie (1.1gb out of 1.8gb already). how do I use the script. I really can’t understand. sorry. if you could please explain in english ’cause I’m a noob T ^ T

  16. James
    Posted August 10, 2013 at 4:41 pm | Permalink

    Awesome script!