1

I am trying to get some basic information from the Steam Community via the steam-condenser gem and so far the Steam.new seems to work just fine with all the players information. however when I do this (example)

player = SteamId.new("tiger")
stats = player.fetch_games

I get the following error message

Traceback (most recent call last):
        1: from lib/assets/ruby/test.rb:15:in `<main>'
/home/zigs/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/steam-condenser-1.3.11/lib/steam/community/steam_id.rb:326:in `fetch_games': undefined method `[]' for nil:NilClass (NoMethodError)

A lot of the information I need seems to be connected to the fetch_games (for example the method total_playtime(id))

Not sure why this is not working. I am lost. Any help or ideas are highly appreciated! Thank you!

donaldLTB
  • 11
  • 1

2 Answers2

1

Valve has added more privacy options to Steam Community profiles which are not reflected in the old XML APIs.

Apparently, the profile in question (tiger) has it‘s game details set to “Friends Only” or ”Private” as games are also unavailable in the browser.

The code from the released 1.x versions is no longer guaranteed to work when it comes to Steam Community. Valve deprecated the old XML APIs several years ago. Sadly, the modern Web API hasn‘t gotten much attention from Valve‘s side either. So development of Steam Condenser has mostly come to halt, too.

You might have more luck using the code from the master branch of the GitHub repository which uses Web API for most of the Community features.

You will have to register for a Steam Web API key, though: https://steamcommunity.com/dev/apikey

Koraktor
  • 41,357
  • 10
  • 69
  • 99
0

TLDR; it looks like this gem no longer works.

the particular module that you're having trouble with is:

def fetch_games
  games_data = parse "#{base_url}/games?xml=1"
  @games            = {}
  @recent_playtimes = {}
  @total_playtimes  = {}
  games_data['games']['game'].each do |game_data|
    app_id = game_data['appID'].to_i
    @games[app_id] = SteamGame.new app_id, game_data

    recent = game_data['hoursLast2Weeks'].to_f
    total = (game_data['hoursOnRecord'] || '').delete(',').to_f

    @recent_playtimes[app_id] = (recent * 60).to_i
    @total_playtimes[app_id]  = (total * 60).to_i
  end

  true
end

with the particular problem statement being games_data['games']['game'].each

If we were looking to get information for a particular user, it downloads an XML document about the user from a URL looking like:

http://steamcommunity.com/id/demomenz?xml=1

and this file does not seem to contain any games objects in it.

Having looked at the codebase for the steam-condenser gem; it hasn't really been updated in about 6 years. I can only assume that the XML format has been modified since this time and that the gem will no longer work.

Jad
  • 1,257
  • 12
  • 19
  • **Thank you @jad.** Thats too bad. I actually looked into it before too but had no clue if I was even able to see anything (i am still a newbie in coding) and thought i might need a key or so. Is there any other gem currently which I could use for my rails app in order to find out the steam users games? – donaldLTB Apr 29 '21 at 14:15
  • In the XML I downloaded there was a "groups" section, that looked like it might contain game code ... you might be able to cobble something together ... also on their twitter account, or their github messaging system (I can't recall which I saw it on) someone suggested a different project ... I can look again if you need me to, it's just a pain on the work laptop, as everything is locked down! :) – Jad Apr 29 '21 at 16:26