Adding entire album to a playlist

1 view
Skip to first unread message

Christoffer Nicklasson

unread,
Apr 19, 2013, 5:35:43 AM4/19/13
to ruby-...@googlegroups.com
The code i modified looks like this
    def call(env)
      rp = env["PATH_INFO"]
      puts env["HTTP_USER_AGENT"]
      puts "Addsong"
      puts "rp: #{rp}"
      user, uri = rp.match(/^\/(\w*)\/(.*)/)[1..2]

      puts "User: " + user
      if uri.include?(':album')
        track_names = []
        puts "Album: " + uri
        album = Hallon::Album.new(uri)
        puts "Album: " + album
        album.browse.tracks.each do |track|
        binding.pry
         # @sp.add_to_playlist ({:track => track.load, :user => user})
         #  @sp.add_to_playlist ({:track => track, :user => user})
          track_names << track.name
        end
        puts track_names.to_json
        xml = {:command=>"add", :tracks=>track_names, :artist=>album.artist.name,
         :album=>album.name, :user=>user}.to_xml
      elsif uri.include?(':track')
        puts "Track: " + uri

        track = Hallon::Track.new(uri).load
        @sp.add_to_playlist ({:track => track, :user => user})

        xml = {:command=>"add", :track=>track.name, :artist=>track.artist.name,
         :album=>track.album.name, :user=>user}.to_xml
      else # Bad request
        return [500, {'Content-Type'=>'text/xml'}, {:error => "Unknown resource for uri '#{uri} - only tracks or albums supported"}]
      end

      [200, {'Content-Type'=>'text/xml'}, [xml]]
    end
  end


But it seems i missed something as it seems tracks is empty.
I have no Ruby skills.
So be gentle


Regards
Coffe

Kim Burgestrand

unread,
Apr 19, 2013, 5:42:54 AM4/19/13
to Hallon on behalf of Christoffer Nicklasson
Hi Coffe!

On Friday, 19 April 2013 at 11:35, Christoffer Nicklasson via Hallon wrote:

The code i modified looks like this
    def call(env)
      rp = env["PATH_INFO"]
      puts env["HTTP_USER_AGENT"]
      puts "Addsong"
      puts "rp: #{rp}"
      user, uri = rp.match(/^\/(\w*)\/(.*)/)[1..2]

      puts "User: " + user
      if uri.include?(':album')
        track_names = []
        puts "Album: " + uri
        album = Hallon::Album.new(uri)
        puts "Album: " + album
        album.browse.tracks.each do |track|
Yes, album.browse.tracks will be empty, because the album.browse object
needs to be loaded for it to have any content. You’ll need to call .load here
as well.

I have no Ruby skills.
I am sorry. Hallon is a difficult library to use. :) 

— Kim Burgestrand

Christoffer Nicklasson

unread,
Apr 19, 2013, 6:37:10 AM4/19/13
to ruby-...@googlegroups.com
changed to
...

        album = Hallon::Album.new(uri)
        puts "Album: " + album
        album.browse.load
        binding.pry
...

Now my log only shows this and then nothing more
[LOG] 10:35:35.649 I [offline-mgr:2084] Storage has been cleaned

Kim Burgestrand

unread,
Apr 19, 2013, 7:06:54 AM4/19/13
to Hallon on behalf of Christoffer Nicklasson
On Friday, 19 April 2013 at 12:37, Christoffer Nicklasson via Hallon wrote:
changed to
...
        album = Hallon::Album.new(uri)
        puts "Album: " + album
        album.browse.load
        binding.pry
...

Now my log only shows this and then nothing more
[LOG] 10:35:35.649 I [offline-mgr:2084] Storage has been cleaned
Yes. You are now no longer iterating through the tracks.

— Kim Burgestrand

Christoffer Nicklasson

unread,
Apr 19, 2013, 8:29:27 AM4/19/13
to ruby-...@googlegroups.com
Hi,

it should give me the pry console. but it seems its stops responding after  .load
or i am i using .load in the wrong way ?

...

        album = Hallon::Album.new(uri)
        puts "Album: " + album
        album.browse.load
        binding.pry
...


Regards
Christoffer.

Kim Burgestrand

unread,
Apr 19, 2013, 10:52:04 AM4/19/13
to Hallon on behalf of Christoffer Nicklasson
On Friday, 19 April 2013 at 14:29, Christoffer Nicklasson via Hallon wrote:
Hi,

it should give me the pry console. but it seems its stops responding after  .load
or i am i using .load in the wrong way ?
There are two possible causes for this:

1. Hallon deadlocks. You won’t be able to exit the script with ^C. If this is the case, try to downgrade to FFI 1.3.
2. Album browser object never loads. Hallon can’t do anything about this, and Hallon should raise an error after some time. Sometimes objects simply won’t load in libspotify.

