This python script makes your life easier because you will get an updated SR/irating file of your teammates. You won't need to waste time visiting all profiles and updating a document. SR and iRating info is exported to a CSV file.
This script has been tested in Python 3.5, 3.6 and 3.7.
I recommend you to create a virtual environment and install all dependencies there. As soon as it's ready and activated, you can install all dependencies:
pip install -r requirements.txt
If you want to run tests, you have to install requirements-test.txt because they use nose and coverage.
pip install -r requirements-text.txt
And then type:
nosetests -v
You have to open settings.py and edit these two lines adding your iRacing email/password:
IRACING_EMAIL = 'YOUR EMAIL'
IRACING_PASSWORD = 'YOUR PASSWORD'
If you want to upload this script or share it, don't forget to remove your personal info from this file.
You need to create a .json file(name doesn't matter) and put the info of your teammates. You can have multiple files but you have to follow the following structure. (Note that names and ids are fictional)
{
"drivers":
[
{"name": "Archaon the Everchosen", "id":4012 },
{"name": "Garrett Branko", "id":1540}
]
}
The name can be different to the real one used on iR (useful if your mates have +4 names and you want a short version) but the id must be right or you will get stats from other guy.
Main.py is the only executable file and the behaviour can be changed using some commandline params:
$ main.py -h
$ main.py --help
This will show you a list of possible command-line flags.
$ main.py -f drivers.json
$ main.py --file files/drivers.json
Indicates the input file tha the script will use. You can have this file in the same level that main.py or different folder. It's a required flag so if you miss it you will get an error. In order to keep this tutorial simple, this flag is missing in the next explanations.
$ main.py -o stats.csv
$ main.py --output /output/stats.csv
By default stats are exported to a csv file named DriversStats.csv and you find it in the project root. With this flag, you can change the name of the file and exported to a different folder.
$ main.py --ignore 2
$ $ main.py --ignore 3,4
By default it exports oval,road and both dirt licences but this flag lets you skip those you don't care. Values must be between 1-4 and below you can see licence-number relation:
- 1: Oval
- 2: Road
- 3: Dirt-Oval
- 4: Dirt-Road
Examples:
Drivers.json file as input and both oval licences aren't exported. Output file will be DriversStats.csv.
$ main.py -f drivers.json --ignore 1,3
Drivers.json file (store in a folder) and info will be exported to a file named stats.csv.
$ main.py -f files/drivers.json -o stats.csv
Drivers.json (inside a folder) as input file, info will be exported to a file named stats.csv(inside a folder) and skip road info.
$ main.py -f files/drivers.json -o output/stats.csv --ignore 2
- Do I have to put my iRacing credentials?
Yes. iRacing doesn't have any API so the only valid method is using your account. It's fair you don't trust me but you can check my code.
- Have you used it?
It's running on my Raspberry Pi every morning.
- Where can I find the customerid?
If visit your mate's profile, his id is at the end of the url after ?custid=.
- I would love having the csv file on my Dropbox/GDrive folder or Discord channel automatically.
In the wiki section you will find a guide to upload it to Dropbox.
- Can I modify/copy it?
Of course!. It's under MIT Licence so feel free to do whatever you want. If you make an awesome feature you can create a PR.
V0.0.2 (17/02/2019)
- Added ignore licence flag and it won't appear in the csv file.
V0.0.1 (06/02/2019)
- Initial release.
Thanks to Juri, his laziness made this script possible ;).