class Song

Defined in:

glue/song.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(song_name : String, artist_name : String) #

[View source]

Instance Method Detail

def filename : String #

[View source]
def grab_it(url : String | Nil = nil, flags = {} of String => String) #

Find, downloads, and tags the mp3 song that this class represents. Optionally takes a youtube URL to download from

Song.new("Bohemian Rhapsody", "Queen").grab_it

[View source]
def organize_it #

Will organize the song into the user's provided music directory in the user's provided structure Must be called AFTER the song has been downloaded.

s = Song.new("Bohemian Rhapsody", "Queen").grab_it
s.organize_it()
# With
# directory_pattern = "{artist}/{album}"
# filename_pattern = "{track_number} - {title}"
# Mp3 will be moved to
# /home/cooper/Music/Queen/A Night At The Opera/1 - Bohemian Rhapsody.mp3

[View source]
def provide_client_keys(client_id : String, client_secret : String) : self #

Provide spotify client keys. Must be called if provide_metadata and provide_spotify are not called.

Song.new(...).provide_client_keys("XXXXXXXXXX", "XXXXXXXXX").grab_it

[View source]
def provide_metadata(metadata : JSON::Any) : self #

Provide metadata so that it doesn't have to find it. Useful for overwriting metadata. Must be called if provide_client_keys and provide_spotify are not called.

Song.new(...).provide_metadata(...).grab_it

[View source]
def provide_spotify(spotify : SpotifySearcher) : self #

Provide an already authenticated SpotifySearcher class. Useful to avoid authenticating over and over again. Must be called if provide_metadata and provide_client_keys are not called.

Song.new(...).provide_spotify(SpotifySearcher.new
  .authenticate("XXXXXXXXXX", "XXXXXXXXXXX")).grab_it

[View source]