Logs playtime of Steam games to a local text file and/or to a Google Sheets spreadsheet.
The target application is VR arcades, where game developers want to know how much their game is being played.
Steam shows playtimes in the web interface, so you could scrape the data from the webpage. Here's the display on my very actiev Steam profile:
We get this data directly by using the Steam API. You can see what output from the API looks like in steam_api_response.txt
.
- Get a Steam API key at http://steamcommunity.com/dev/apikey and put it in
steamid
- If you want to save logs to Google Sheets:
- Follow Google's Python Quickstart
- Save the various JSON files in this directory
- Create a new spreadsheet on Google Sheets and put the ID in
spreadsheet_id
- Create a folder called
out
in this directory, or changepath
to change where files are written - Find the appIDs of the games you want to log, and put them in
appids_to_log
- Go here and comment or uncomment the functions to write the logs to a local text file or to Google Sheets
- Run
log_playtime.py
- Results:
- By default, the filenames of the local logs are formatted like
[appID] gameName.txt
, eg.[440] Team Fortress 2.txt
. The contents are comma-seperated values, eg.
"Date", "Time", "Playtime (minutes)" "2016-12-23", "22:16:18.869231", "525"
- Google Sheets output is similar.
- By default, the filenames of the local logs are formatted like