jump to navigation

When Will the App Store Cross One Billion? April 13, 2009

Posted by Robert Harder in Utility.
trackback

With Apple giving away great loot ($10,000 iTunes Gift Card, an iPod touch, a Time Capsule, and a MacBook Pro) when they reach the One Billionth Download (American, not British “billion”), what I want to know is when I need to start feverishly downloading apps or filling out the no-purchase-necessary entry form. Consequently I’ve written this little widget that uses Apple’s own statistics to estimate the crossover point. [Now that we’re past, I’ve locked the “prediction” down to the last posted Apple statistic before the crossover. -Rob]

http://blog.iharder.net/wp-content/uploads/2009/04/appstore.js.php

Apple only seems to be updating their statistics once per hour, so there’s no point in refreshing very often. Of course their predicted selling rate changes as well, so don’t come crying to me when you don’t when the Ten Grand!

appstore-counter-sample

Is it Accurate?

No.

These things never are, but they’re fun. Here’s a chart someone else made up that shows how the rate changes often. That would throw off the prediction pretty badly. I could try to do some kind of running average, but simply put, I don’t think I will.

Chart courtesy "Sendai" on #macosx

Chart courtesy "Sendai" on #macosx

Include On Your Page

You can put this on your own page (it’s only meaningful this week) by adding the following javascript to your page:

http://blog.iharder.net/wp-content/uploads/2009/04/appstore.js.php

If you want to style it at all, here’s an example of the generated HTML:

iPhone App Store Predicted Crossover
Monday, April 20th 2009
7:27:07 PM PDT
Last Apple statistic: 13-APR-2009 19:00:00|949483732|299885
</div>

How It’s Calculated

Looking at the HTML source for Apple’s countdown page, I examined the javascript file at http://images.apple.com/global/scripts/downloadcounter.js and a sort of data file that was referenced at http://images.apple.com/autopush/us/itunes/includes/countdown.txt. The countdown.txt file was interesting. I’m guessing there’s a cron job that does some calculations and dumps this text file out once per hour. It looks like this:

13-APR-2009 20:00:00|949783866|300134

The script file itself was a bit obfuscated but not badly. The function dataRequestDidFinishLoading, called in response to an AJAX fetch, told the whole story:

dataRequestDidFinishLoading: function(n) {
    var j = n.responseText.split("|"),
    m,
    c,
    i,
    f,
    k,
    g,
    b,
    e,
    d,
    l,
    a,
    h;
    if (j.length === 3) {
        m = j[0].split(" ");
        c = m[1];
        date = m[0].split("-");
        this.setRate(parseInt(j[2]) / 3600000);
        k = date[0];
        f = date[1];
        i = date[2];
        a = Date.parse(f + " " + k + ", " + i + " " + c + " GMT-0700");
        d = new Date(a + 3600000);
        l = d.getTime() - a + 1000;
        this._nextUpdateTimeout = setTimeout(this.loadData.bind(this), l);
        b = new Date();
        this._lastReferenceTime = b.getTime();
        e = this._lastReferenceTime - a;
        h = Math.floor(parseInt(j[1]) + e * (this._rate));
        this.setCurrentCount(h);
        this.setNeedsDisplayIfNeeded()
    }

I followed  a similar logic stream, but because my browser (and yours, hopefully) tries to guard against cross-site scripting, or possibly because I wasn’t smart enough to get around it, I couldn’t make a similar AJAX call to Apple’s countdown.txt file since it comes from a different domain than where my script was loaded. Instead I have the ugly hack of having PHP dynamically generate the JavaScript file on the fly. The PHP server makes a call to Apple’s countdown.txt file and hard-wires it into the script as it’s downloaded.

Enjoy! Let me know if you discover any errors in my math.

Comments»

1. Robert Harder - April 20, 2009

Nearly there!

2. Sommer - October 14, 2014

Pretty! This was an incredibly wonderful article. Many thanks for
supplying this info.

3. Barbara - November 14, 2014

You could definitely see your skills within the article you write.
The world hopes for more passionate writers
like you who are not afraid to mention how they believe.

At all times go after your heart.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: