add file saving capabilities

This commit is contained in:
MichaelYick 2023-08-10 01:44:19 -05:00
parent 4814d3a14f
commit 71dc2fc768
3 changed files with 27 additions and 5 deletions

View File

@ -1,3 +1,11 @@
# 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
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 simply output the results without saving a file locally
`SteamMoneyEstimator true "https://store.steampowered.com/app/1895350/I_Wani_Hug_that_Gator/"`

View File

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

View File

@ -4,10 +4,10 @@ import htmlparser
import xmltree
import strutils
import re
import typetraits
var client = newHttpClient()
let steamURL = os.paramStr(1)
let save = parseBool(os.paramStr(1))
let steamURL = os.paramStr(2)
let response = client.getContent(steamURL)
var html = htmlparser.parseHtml(response)
@ -68,7 +68,7 @@ if onSale:
if element.attr("class") == "discount_original_price":
price = element.innerText.replace("$").parseFloat
break
echo "Link: " & os.paramStr(1)
echo "Link: " & os.paramStr(2)
echo "Price: " & $price
echo "Year of Release: " & yearOfRelease
echo "Year Multiplier (from VG Insights): " & $multiplier
@ -77,3 +77,17 @@ 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, output)