|
Project Information
Featured
Downloads
|
IntroductionAppDailySales is a Python script that will download daily sales report files from the iTunes Connect web site. Source Code Repository Has MovedThe source code repository for this script has moved to github. It is now available at: https://github.com/kirbyt/appdailysales How to UseAppDailySales can be used as a stand-alone program or as part of another script. Use as Stand-alone ProgramDownload the script appdailysales.py and run the command line:
usage: appdailysales.py [options] Options and arguments: -h : print this help message and exit (also --help) -a uid : your apple id (also --appleId) -p pwd : your password (also --password) -P : read the password from stdin (also --passwordStdin) -o dir : directory where download file is stored, default is the current working directory (also --outputDirectory) -v : verbose output, default is off (also --verbose) -u : unzip download file, default is off (also --unzip) -d num : number of days to download, default is 1 (also --days) -D mm/dd/yyyy : report date to download, -d option is ignored when -D is used (also --date) -f format : output file name format (see strftime; also --format) -n : used with -f, skips downloading of report files that already exist (also --noOverWriteFiles) --proxy : URL of the proxy -- debug : debug output, default is off You can also change the option variables located towards the top of the script file if you prefer to not use the command line options. However, this approach is not recommended with version 1.2 and greater of the script file. Note: The script will return the exit code 0 if successful, otherwise exit code 1 is returned. Use as Part of Another ScriptAs of Version 1.3 the AppDailySales script can be used as part of another script. Simply import appdailysales, set the report options, and call the downloadFile function. Here is a sample script file to help you get started: #!/usr/bin/python
import sys
import traceback
import appdailysales
def main():
options = appdailysales.ReportOptions()
options.appleId = 'Your Apple Id'
options.password = 'Your Password'
options.outputDirectory = ''
options.unzipFile = False
options.verbose = False
try:
filename = appdailysales.downloadFile(options)
print 'Report file downloaded: ', filename
except:
traceback.print_exc()
if __name__ == '__main__':
main()The function appdailysales.downloadFile will return the name of the last file downloaded. Be sure to include a try..except block around the call to gracefully handle any errors that might occur during the download. Download Reports Multiple DaysAs of version 1.6, there is a -d (also --days) option that is used to specify the number of days to download. The default is 1, which will download yesterday's report and keeps the script backwards compatible with the previous versions. Any value can be used for this option. However please note that as of now Apple only stores the last 7 days of daily sales reports. Using a value greater than 7 will result in a "report not available" error. Why not add a check in the script to prevent values greater than 7? I decided not to include the check on the off chance Apple decides to provide access to reports older than 7 days. Report File Name FormattingVersion 2.1 introduces the new -f (also --format) option. This option allows you to reformat the report file name. The format is specific as per strftime (see man page), e.g. "%Y-%m-%d-daily.txt.gz" would give you "2010-09-16-daily.txt.gz". By default, the report file is compressed. When using the -f option, be sure to include the appropriate file name extension, e.g., ".gz". Use the -u option to have the script uncompress the file for you. The script will automatically strip the .gz extension if present. What Version of PythonThe script was written for and has been tested with Python version 2.5.x, 2.6.x, and 2.7.x. It is doubtful the script will work with Python 3.x without some tweaking. Debugging the ScriptVersion 2.4 introduces the new --debug flag. This flag will display additional verbose output for debugging and troubleshooting the script. Also, when this flag is turned on and the script encounters a screen scraping error, a file named temp.html is created and stored in the output directory. This file contains the HTML downloaded in the last web request. Change HistoryVersion 2.9
Version 2.8
Version 2.7
Version 2.6
Version 2.5
Version 2.4
Version 2.3
Version 2.2
Version 2.1
Version 2.0.2
Version 2.0.1
Version 2.0
Version 1.10
Version 1.9
Version 1.8.1
Version 1.8
Version 1.7
Version 1.6
Version 1.5
Version 1.4
Version 1.3
Version 1.2
Version 1.1
ContributorsSpecial thanks goes out to the following individuals for contributing to this project:
Some Final WordsI created this script with the iPhone developer in mind. Being an iPhone developer myself I don't want to remember to download the daily sales report from yesterday's activity so I wrote this script. I have a cron job scheduled on a server that will download each day's report for me so I don't have to. Ain't automation great. |