— Kim Burgestrand

Sebastian Thörn

unread,
Apr 19, 2013, 11:08:30 AM4/19/13
to ruby-...@googlegroups.com
Hi Kim,

[1] pry(main)> album = Hallon::Album.new("spotify:album:1UsmQ3bpJTyK6ygoOOjG1r").load
=> #<Hallon::Album:0x000000034f1a70 @pointer=#<Spotify::Album address=0x3b4f680>>
[2] pry(main)> album.browse.tracks {|track| puts track}
=> #<Hallon::AlbumBrowse::Tracks:0x00000003565b28
 @pointer=#<Spotify::AlbumBrowse address=0x3e6bad0>>
[3] pry(main)> album.browse.load.tracks {|track| puts track}
[LOG] 15:06:41.152 I [offline-mgr:2032] 0 files are locked. 0 images are locked
[LOG] 15:06:41.152 I [offline-mgr:2058] 0 files unlocked. 0 images unlocked
<--! been like this for 10 minutes now, gotta do C-z and kill the pid -->

what is the differences between ffi 1.6.0 (the one im using) and 1.3?

Br
Sebastian

Kim Burgestrand

unread,
Apr 19, 2013, 11:13:11 AM4/19/13
to Hallon on behalf of Sebastian Thörn
Something happened somewhere after 1.3 that will make Hallon deadlock fairly frequently.
I have not yet investigated exactly what it would be, or exactly which version of FFI that
is causing the issue.

— Kim Burgestrand

Sebastian Thörn

unread,
Apr 19, 2013, 11:13:30 AM4/19/13
to ruby-...@googlegroups.com
just tried with ffi version 1.3 and it seems like it works :)

Sebastian Thörn

unread,
Apr 19, 2013, 11:21:05 AM4/19/13
to ruby-...@googlegroups.com


On Friday, April 19, 2013 5:13:11 PM UTC+2, Kim Burgestrand wrote:
Something happened somewhere after 1.3 that will make Hallon deadlock fairly frequently.
I have not yet investigated exactly what it would be, or exactly which version of FFI that
is causing the issue.

— Kim Burgestrand

ok, i see.

would it be possible to get a specific ffi-version requirement into hallon? 

Kim Burgestrand

unread,
Apr 19, 2013, 11:25:05 AM4/19/13
to Hallon on behalf of Sebastian Thörn
Yes, and no. FFI follows a sane version scheme, so Hallon *should* work on later
versions of FFI. Why it doesn’t is still a mystery, and I have a nice log of commits

I have a task for myself for locking down the dependency of FFI for Hallon that I
created this week: https://github.com/Burgestrand/Hallon/issues/143 — the reason
it haven’t been done is that I haven’t really coded anything since then. :)

I’d like to get that out as a minor release, and after that figure out why newer versions
of FFI won’t work with Hallon, as that possibly impacts more than just Hallon. After
that I’d like to get Hallon working with the very latest version of the spotify gem, as well
as use the plaything API instead of hallon-openal for playback.

— Kim Burgestrand

Sebastian Thörn

unread,
Apr 19, 2013, 11:28:35 AM4/19/13
to Hallon on behalf of Kim Burgestrand
i understand :)

well, if you get any time to do it, check out spotiserv: https://github.com/SebastianThorn/Spotiserv
have a nice weekend Kim!


--
You received this message because you are subscribed to the Hallon ruby gem mailing list.

- To view this group online, visit https://groups.google.com/d/forum/ruby-hallon
- To post to this group, send email to ruby-...@googlegroups.com
- To unsubscribe from this group, send email to ruby-hallon...@googlegroups.com
---
You received this message because you are subscribed to a topic in the Google Groups "Hallon" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ruby-hallon/uxq7CST-Gks/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to ruby-hallon...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Kim Burgestrand

unread,
Apr 25, 2013, 12:08:44 AM4/25/13
to Hallon on behalf of Sebastian Thörn
On Friday, 19 April 2013 at 17:28, Hallon on behalf of Sebastian Thörn wrote:
i understand :)

well, if you get any time to do it, check out spotiserv: https://github.com/SebastianThorn/Spotiserv
have a nice weekend Kim!
Cool. I’ve been meaning to write something similar for a while now, but I never
got to it. Awesome! :)

On another note, the problem with FFI >= 1.3 was because of a change in FFI. Wayne
was extremely quick to answer and fix it in an elegant way as always. FFI >= 1.8 work
fine with Hallon.

I’ve released a new version of Hallon that depends on the latest FFI. :)

— Kim Burgestrand

Reply all
Reply to author
Forward
0 new messages