Sha256: d860e8139d895afb9c5739542b8b9f6131604fc1964d3bc66bbb8c573dbd17c6
Contents?: true
Size: 960 Bytes
Versions: 3
Compression:
Stored size: 960 Bytes
Contents
require 'rspotify' require 'spotify_to_mp3/spotify/track' require 'spotify_to_mp3/spotify/album' module SpotifyToMp3 class Spotify def get_track(uri) track_id = parse_id(uri) track = RSpotify::Track.find(track_id) Track.new(track.artists.first.name, track.name) end def get_album(uri) album_id = parse_id(uri) album = RSpotify::Album.find(album_id) tracks = [] album.tracks.each do |track| tracks << Track.new(album.artists.first.name, track.name) end Album.new(album.artists.first.name, album.name, tracks) end def track_uri?(uri) uri.start_with?('http://open.spotify.com/track/', 'spotify:track:') end def album_uri?(uri) uri.start_with?('http://open.spotify.com/album/', 'spotify:album:') end private def parse_id(uri) id = uri.sub(/.*:/, '') id = id.sub(/.*\//, '') if uri.start_with?('http') id end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
spotify-to-mp3-0.7.2 | lib/spotify_to_mp3/spotify.rb |
spotify-to-mp3-0.7.1 | lib/spotify_to_mp3/spotify.rb |
spotify-to-mp3-0.7.0 | lib/spotify_to_mp3/spotify.rb |