Skip to content

Instantly share code, notes, and snippets.

@7rebux
Created October 10, 2023 21:17
Show Gist options
  • Save 7rebux/67fb804b3cf9db2a86349186ea64d118 to your computer and use it in GitHub Desktop.
Save 7rebux/67fb804b3cf9db2a86349186ea64d118 to your computer and use it in GitHub Desktop.
Ubisoft Playtime Calculator
import fs from 'fs';
const content = fs.readFileSync("./uplay_traffic_data.csv").toString();
const lines = content.split("\n").slice(1);
const playTimes = {}
for (const line of lines) {
const [
_accountId,
game,
_platform,
_packageDesc,
_purposeDesc,
_contentDesc,
_actionDesc,
_actionDate,
_countryDesc,
sessionTime
] = line.split(",");
const secondsRegex = /(\d+)sec/.exec(sessionTime)
// Skip "Session launched" entries
if (secondsRegex === null) continue
playTimes[game] = (playTimes[game] ?? 0) + parseInt(secondsRegex[1])
}
console.log(playTimes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment