Class: LastFM::Api::Artist

Inherits:
Object
  • Object
show all
Defined in:
lib/lastfm/api/artist.rb

Class Method Summary collapse

Class Method Details

.add_tags(params) ⇒ Object

Tag an artist with one or more user supplied tags.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required)

    the artist name

  • :tags (Array, required)

    up to 10 tags to apply to this artist

See Also:



11
12
13
14
# File 'lib/lastfm/api/artist.rb', line 11

def add_tags( params )
  LastFM.requires_authentication
  LastFM.post( "artist.addTags", params )
end

.get_correction(params) ⇒ Array<LastFM::Artist>

Check whether the supplied artist has a correction to a canonical artist.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required)

    the artist name

Returns:

  • (Array<LastFM::Artist>)

    list of suggestion corrections, in order of similarity

See Also:



21
22
23
24
25
26
# File 'lib/lastfm/api/artist.rb', line 21

def get_correction( params )
  xml = LastFM.get( "artist.getCorrection", params )
  xml.find('corrections/correction/artist').map do |correction|
    LastFM::Artist.from_xml( correction )
  end
end

.get_events(params) ⇒ Object

Get a list of upcoming events for this artist.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :mbid (String, optional)

    the musicbrainz id for the artist

  • :festivalsonly (Boolean, optional)

    whether only festivals should be returned, or all events

  • :autocorrect (Boolean, optional)

    transform misspelled artist names into correct artist names to be returned in the response

  • :page (Fixnum, optional)

    the page number to fetch. defaults to first page

  • :limit (Fixnum, optional)

    the number of results to fetch per page. defaults to 50

See Also:



37
38
39
40
41
42
# File 'lib/lastfm/api/artist.rb', line 37

def get_events( params )
  xml = LastFM.get( "artist.getEvents", params )
  xml.find('events/event').map do |event|
    LastFM::Event.from_xml( event )
  end
end

.get_images(params) ⇒ Object

Get images for this artist in a variety of sizes.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :mbid (String, optional)

    the musicbrainz id for the artist

  • :order (Symbol, optional)

    sort ordering can be either :popularity (default) or :dateadded

  • :autocorrect (Boolean, optional)

    transform misspelled artist names into correct artist names to be returned in the response

  • :page (Fixnum, optional)

    the page number to fetch. defaults to first page

  • :limit (Fixnum, optional)

    the number of results to fetch per page. defaults to 50

See Also:



53
54
55
# File 'lib/lastfm/api/artist.rb', line 53

def get_images( params )
  LastFM.get( "artist.getImages", params )
end

.get_info(params) ⇒ LastFM::Artist

Get the metadata for an artist. Includes biography.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :mbid (String, optional)

    the musicbrainz id for the artist

  • :lang (String, optional)

    the language to return the biography in, expressed as an ISO 639 alpha-2 code

  • :autocorrect (Boolean, optional)

    transform misspelled artist names into correct artist names to be returned in the response

  • :username (String, optional)

    username whose playcount for this artist is to be returned in the reponse

Returns:

  • (LastFM::Artist)

    artist constructed from the metadata contained in the response

See Also:



66
67
68
69
# File 'lib/lastfm/api/artist.rb', line 66

def get_info( params )
  xml = LastFM.get( "artist.getInfo", params )
  LastFM::Artist.from_xml( xml )
end

.get_past_events(params) ⇒ Object

Get a paginated list of all the events this artist has played at in the past.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :mbid (String, optional)

    the musicbrainz id for the artist

  • :autocorrect (Boolean, optional)

    transform misspelled artist names into correct artist names to be returned in the response

  • :page (Fixnum, optional)

    the page number to fetch. defaults to first page

  • :limit (Fixnum, optional)

    the number of results to fetch per page. defaults to 50

See Also:



79
80
81
# File 'lib/lastfm/api/artist.rb', line 79

def get_past_events( params )
  LastFM.get( "artist.getPastEvents", params )
end

.get_podcast(params) ⇒ Object

Get a podcast of free mp3s based on an artist.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :mbid (String, optional)

    the musicbrainz id for the artist

  • :autocorrect (Boolean, optional)

    transform misspelled artist names into correct artist names to be returned in the response

See Also:



89
90
91
# File 'lib/lastfm/api/artist.rb', line 89

def get_podcast( params )
  LastFM.get( "artist.getPodcast", params )
end

.get_shouts(params) ⇒ Array<LastFM::Shout>

Get shouts for this artist.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :mbid (String, optional)

    the musicbrainz id for the artist

  • :autocorrect (Boolean, optional)

    transform misspelled artist names into correct artist names to be returned in the response

  • :page (Fixnum, optional)

    the page number to fetch. defaults to first page

  • :limit (Fixnum, optional)

    the number of results to fetch per page. defaults to 50

Returns:

See Also:



102
103
104
105
106
107
# File 'lib/lastfm/api/artist.rb', line 102

def get_shouts( params )
  xml = LastFM.get( "artist.getShouts", params )
  xml.find('shouts/shout').map do |shout|
    LastFM::Shout.from_xml( shout )
  end
end

.get_similar(params) ⇒ Array<LastFM::Artist>

Get all the artists similar to this artist.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :mbid (String, optional)

    the musicbrainz id for the artist

  • :autocorrect (Boolean, optional)

    transform misspelled artist names into correct artist names to be returned in the response

  • :limit (Fixnum, optional)

    limit the number of results to fetch

Returns:

See Also:



117
118
119
120
121
122
# File 'lib/lastfm/api/artist.rb', line 117

def get_similar( params )
  xml = LastFM.get( "artist.getSimilar", params )
  xml.find('similarartists/artist').map do |artist|
    LastFM::Artist.from_xml( artist )
  end
end

.get_tags(params) ⇒ Object

Get the tags applied by an individual user to an artist on Last.fm. If accessed as an authenticated service and you don’t supply a user parameter then this service will return tags for the authenticated user.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :mbid (String, optional)

    the musicbrainz id for the artist

  • :autocorrect (Boolean, optional)

    transform misspelled artist names into correct artist names to be returned in the response

  • :user (String, optional)

    if called in non-authenticated mode you must specify the user to look up

See Also:



132
133
134
135
136
# File 'lib/lastfm/api/artist.rb', line 132

def get_tags( params )
  secure = !params.include?(:user)
  LastFM.requires_authentication if secure
  LastFM.get( "artist.getTags", params, secure )
end

.get_top_albums(params) ⇒ Array<LastFM::Album>

Get the top albums for an artist, ordered by popularity.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :mbid (String, optional)

    the musicbrainz id for the artist

  • :autocorrect (Boolean, optional)

    transform misspelled artist names into correct artist names to be returned in the response

  • :page (Fixnum, optional)

    the page number to fetch. defaults to first page

  • :limit (Fixnum, optional)

    the number of results to fetch per page. defaults to 50

Returns:

See Also:



147
148
149
150
151
152
# File 'lib/lastfm/api/artist.rb', line 147

def get_top_albums( params )
  xml = LastFM.get( "artist.getTopAlbums", params )
  xml.find('topalbums/album').map do |album|
    LastFM::Album.from_xml( album )
  end
end

.get_top_fans(params) ⇒ Object

Get the top fans for an artist on Last.fm, based on listening data.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :mbid (String, optional)

    the musicbrainz id for the artist

  • :autocorrect (Boolean, optional)

    transform misspelled artist names into correct artist names to be returned in the response

See Also:



160
161
162
# File 'lib/lastfm/api/artist.rb', line 160

def get_top_fans( params )
  LastFM.get( "artist.getTopFans", params )
end

.get_top_tags(params) ⇒ Array<LastFM::Tag>

Get the top tags for an artist, ordered by popularity.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :mbid (String, optional)

    the musicbrainz id for the artist

  • :autocorrect (Boolean, optional)

    transform misspelled artist names into correct artist names to be returned in the response

Returns:

  • (Array<LastFM::Tag>)

    list of tags ordered by popularity

See Also:



171
172
173
174
175
176
# File 'lib/lastfm/api/artist.rb', line 171

def get_top_tags( params )
  xml = LastFM.get( "artist.getTopTags", params )
  xml.find('toptags/tag').map do |tag|
    LastFM::Tag.from_xml( tag )
  end
end

.get_top_tracks(params) ⇒ Array<LastFM::Track>

Get the top tracks by an artist, ordered by popularity.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :mbid (String, optional)

    the musicbrainz id for the artist

  • :autocorrect (Boolean, optional)

    transform misspelled artist names into correct artist names to be returned in the response

  • :page (Fixnum, optional)

    the page number to fetch. defaults to first page

  • :limit (Fixnum, optional)

    the number of results to fetch per page. defaults to 50

Returns:

See Also:



187
188
189
190
191
192
# File 'lib/lastfm/api/artist.rb', line 187

def get_top_tracks( params )
  xml = LastFM.get( "artist.getTopTracks", params )
  xml.find('toptracks/track').map do |track|
    LastFM::Track.from_xml( track )
  end
end

.remove_tag(params) ⇒ Object

Remove a user’s tag from an artist.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required)

    the artist name

  • :tag (String, required)

    a single user tag to remove from this artist

See Also:



199
200
201
202
# File 'lib/lastfm/api/artist.rb', line 199

def remove_tag( params )
  LastFM.requires_authentication
  LastFM.post( "artist.removeTag", params )
end

.search(params) ⇒ Array<LastFM::Artist>

Search for an artist by name. Returns artist matches sorted by relevance.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :page (Fixnum, optional)

    the page number to fetch. defaults to first page

  • :limit (Fixnum, optional)

    the number of results to fetch per page. defaults to 50

  • :artist (String, required)

    the artist name

Returns:

See Also:



211
212
213
214
215
216
# File 'lib/lastfm/api/artist.rb', line 211

def search( params )
  xml = LastFM.get( "artist.search", params )
  xml.find('results/artistmatches/artist').map do |artist|
    LastFM::Artist.from_xml( artist )
  end
end

.share(params) ⇒ Object

Share an artist with Last.fm users or other friends.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required)

    the artist name

  • :recipient (Array, required)

    a list of email addresses or Last.fm usernames. maximum is 10

  • :message (String, optional)

    an optional message to send. if not supplied a default message will be used

  • :public (Boolean, optional)

    optionally show in the sharing users activity feed. defaults to false

See Also:



225
226
227
228
# File 'lib/lastfm/api/artist.rb', line 225

def share( params )
  LastFM.requires_authentication
  LastFM.post( "artist.share", params )
end

.shout(params) ⇒ Object

Shout in this artist’s shoutbox.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required)

    name of the artist to shout on

  • :message (String, required)

    message to post to the shoutbox

See Also:



235
236
237
238
# File 'lib/lastfm/api/artist.rb', line 235

def shout( params )
  LastFM.requires_authentication
  LastFM.post( "artist.shout", params )
end