3 Commits

3 changed files with 111 additions and 72 deletions

View File

@ -1,3 +1,16 @@
# SteamMoneyEstimator # SteamMoneyEstimator
Estimates how much money a piece of software makes on steam using information about its reviews. Estimates how much money a piece of software makes on steam using information about its reviews.
## Usage
`SteamMoneyEstimator {FORMAT} [URLS]`
This will save a file locally
`SteamMoneyEstimator plain "https://store.steampowered.com/app/1895350/I_Wani_Hug_that_Gator/"`
This will simply output the results to stdout
`SteamMoneyEstimator stdout "https://store.steampowered.com/app/1895350/I_Wani_Hug_that_Gator/"`
Will output all urls data in a csv format
`SteamMoneyEstimator csv "https://store.steampowered.com/app/1895350/I_Wani_Hug_that_Gator/"`

View File

@ -1,6 +1,6 @@
# Package # Package
version = "1.0.0" version = "1.0.1"
author = "Michael Yick" author = "Michael Yick"
description = "Estimates how much money a piece of software makes on steam using information about its reviews." description = "Estimates how much money a piece of software makes on steam using information about its reviews."
license = "AGPL-3.0-only" license = "AGPL-3.0-only"

View File

@ -4,10 +4,14 @@ import htmlparser
import xmltree import xmltree
import strutils import strutils
import re import re
import typetraits
var client = newHttpClient() var client = newHttpClient()
let steamURL = os.paramStr(1) let save = os.paramStr(1)
if save == "csv":
writeFile("games.csv", "link,price,yearOfRelease,multiplier,reviewCount,estimatedSales,estimatedRevenue\n")
let commandLine = os.commandLineParams()
let steamURLS = commandLine[1..paramCount()-1]
for steamURL in steamURLS:
let response = client.getContent(steamURL) let response = client.getContent(steamURL)
var html = htmlparser.parseHtml(response) var html = htmlparser.parseHtml(response)
@ -68,12 +72,34 @@ if onSale:
if element.attr("class") == "discount_original_price": if element.attr("class") == "discount_original_price":
price = element.innerText.replace("$").parseFloat price = element.innerText.replace("$").parseFloat
break break
echo "Link: " & os.paramStr(1)
let estimatedSales = multiplier*reviewCount
let estimatedRevenue = (toFloat(estimatedSales)*price)*0.70
case save:
of "plain":
for name in html.findall("span"):
if name.attr("itemprop") == "name":
var output = """
Link: $1
Price: $2
Year of Release: $3
Year Multiplier (from VG Insights): $4
Reviews: : $5
Estimated Sales: $6
Estimated revenue (including steam cut): $7""" % [steamURL, $price, yearOfRelease, $multiplier, $reviewCount, $estimatedSales, $estimatedRevenue]
writeFile(name.innerText.replace("/"), output)
of "csv":
let f = open("games.csv", fmAppend)
var output = """$1,$2,$3,$4,$5,$6,$7""" % [steamURL, $price, yearOfRelease, $multiplier, $reviewCount, $estimatedSales, $estimatedRevenue]
f.writeLine(output)
f.close()
of "stdout":
echo "Link: " & steamURL
echo "Price: " & $price echo "Price: " & $price
echo "Year of Release: " & yearOfRelease echo "Year of Release: " & yearOfRelease
echo "Year Multiplier (from VG Insights): " & $multiplier echo "Year Multiplier (from VG Insights): " & $multiplier
echo "Reviews: " & $reviewCount echo "Reviews: " & $reviewCount
let estimatedSales = multiplier*reviewCount
echo "Estimated Sales: " & $estimatedSales echo "Estimated Sales: " & $estimatedSales
let estimatedRevenue = (toFloat(estimatedSales)*price)*0.70
echo "Estimated revenue (including steam cut): " & $estimatedRevenue echo "Estimated revenue (including steam cut): " & $estimatedRevenue