Sha256: f32f954d62dc14a5bd24b48aef8758684b30b43191b25f352c96867ff9bc7958
Contents?: true
Size: 985 Bytes
Versions: 2
Compression:
Stored size: 985 Bytes
Contents
#!/usr/bin/env jruby $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib')) require 'rubygems' gem 'spotify-api' require 'clients/lastfm' require 'clients/spotify' # a demo app which grabs tracks from last.fm and creates a spotify # playlist based on friends loved tracks if __FILE__ == $0 username = ARGV.shift or raise "#{$0} <username>" puts "fetching last.fm tracks (friends/recently_loved)" limit = 10 # 10 tracks per friend tracks = LastFM.friends_loved_tracks(username, limit).values.flatten puts "resolving spotify ids" spotify_tracks = begin Spotify.resolve(tracks.map {|t| [t["title"], t["artist"]] }) rescue Errno::ECONNREFUSED fail "Could not connect to spotify-api server. Make sure it it running." end if spotify_tracks.size > 0 puts "creating playlist with #{spotify_tracks.size} tracks" puts Spotify.create_playlist("loved by friends of #{username}", spotify_tracks.map { |t| t['id'] }) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spotify-api-0.0.7 | examples/lastfm2spotify_loved_tracks |
spotify-api-0.0.6 | examples/lastfm2spotify_loved_tracks |