Class: LastFM::Artist

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

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Struct

from_xml, inherited, #initialize, package, #to_json

Constructor Details

This class inherits a constructor from LastFM::Struct

Instance Attribute Details

#imagesHash

Returns the current value of images.

Returns:

  • (Hash)

    the current value of images


13
14
15
# File 'lib/lastfm/artist.rb', line 13

def images
  @images
end

#listenersFixnum

Returns the current value of listeners.

Returns:

  • (Fixnum)

    the current value of listeners


13
14
15
# File 'lib/lastfm/artist.rb', line 13

def listeners
  @listeners
end

#matchObject

Returns the value of attribute match

Returns:

  • (Object)

    the current value of match


13
14
15
# File 'lib/lastfm/artist.rb', line 13

def match
  @match
end

#mbidString

Returns the current value of mbid.

Returns:

  • (String)

    the current value of mbid


13
14
15
# File 'lib/lastfm/artist.rb', line 13

def mbid
  @mbid
end

#nameString

Returns the current value of name.

Returns:

  • (String)

    the current value of name


13
14
15
# File 'lib/lastfm/artist.rb', line 13

def name
  @name
end

#playcountFixnum

Returns the current value of playcount.

Returns:

  • (Fixnum)

    the current value of playcount


13
14
15
# File 'lib/lastfm/artist.rb', line 13

def playcount
  @playcount
end

#similarArray

Returns the current value of similar.

Returns:

  • (Array)

    the current value of similar


13
14
15
# File 'lib/lastfm/artist.rb', line 13

def similar
  @similar
end

#streamableBoolean

Returns the current value of streamable.

Returns:

  • (Boolean)

    the current value of streamable


13
14
15
# File 'lib/lastfm/artist.rb', line 13

def streamable
  @streamable
end

#tagsArray

Returns the current value of tags.

Returns:

  • (Array)

    the current value of tags


13
14
15
# File 'lib/lastfm/artist.rb', line 13

def tags
  @tags
end

#urlString

Returns the current value of url.

Returns:

  • (String)

    the current value of url


13
14
15
# File 'lib/lastfm/artist.rb', line 13

def url
  @url
end

#wikiLastFM::Wiki

Returns the current value of wiki.

Returns:


13
14
15
# File 'lib/lastfm/artist.rb', line 13

def wiki
  @wiki
end

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:


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

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:


33
34
35
36
37
38
# File 'lib/lastfm/artist.rb', line 33

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:


49
50
51
52
53
54
# File 'lib/lastfm/artist.rb', line 49

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:


65
66
67
# File 'lib/lastfm/artist.rb', line 65

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:


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

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:


91
92
93
# File 'lib/lastfm/artist.rb', line 91

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:


101
102
103
# File 'lib/lastfm/artist.rb', line 101

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:


114
115
116
117
118
119
# File 'lib/lastfm/artist.rb', line 114

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:


129
130
131
132
133
134
# File 'lib/lastfm/artist.rb', line 129

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:


144
145
146
147
148
# File 'lib/lastfm/artist.rb', line 144

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:


159
160
161
162
163
164
# File 'lib/lastfm/artist.rb', line 159

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:


172
173
174
# File 'lib/lastfm/artist.rb', line 172

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:


183
184
185
186
187
188
# File 'lib/lastfm/artist.rb', line 183

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:


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

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:


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

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:


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

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:


237
238
239
240
# File 'lib/lastfm/artist.rb', line 237

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:


247
248
249
250
# File 'lib/lastfm/artist.rb', line 247

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