Sha256: c69bf2ac30d24f10fb1fd785b89b7c2165e1eee8dc236a0400d343bdd53f779f
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
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 tracks popular in a city # to batch create playlists, use lastfm_metro_playlists.rb if __FILE__ == $0 city = ARGV.shift or raise "#{$0} <city,country>" metro,country = *city.split(',') puts "fetching last.fm tracks for #{metro}, #{country}" unique = true tracks = LastFM.metro_track_chart(metro,country, unique) puts "resolving spotify ids" spotify_tracks = begin Spotify.resolve(tracks.map { |t| [t["name"], t["artist"]["name"]] }) 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("chart for #{metro}, #{country}", 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_metrochart |
spotify-api-0.0.6 | examples/lastfm2spotify_metrochart |