Create a gist now

Instantly share code, notes, and snippets.

Example usage of the Hallon gem to login to Spotify, search for tracks and play a song
require 'hallon'
require 'hallon/openal'
session = Hallon::Session.initialize IO.read('./spotify_appkey.key')
session.login!('johndoe', 'superpassword')
search = Hallon::Search.new("Daft Punk Get Lucky")
search.load
tracks = search.tracks[0...5].map(&:load)
puts "Top 5 Results"
tracks.each do |track|
puts "#{track.artist.name} - #{track.name}"
end
player = Hallon::Player.new(Hallon::OpenAL)
player.play!(tracks.first)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment