Class: LastFM::Album

Inherits:
Struct
  • Object
show all
Defined in:
lib/lastfm/album.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

#artistLastFM::Artist, String

Returns the current value of artist.

Returns:



16
17
18
# File 'lib/lastfm/album.rb', line 16

def artist
  @artist
end

#idFixnum

Returns the current value of id.

Returns:

  • (Fixnum)

    the current value of id



16
17
18
# File 'lib/lastfm/album.rb', line 16

def id
  @id
end

#imagesHash

Returns the current value of images.

Returns:

  • (Hash)

    the current value of images



16
17
18
# File 'lib/lastfm/album.rb', line 16

def images
  @images
end

#listenersFixnum

Returns the current value of listeners.

Returns:

  • (Fixnum)

    the current value of listeners



16
17
18
# File 'lib/lastfm/album.rb', line 16

def listeners
  @listeners
end

#mbidString

Returns the current value of mbid.

Returns:

  • (String)

    the current value of mbid



16
17
18
# File 'lib/lastfm/album.rb', line 16

def mbid
  @mbid
end

#nameString

Returns the current value of name.

Returns:

  • (String)

    the current value of name



16
17
18
# File 'lib/lastfm/album.rb', line 16

def name
  @name
end

#playcountFixnum

Returns the current value of playcount.

Returns:

  • (Fixnum)

    the current value of playcount



16
17
18
# File 'lib/lastfm/album.rb', line 16

def playcount
  @playcount
end

#release_dateTime

Returns the current value of release_date.

Returns:

  • (Time)

    the current value of release_date



16
17
18
# File 'lib/lastfm/album.rb', line 16

def release_date
  @release_date
end

#streamableBoolean

Returns the current value of streamable.

Returns:

  • (Boolean)

    the current value of streamable



16
17
18
# File 'lib/lastfm/album.rb', line 16

def streamable
  @streamable
end

#tagsArray<LastFM::Tag>

Returns the current value of tags.

Returns:



16
17
18
# File 'lib/lastfm/album.rb', line 16

def tags
  @tags
end

#tracksArray<LastFM::Track>

Returns the current value of tracks.

Returns:



16
17
18
# File 'lib/lastfm/album.rb', line 16

def tracks
  @tracks
end

#urlString

Returns the current value of url.

Returns:

  • (String)

    the current value of url



16
17
18
# File 'lib/lastfm/album.rb', line 16

def url
  @url
end

#wikiLastFM::Wiki

Returns the current value of wiki.

Returns:



16
17
18
# File 'lib/lastfm/album.rb', line 16

def wiki
  @wiki
end

Class Method Details

.add_tags(params) ⇒ Object

Tag an album using a list of user supplied tags.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required)

    the artist name

  • :album (String, required)

    the album name

  • :tags (Array, required)

    up to 10 tags to apply to this album

See Also:



27
28
29
30
# File 'lib/lastfm/album.rb', line 27

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

Get a list of buy links for an album.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :album (String, required unless :mbid)

    the album name

  • :country (String, required)

    a country name, as defined by ISO 3166-1

  • :mbid (String, optional)

    the musicbrainz id for the album

  • :autocorrect (Boolean, optional)

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

Returns:

  • (Array<LastFM::Buylink>)

    collection of links where this album can be bought or downloaded

See Also:



41
42
43
44
45
46
47
48
# File 'lib/lastfm/album.rb', line 41

def get_buylinks( params )
  xml = LastFM.get( "album.getBuylinks", params )
  [:physical, :download].each_with_object([]) do |type, buylinks|
    xml.find("affiliations/#{type}s/affiliation").each do |buylink|
      buylinks << LastFM::Buylink.from_xml( buylink, :type => type )
    end
  end
end

.get_info(params) ⇒ LastFM::Album

Get the metadata for an album.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :album (String, required unless :mbid)

    the album name

  • :mbid (String, optional)

    the musicbrainz id for the album

  • :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 album is to be returned in the reponse

Returns:

  • (LastFM::Album)

    album constructed from the metadata contained in the response

See Also:



60
61
62
63
# File 'lib/lastfm/album.rb', line 60

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

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

Get shouts for an album.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :album (String, required unless :mbid)

    the album name

  • :mbid (String, optional)

    the musicbrainz id for the album

  • :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:



75
76
77
78
79
80
# File 'lib/lastfm/album.rb', line 75

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

.get_tags(params) ⇒ Object

Get the tags applied by an individual user to an album.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :album (String, required unless :mbid)

    the album name

  • :mbid (String, optional)

    the musicbrainz id for the album

  • :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:



90
91
92
93
94
95
96
97
# File 'lib/lastfm/album.rb', line 90

def get_tags( params )
  secure = !params.include?(:user)
  LastFM.requires_authentication if secure
  xml = LastFM.get( "album.getTags", params, secure )
  xml.find('tags/tag').map do |tag|
    LastFM::Tag.from_xml( tag )
  end
end

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

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

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required unless :mbid)

    the artist name

  • :album (String, required unless :mbid)

    the album name

  • :mbid (String, optional)

    the musicbrainz id for the album

  • :autocorrect (Boolean, optional)

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

Returns:

  • (Array<LastFM::Tag>)

    list of tags sorted by popularity

See Also:



107
108
109
110
111
112
# File 'lib/lastfm/album.rb', line 107

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

.remove_tag(params) ⇒ Object

Remove a user’s tag from an album.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required)

    the artist name

  • :album (String, required)

    the album name

  • :tag (String, required)

    a single user tag to remove from this album

See Also:



120
121
122
123
# File 'lib/lastfm/album.rb', line 120

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

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

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

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :album (String, required)

    the album name

  • :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:



132
133
134
135
136
137
# File 'lib/lastfm/album.rb', line 132

def search( params )
  xml = LastFM.get( "album.search", params )
  xml.find('results/albummatches/album').map do |album|
    LastFM::Album.from_xml( album )
  end
end

.share(params) ⇒ Object

Share an album with one or more Last.fm users or other friends.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :artist (String, required)

    the artist name

  • :album (String, required)

    the album 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:



147
148
149
150
# File 'lib/lastfm/album.rb', line 147

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