A CLI to analyze and export CS2/CS:GO demos.
Ready-to-use binaries are available on the releases page.
csda -help
Usage of csda:
-demo-path string
Demo file path (mandatory)
-format string
Export format, valid values: [csv,json,csdm] (default "csv")
-minify
Minify JSON file, it has effect only when -format is set to json
-output string
Output folder or file path, must be a folder when exporting to CSV (mandatory)
-positions
Include entities (players, grenades...) positions (default false)
-source string
Force demo's source, valid values: [challengermode,ebot,esea,esl,esportal,faceit,fastcup,5eplay,perfectworld,popflash,valve]
Export a demo into CSV files in the current folder.
csda -demo-path=myDemo.dem -output=.
Export a demo in a specific folder into a minified JSON file including entities positions.
csda -demo-path=/path/to/myDemo.dem -output=/path/to/folder -format=json -positions -minify
This API exposes functions to analyze/export a demo using the Go language.
This function analyzes the demo located at the given path and returns a Match
.
package main
import (
"fmt"
"os"
"github.com/akiver/cs-demo-analyzer/pkg/api"
"github.com/akiver/cs-demo-analyzer/pkg/api/constants"
)
func main() {
match, err := api.AnalyzeDemo("./myDemo.dem", api.AnalyzeDemoOptions{
IncludePositions: true,
Source: constants.DemoSourceValve,
})
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
for _, kill := range match.Kills {
fmt.Printf("(%d): %s killed %s with %s\n", kill.Tick, kill.KillerName, kill.VictimName, kill.WeaponName)
}
}
This function analyzes and exports a demo into the given output path.
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/akiver/cs-demo-analyzer/pkg/api"
"github.com/akiver/cs-demo-analyzer/pkg/api/constants"
)
func main() {
exePath, _ := os.Executable()
outputPath := filepath.Dir(exePath)
err := api.AnalyzeAndExportDemo("./myDemo.dem", outputPath, api.AnalyzeAndExportDemoOptions{
IncludePositions: false,
Source: constants.DemoSourceValve,
Format: constants.ExportFormatJSON,
MinifyJSON: true,
})
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Println("Demo analyzed and exported in " + outputPath)
}
This API exposes the command-line interface.
package main
import (
"os"
"github.com/akiver/cs-demo-analyzer/pkg/cli"
)
func main() {
os.Exit(cli.Run(os.Args[1:]))
}
A Node.js module called @akiver/cs-demo-analyzer
is available on NPM.
It exposes a function that under the hood is a wrapper around the Go CLI.
The module also exports TypeScript types and constants.
import { analyzeDemo, DemoSource, ExportFormat } from '@akiver/cs-demo-analyzer';
async function main() {
await analyzeDemo({
demoPath: './myDemo.dem',
outputFolderPath: '.',
format: ExportFormat.JSON,
source: DemoSource.Valve,
analyzePositions: false,
minify: false,
onStderr: console.error,
onStdout: console.log,
onStart: () => {
console.log('Starting!');
},
onEnd: () => {
console.log('Done!');
},
});
}
main();
make build-windows
make build-darwin
/ make build-darwin-arm64
make build-linux
/ make build-linux-arm64
./download-demos.sh
it will download the demos used for the testsmake test
- Inside the
.vscode
folder, copy/paste the filelaunch.template.json
and name itlaunch.json
- Place a demo in the
debug
folder - Update the
-demo-path
argument to point to the demo you just placed - Adjust the other arguments as you wish
- Start the debugger from VSCode
This project uses the demo parser demoinfocs-golang created by @markus-wa and maintained by him and @akiver.