Skip to content

Instantly share code, notes, and snippets.

@futuretap
Created October 21, 2014 20:19
Show Gist options
  • Save futuretap/69c6289e791b10b43fba to your computer and use it in GitHub Desktop.
Save futuretap/69c6289e791b10b43fba to your computer and use it in GitHub Desktop.
Download the last 12 months of Financial Reports from iTunes Connect (uses Apples Autoingestion tool)
#!/bin/bash
VENDORID=80012345
DATAFOLDER="${HOME}/Sales Reports"
CLASSPATH="${HOME}/bin"
ZVENDORID=`printf %.10d ${VENDORID}`
for i in 1 2 3 4 5 6 7 8 9 10 11 12; do
for REGION in "AE" "AU" "CA" "CH" "CN" "DK" "EU" "GB" "HK" "ID" "IL" "IN" "JP" "MX" "NO" "NZ" "RU" "SA" "SE" "SG" "TR" "TW" "US" "WW" "ZA" ; do
MYFILE=`date -v -$((i))m +"${VENDORID}_%m%y_${REGION}.txt"`
if [ ! -e "$DATAFOLDER/$MYFILE" ] ; then
ai=`printf "%+d" $((3-i))`
FISCAL_MONTH=`date -v ${ai}m +"%m"`
FISCAL_YEAR=`date -v ${ai}m +"%Y"`
echo -n "downloading ${MYFILE}"
if RESULT=`java -cp "${CLASSPATH}" Autoingestion autoingestion.properties ${ZVENDORID} ${REGION} DRR ${FISCAL_YEAR} ${FISCAL_MONTH} | grep .txt.gz`
then
echo " succeeded"
gunzip -f "${MYFILE}.gz"
mv -f ${MYFILE} "$DATAFOLDER/$MYFILE"
else
echo " failed (probably no sales)"
fi
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment