hamin / Spotify-Water-Cooler

Killing Productivity...one beat at a time!
http://blog.harisamin.com
33 stars 1 forks source link

Undefined method 'tracks' #1

Closed agrieser closed 12 years ago

agrieser commented 12 years ago

I receive an error when loading the root page.

Trying to debug this, the HALLON_SESSION.container object responds to "loaded?" with false.

NoMethodError - undefined method `tracks' for nil:NilClass:
    /Users/agrieser//Spotify-Water-Cooler/app.rb:30:in `block in <class:MainApp>'
    /Users/agrieser/.rvm/gems/ruby-1.9.3-p0@spotify/gems/sinatra-1.3.2/lib/sinatra/base.rb:1212:in `call'
    /Users/agrieser/.rvm/gems/ruby-1.9.3-p0@spotify/gems/sinatra-1.3.2/lib/sinatra/base.rb:1212:in `block in compile!'
    /Users/agrieser/.rvm/gems/ruby-1.9.3-p0@spotify/gems/sinatra-1.3.2/lib/sinatra/base.rb:785:in `[]'
    /Users/agrieser/.rvm/gems/ruby-1.9.3-p0@spotify/gems/sinatra-1.3.2/lib/sinatra/base.rb:785:in `block (3 levels) in route!'
    /Users/agrieser/.rvm/gems/ruby-1.9.3-p0@spotify/gems/sinatra-1.3.2/lib/sinatra/base.rb:801:in `route_eval'
    /Users/agrieser/.rvm/gems/ruby-1.9.3-p0@spotify/gems/sinatra-1.3.2/lib/sinatra/base.rb:785:in `block (2 levels) in route!'
    /Users/agrieser/.rvm/gems/ruby-1.9.3-p0@spotify/gems/sinatra-1.3.2/lib/sinatra/base.rb:822:in `block in process_route'
    /Users/agrieser/.rvm/gems/ruby-1.9.3-p0@spotify/gems/sinatra-1.3.2/lib/sinatra/base.rb:820:in `catch'
    /Users/agrieser/.rvm/gems/ruby-1.9.3-p0@spotify/gems/sinatra-1.3.2/lib/sinatra/base.rb:820:in `process_route'
    /Users/agrieser/.rvm/gems/ruby-1.9.3-p0@spotify/gems/sinatra-1.3.2/lib/sinatra/base.rb:784:in `block in route!'

Log messages:

[LOG] 19:39:36.531 I [offline_authorizer.cpp:289] Unable to login offline: no such user
[LOG] 19:39:36.541 I [ap:1766] Connecting to AP ap.spotify.com:4070
[LOG] 19:39:41.543 E [ap:1704] AP Socket Error: Timeout reached (20000)
[LOG] 19:39:41.543 E [ap:4097] Connection error:  117
[LOG] 19:39:41.543 I [ap:1766] Connecting to AP ap.spotify.com:443
[LOG] 19:39:46.544 E [ap:1704] AP Socket Error: Timeout reached (20000)
[LOG] 19:39:46.544 E [ap:4097] Connection error:  117
[LOG] 19:39:46.545 I [ap:1766] Connecting to AP ap.spotify.com:80
[LOG] 19:39:46.582 I [ap:1224] Connected to AP: 193.182.8.38:80
[LOG] 19:39:46.796 I [user_cache:138] UserCache::initiateGetUsers() will query for 1 users
[LOG] 19:39:46.866 E [offline_authorizer.cpp:51] Unable to save file: offline.bnk
hamin commented 12 years ago

@agrieser not sure why you're getting that error. In the project type in racksh, that will launch an app console with the envrioment properly loaded. Inspect HALLON_SESSION.container.contents . It should yield a Hallon:PlaylistsContrainer::Contents object which basically represents the Spotify user's playlist objects. HALLON_SESSION.container.loaded? also yields true for me. Not sure why your session is not being initialized properly. You can also try the code in the console manually to see what the problem might be:

  HALLON_SESSION = Hallon::Session.initialize IO.read(ENV['HALLON_APPKEY']) do
    on(:log_message) do |message|
      puts "[LOG] #{message}"
    end
  end

  HALLON_SESSION.login!(ENV['HALLON_USERNAME'], ENV['HALLON_PASSWORD'])