{"id":473,"date":"2015-03-31T12:48:21","date_gmt":"2015-03-31T12:48:21","guid":{"rendered":"http:\/\/blog.daft-ideas.co.uk\/?p=473"},"modified":"2015-03-31T12:55:12","modified_gmt":"2015-03-31T12:55:12","slug":"steamleft","status":"publish","type":"post","link":"https:\/\/blog.daft-ideas.co.uk\/2015\/03\/31\/steamleft\/","title":{"rendered":"Steamleft"},"content":{"rendered":"

Somebody sent me to this\u00a0tool.<\/a><\/p>\n

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.<\/p>\n

My own entry is here<\/a>.<\/p>\n

It relies on average game length statistics from www.howlongtobeat.com<\/a> , 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?<\/p>\n

Actually, I’ll go and look it up:<\/p>\n

\"howlongtobeatKSP\"<\/a><\/p>\n

 <\/p>\n

Well.<\/p>\n

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.<\/p>\n

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.<\/p>\n

However, I wrote myself a little script to scrape my steamleft entry daily, and log the results to a file.<\/p>\n

The script is here:<\/p>\n

#!\/bin\/sh\r\n 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<\/pre>\n

I’ll break down what it’s doing:<\/p>\n

wget -O - http:\/\/steamleft.com\/span\/76561197973314452<\/pre>\n

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).<\/p>\n

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.<\/p>\n

| 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<\/pre>\n

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.<\/p>\n

echo $(date +”%d-%m-%Y”)<\/strong><\/p>\n

This outputs the date in the format “dd-mm-yyyy”.<\/p>\n

xmllint --html --xpath<\/strong> \"\/html\/body\/main\/div\/div\/section[1]\/div[4]\/text()<\/pre>\n

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).<\/p>\n

The “–xpath” option \u00a0lets me grab the actual element I want from the page. \u00a0I found the xpath by looking through the steamleft page in Google Chrome:<\/p>\n

\"steamleftxpath\"<\/a><\/p>\n

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

The “-” reads the input from standard in.<\/p>\n

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.<\/p>\n

>> \/home\/anorak\/steamleft\/bob<\/strong><\/pre>\n

This adds the result to the end of the output file.<\/p>\n

The output file looks like this:<\/p>\n

30-03-2015 1768 continuous hours\r\n31-03-2015 1768 continuous hours\r\n<\/pre>\n

Thrilling.
\nThis 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.<\/p>\n

I’ve been fairly good at not buying new games, with the intention of beating my \u00a0back-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.<\/p>\n

 <\/p>\n","protected":false},"excerpt":{"rendered":"

Somebody sent me to this\u00a0tool. 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… Continue reading → <\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[60,4],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.daft-ideas.co.uk\/wp-json\/wp\/v2\/posts\/473"}],"collection":[{"href":"https:\/\/blog.daft-ideas.co.uk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.daft-ideas.co.uk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.daft-ideas.co.uk\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.daft-ideas.co.uk\/wp-json\/wp\/v2\/comments?post=473"}],"version-history":[{"count":3,"href":"https:\/\/blog.daft-ideas.co.uk\/wp-json\/wp\/v2\/posts\/473\/revisions"}],"predecessor-version":[{"id":481,"href":"https:\/\/blog.daft-ideas.co.uk\/wp-json\/wp\/v2\/posts\/473\/revisions\/481"}],"wp:attachment":[{"href":"https:\/\/blog.daft-ideas.co.uk\/wp-json\/wp\/v2\/media?parent=473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.daft-ideas.co.uk\/wp-json\/wp\/v2\/categories?post=473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.daft-ideas.co.uk\/wp-json\/wp\/v2\/tags?post=473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}