Steamleft

Somebody sent me to this tool.

If your Steam Profile is public, it will show you how long you’d need to play for to “complete” all games in your steam library.

My own entry is here.

It relies on average game length statistics from www.howlongtobeat.com , which will obviously be a bit hit and miss with games like Kerbal Space Program. For open ended sandbox games, like KSP, what counts as beating it?

Actually, I’ll go and look it up:

howlongtobeatKSP

 

Well.

I suppose KSP does have a Career mode these days, and maybe that’s what’s been submitted for the Main Story stat? Even so, I could play this game for literally the rest of my life and I’d still probably find stuff to do.

So SteamLeft won’t be perfect, by a long shot. I’ve got whole sections of my library dedicated to multiplayer games that I’ll never “beat”, and I’ve got a load of duplicate games as well, for when things have a separate beta branch entry in my games list.

However, I wrote myself a little script to scrape my steamleft entry daily, and log the results to a file.

The script is here:

#!/bin/sh
 wget -O - http://steamleft.com/span/76561197973314452 | echo $(date +"%d-%m-%Y") $(xmllint --html --xpath "/html/body/main/div/div/section[1]/div[4]/text()" - 2>/dev/null) >> /home/anorak/steamleft/bob

I’ll break down what it’s doing:

wget -O - http://steamleft.com/span/76561197973314452

Wget grabs whatever content exists at the URL you give it. In this case, the URL is the steamleft page for my steam account. This information is looked up in realtime when you visit the page (presumably).

The “-O -” argument redirect the downloaded contents to standard in, rather than writing the results to disk. This is useful because we don’t need to then look up the contents of disk afterwards, and the next part of the command can read directly from standard input.

| echo $(date +"%d-%m-%Y") $(xmllint --html --xpath "/html/body/main/div/div/section[1]/div[4]/text()" - 2>/dev/null) >> /home/anorak/steamleft/bob

The “|” character is a pipe, and it’s used for directing the output of the command before it to the input of the command after it.

echo $(date +”%d-%m-%Y”)

This outputs the date in the format “dd-mm-yyyy”.

xmllint --html --xpath "/html/body/main/div/div/section[1]/div[4]/text()

xmllint I had to install myself, it wasn’t part of my standard ubuntu install. It’s a program for parsing XML. The “–html” option allows parsing of HTML (HTML is often not XML compliant).

The “–xpath” option  lets me grab the actual element I want from the page.  I found the xpath by looking through the steamleft page in Google Chrome:

steamleftxpath

$(xmllint --html --xpath "/html/body/main/div/div/section[1]/div[4]/text()" - 2>/dev/null) >> /home/anorak/steamleft/bob

The “-” reads the input from standard in.

the “2>/dev/null” redircects all errors to /dev/null. And there WILL be errors, because it’s HTML. And XML parsers do not like HTML very much.

>> /home/anorak/steamleft/bob

This adds the result to the end of the output file.

The output file looks like this:

30-03-2015 1768 continuous hours
31-03-2015 1768 continuous hours

Thrilling.
This script is set to execute once per day. I’ll leave it running for a few months, and see how I’m doing at beating my library. I’ll hook it up to GNUplot at some point too, for shits and giggles.

I’ve been fairly good at not buying new games, with the intention of beating my  back-catalog. This should give me an indication of how I’m doing. And it gave me an interesting little exercise. In fact it took me longer to write up how I did it than it took to actually do it.

 

Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *