Skip to content

Instantly share code, notes, and snippets.

@jpommerening
Created May 6, 2013 10:22
Show Gist options
  • Save jpommerening/5524347 to your computer and use it in GitHub Desktop.
Save jpommerening/5524347 to your computer and use it in GitHub Desktop.
Get the current (estimation) of iTunes' 50 billion App countdown (see: http://www.apple.com/itunes/50-billion-app-countdown/)
#!/bin/sh
URL="${1:-http://www.apple.com/itunes/store/counters/il6ark7ec.js}"
JSON=`curl "$URL" 2>/dev/null`
getField () {
echo "$JSON" | sed 's/.*"'$1'" *: *\([0-9]\+\)[}, ].*/\1/p;d'
}
COUNT=`getField count`
RATE=`getField rate`
TIMESTAMP=`getField sampleTimestamp`
NOW=`date "+%s"`
expr "$COUNT" + "(" "$NOW" - "$TIMESTAMP" ")" "*" "$RATE" "/" "3600"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment