RubyGem 'steam-condenser' - .fetch method only time and fetch_games undefined method `[]'

65 views Asked by At

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!

2

There are 2 answers

2
Jad On

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.

0
Koraktor On

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