forked from Cavemanon/SteamMoneyEstimator
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
19d0455ca8 | |||
be18bae3c5 | |||
9bf9f0d2e8 |
13
README.md
13
README.md
@ -4,8 +4,13 @@ Estimates how much money a piece of software makes on steam using information ab
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
This will save a file locally along with printing the results:
|
`SteamMoneyEstimator {FORMAT} [URLS]`
|
||||||
`SteamMoneyEstimator true "https://store.steampowered.com/app/1895350/I_Wani_Hug_that_Gator/"`
|
|
||||||
|
|
||||||
This will simply output the results without saving a file locally
|
This will save a file locally
|
||||||
`SteamMoneyEstimator true "https://store.steampowered.com/app/1895350/I_Wani_Hug_that_Gator/"`
|
`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/"`
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "1.0.1"
|
version = "1.0.6"
|
||||||
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"
|
||||||
|
@ -6,88 +6,100 @@ import strutils
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
var client = newHttpClient()
|
var client = newHttpClient()
|
||||||
let save = parseBool(os.paramStr(1))
|
let save = os.paramStr(1)
|
||||||
let steamURL = os.paramStr(2)
|
if save == "csv":
|
||||||
let response = client.getContent(steamURL)
|
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)
|
||||||
|
|
||||||
|
var html = htmlparser.parseHtml(response)
|
||||||
|
|
||||||
|
var reviewCount: int
|
||||||
|
var price: float
|
||||||
|
var onSale: bool
|
||||||
|
var yearOfRelease: string
|
||||||
|
var multiplier: int
|
||||||
|
|
||||||
|
for meta in html.findall("meta"):
|
||||||
|
case meta.attr("itemprop"):
|
||||||
|
of "reviewCount":
|
||||||
|
reviewCount = parseInt(meta.attr("content"))
|
||||||
|
of "price":
|
||||||
|
price = parseFloat(meta.attr("content"))
|
||||||
|
case meta.attr("property"):
|
||||||
|
of "og:title":
|
||||||
|
if re.find(meta.attr("content"), re"Save .[0-100]% on.*") == -1:
|
||||||
|
onSale = false
|
||||||
|
else:
|
||||||
|
onSale = true
|
||||||
|
|
||||||
|
for date in html.findall("div"):
|
||||||
|
if date.attr("class") == "date":
|
||||||
|
yearOfRelease = date.innerText.split(" ")[2]
|
||||||
|
|
||||||
|
## https://vginsights.com/insights/article/how-to-estimate-steam-video-game-sales
|
||||||
|
case yearOfRelease:
|
||||||
|
of "2013":
|
||||||
|
multiplier = 79
|
||||||
|
of "2014":
|
||||||
|
multiplier = 72
|
||||||
|
of "2015":
|
||||||
|
multiplier = 62
|
||||||
|
of "2016":
|
||||||
|
multiplier = 52
|
||||||
|
of "2017":
|
||||||
|
multiplier = 43
|
||||||
|
of "2018":
|
||||||
|
multiplier = 38
|
||||||
|
of "2019":
|
||||||
|
multiplier = 36
|
||||||
|
of "2020":
|
||||||
|
multiplier = 31
|
||||||
|
of "2021":
|
||||||
|
multiplier = 31
|
||||||
|
of "2022": ## From here onward, multiplier are made up based off instinct alone
|
||||||
|
multiplier = 31
|
||||||
|
of "2023":
|
||||||
|
multiplier = 31
|
||||||
|
|
||||||
|
if onSale:
|
||||||
|
let steamID = steamURL.split("/")[4]
|
||||||
|
let response = client.getContent("https://store.steampowered.com/widget/" & steamID)
|
||||||
|
let widget = htmlparser.parseHTML(response)
|
||||||
|
for element in widget.findall("div"):
|
||||||
|
if element.attr("class") == "discount_original_price":
|
||||||
|
price = element.innerText.replace("$").parseFloat
|
||||||
|
break
|
||||||
|
|
||||||
|
let estimatedSales = multiplier*reviewCount
|
||||||
|
let estimatedRevenue = (toFloat(estimatedSales)*price)*0.70
|
||||||
|
|
||||||
var html = htmlparser.parseHtml(response)
|
case save:
|
||||||
|
of "plain":
|
||||||
var reviewCount: int
|
for name in html.findall("span"):
|
||||||
var price: float
|
if name.attr("itemprop") == "name":
|
||||||
var onSale: bool
|
var output = """
|
||||||
var yearOfRelease: string
|
Link: $1
|
||||||
var multiplier: int
|
Price: $2
|
||||||
|
Year of Release: $3
|
||||||
for meta in html.findall("meta"):
|
Year Multiplier (from VG Insights): $4
|
||||||
case meta.attr("itemprop"):
|
Reviews: : $5
|
||||||
of "reviewCount":
|
Estimated Sales: $6
|
||||||
reviewCount = parseInt(meta.attr("content"))
|
Estimated revenue (including steam cut): $7""" % [steamURL, $price, yearOfRelease, $multiplier, $reviewCount, $estimatedSales, $estimatedRevenue]
|
||||||
of "price":
|
|
||||||
price = parseFloat(meta.attr("content"))
|
writeFile(name.innerText.replace("/"), output)
|
||||||
case meta.attr("property"):
|
of "csv":
|
||||||
of "og:title":
|
let f = open("games.csv", fmAppend)
|
||||||
if re.find(meta.attr("content"), re"Save .[0-100]% on.*") == -1:
|
var output = """$1,$2,$3,$4,$5,$6,$7""" % [steamURL, $price, yearOfRelease, $multiplier, $reviewCount, $estimatedSales, $estimatedRevenue]
|
||||||
onSale = false
|
f.writeLine(output)
|
||||||
else:
|
f.close()
|
||||||
onSale = true
|
of "stdout":
|
||||||
|
echo "Link: " & steamURL
|
||||||
for date in html.findall("div"):
|
echo "Price: $" & ((price.formatFloat(ffDecimal, 2)).insertSep(',')).replace(",.", ".") & " (USD)"
|
||||||
if date.attr("class") == "date":
|
echo "Year of Release: " & yearOfRelease
|
||||||
yearOfRelease = date.innerText.split(" ")[2]
|
echo "Year Multiplier (from VG Insights): " & $multiplier
|
||||||
|
echo "Reviews: " & $reviewCount
|
||||||
## https://vginsights.com/insights/article/how-to-estimate-steam-video-game-sales
|
echo "Estimated Sales: " & $estimatedSales
|
||||||
case yearOfRelease:
|
echo "Estimated revenue (including steam cut): " & $estimatedRevenue
|
||||||
of "2013":
|
|
||||||
multiplier = 79
|
|
||||||
of "2014":
|
|
||||||
multiplier = 72
|
|
||||||
of "2015":
|
|
||||||
multiplier = 62
|
|
||||||
of "2016":
|
|
||||||
multiplier = 52
|
|
||||||
of "2017":
|
|
||||||
multiplier = 43
|
|
||||||
of "2018":
|
|
||||||
multiplier = 38
|
|
||||||
of "2019":
|
|
||||||
multiplier = 36
|
|
||||||
of "2020":
|
|
||||||
multiplier = 31
|
|
||||||
of "2021":
|
|
||||||
multiplier = 31
|
|
||||||
of "2022": ## From here onward, multiplier are made up based off instinct alone
|
|
||||||
multiplier = 31
|
|
||||||
of "2023":
|
|
||||||
multiplier = 31
|
|
||||||
|
|
||||||
if onSale:
|
|
||||||
let steamID = steamURL.split("/")[4]
|
|
||||||
let response = client.getContent("https://store.steampowered.com/widget/" & steamID)
|
|
||||||
let widget = htmlparser.parseHTML(response)
|
|
||||||
for element in widget.findall("div"):
|
|
||||||
if element.attr("class") == "discount_original_price":
|
|
||||||
price = element.innerText.replace("$").parseFloat
|
|
||||||
break
|
|
||||||
echo "Link: " & os.paramStr(2)
|
|
||||||
echo "Price: " & $price
|
|
||||||
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
|
|
||||||
echo "Estimated revenue (including steam cut): " & $estimatedRevenue
|
|
||||||
|
|
||||||
if save:
|
|
||||||
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""" % [os.paramStr(2), $price, yearOfRelease, $multiplier, $reviewCount, $estimatedSales, $estimatedRevenue]
|
|
||||||
|
|
||||||
writeFile(name.innerText.replace("/"), output)
|
|
||||||
|
Reference in New Issue
Block a user