class SpotifySearcher

Defined in:

search/spotify.cr

Instance Method Summary

Instance Method Detail

def authorize(client_id : String, client_secret : String) : self #

Saves an access token for future program use with spotify using client IDs. Specs defined on spotify's developer api: https://developer.spotify.com/documentation/general/guides/authorization-guide/#client-credentials-flow

SpotifySearcher.new.authorize("XXXXXXXXXX", "XXXXXXXXXX")

[View source]
def authorized? : Bool #

Check if the class is authorized or not


[View source]
def find_genre(id : String) : String | Nil #

Find the genre of an artist based off of their id

SpotifySearcher.new.authorize(...).find_genre("1dfeR4HaWDbWqFHLkxsg1d")

[View source]
def find_item(item_type : String, item_parameters : Hash, offset = 0, limit = 20) : JSON::Any | Nil #

Searches spotify with the specified parameters for the specified items

spotify_searcher.find_item("track", {
  "artist" => "Queen",
  "track" => "Bohemian Rhapsody"
})
=> {track metadata}

[View source]
def find_user_playlist(username : String, name : String, offset = 0, limit = 20) : JSON::Any | Nil #

Grabs a users playlists and searches through it for the specified playlist

spotify_searcher.find_user_playlist("prakkillian", "the little man")
=> {playlist metadata}

[View source]
def get_item(item_type : String, id : String, offset = 0, limit = 100) : JSON::Any #

Get the complete metadata of an item based off of its id

SpotifySearcher.new.authorize(...).get_item("artist", "1dfeR4HaWDbWqFHLkxsg1d")

[View source]
def get_playlist(id, offset = 0, limit = 100) : JSON::Any #

The only way this method differs from #get_item is that it makes sure to insert ALL tracks from the playlist into the JSON::Any

SpotifySearcher.new.authorize(...).get_playlist("122Fc9gVuSZoksEjKEx7L0")

[View source]