1 Commits

Author SHA1 Message Date
38666d5472 List in $USD 2023-08-11 12:53:21 +10:00
2 changed files with 88 additions and 105 deletions

View File

@ -4,13 +4,8 @@ Estimates how much money a piece of software makes on steam using information ab
## Usage ## Usage
`SteamMoneyEstimator {FORMAT} [URLS]` This will save a file locally along with printing the results:
`SteamMoneyEstimator true "https://store.steampowered.com/app/1895350/I_Wani_Hug_that_Gator/"`
This will save a file locally This will simply output the results without saving a file locally
`SteamMoneyEstimator plain "https://store.steampowered.com/app/1895350/I_Wani_Hug_that_Gator/"` `SteamMoneyEstimator true "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

@ -6,23 +6,19 @@ import strutils
import re import re
var client = newHttpClient() var client = newHttpClient()
let save = os.paramStr(1) let save = parseBool(os.paramStr(1))
if save == "csv": let steamURL = os.paramStr(2)
writeFile("games.csv", "link,price,yearOfRelease,multiplier,reviewCount,estimatedSales,estimatedRevenue\n") let response = client.getContent(steamURL)
let commandLine = os.commandLineParams()
let steamURLS = commandLine[1..paramCount()-1]
for steamURL in steamURLS:
let response = client.getContent(steamURL)
var html = htmlparser.parseHtml(response) var html = htmlparser.parseHtml(response)
var reviewCount: int var reviewCount: int
var price: float var price: float
var onSale: bool var onSale: bool
var yearOfRelease: string var yearOfRelease: string
var multiplier: int var multiplier: int
for meta in html.findall("meta"): for meta in html.findall("meta"):
case meta.attr("itemprop"): case meta.attr("itemprop"):
of "reviewCount": of "reviewCount":
reviewCount = parseInt(meta.attr("content")) reviewCount = parseInt(meta.attr("content"))
@ -35,12 +31,12 @@ for steamURL in steamURLS:
else: else:
onSale = true onSale = true
for date in html.findall("div"): for date in html.findall("div"):
if date.attr("class") == "date": if date.attr("class") == "date":
yearOfRelease = date.innerText.split(" ")[2] yearOfRelease = date.innerText.split(" ")[2]
## https://vginsights.com/insights/article/how-to-estimate-steam-video-game-sales ## https://vginsights.com/insights/article/how-to-estimate-steam-video-game-sales
case yearOfRelease: case yearOfRelease:
of "2013": of "2013":
multiplier = 79 multiplier = 79
of "2014": of "2014":
@ -64,7 +60,7 @@ for steamURL in steamURLS:
of "2023": of "2023":
multiplier = 31 multiplier = 31
if onSale: if onSale:
let steamID = steamURL.split("/")[4] let steamID = steamURL.split("/")[4]
let response = client.getContent("https://store.steampowered.com/widget/" & steamID) let response = client.getContent("https://store.steampowered.com/widget/" & steamID)
let widget = htmlparser.parseHTML(response) let widget = htmlparser.parseHTML(response)
@ -72,34 +68,26 @@ for steamURL in steamURLS:
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(2)
echo "Price: $" & ((price.formatFloat(ffDecimal, 2)).insertSep(',')).replace(",.", ".") & " (USD)"
echo "Year of Release: " & yearOfRelease
echo "Year Multiplier (from VG Insights): " & $multiplier
echo "Reviews: " & $reviewCount
let estimatedSales = multiplier*reviewCount
echo "Estimated Sales: " & $estimatedSales
let estimatedRevenue = "$" & (((toFloat(estimatedSales)*price*0.70).formatFloat(ffDecimal, 2)).insertSep(',')).replace(",.", ".") & " (USD)"
echo "Estimated revenue (including steam cut): " & $estimatedRevenue
let estimatedSales = multiplier*reviewCount if save:
let estimatedRevenue = (toFloat(estimatedSales)*price)*0.70
case save:
of "plain":
for name in html.findall("span"): for name in html.findall("span"):
if name.attr("itemprop") == "name": if name.attr("itemprop") == "name":
var output = """ var output = """
Link: $1 Link: $1
Price: $2 Price: $2
Year of Release: $3 Year of Release: $3
Year Multiplier (from VG Insights): $4 Year Multiplier (from VG Insights): $4
Reviews: : $5 Reviews: : $5
Estimated Sales: $6 Estimated Sales: $6
Estimated revenue (including steam cut): $7""" % [steamURL, $price, yearOfRelease, $multiplier, $reviewCount, $estimatedSales, $estimatedRevenue] Estimated revenue (including steam cut): $7""" % [os.paramStr(2), $price, yearOfRelease, $multiplier, $reviewCount, $estimatedSales, $estimatedRevenue]
writeFile(name.innerText.replace("/"), output) writeFile(name.innerText, 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 "Year of Release: " & yearOfRelease
echo "Year Multiplier (from VG Insights): " & $multiplier
echo "Reviews: " & $reviewCount
echo "Estimated Sales: " & $estimatedSales
echo "Estimated revenue (including steam cut): " & $estimatedRevenue