Class: LastFM::Api::Album
- Inherits:
-
Object
- Object
- LastFM::Api::Album
- Defined in:
- lib/lastfm/api/album.rb
Class Method Summary collapse
-
.add_tags(params) ⇒ Object
Tag an album using a list of user supplied tags.
-
.get_buylinks(params) ⇒ Array<LastFM::Buylink>
Get a list of buy links for an album.
-
.get_info(params) ⇒ LastFM::Album
Get the metadata for an album.
-
.get_shouts(params) ⇒ Array<LastFM::Shout>
Get shouts for an album.
-
.get_tags(params) ⇒ Object
Get the tags applied by an individual user to an album.
-
.get_top_tags(params) ⇒ Array<LastFM::Tag>
Get the top tags for an album, ordered by popularity.
-
.remove_tag(params) ⇒ Object
Remove a user’s tag from an album.
-
.search(params) ⇒ Array<LastFM::Album>
Search for an album by name.
-
.share(params) ⇒ Object
Share an album with one or more Last.fm users or other friends.
Class Method Details
.add_tags(params) ⇒ Object
Tag an album using a list of user supplied tags.
12 13 14 15 |
# File 'lib/lastfm/api/album.rb', line 12 def ( params ) LastFM.requires_authentication LastFM.post( "album.addTags", params ) end |
.get_buylinks(params) ⇒ Array<LastFM::Buylink>
Get a list of buy links for an album.
26 27 28 29 30 31 32 33 |
# File 'lib/lastfm/api/album.rb', line 26 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.
45 46 47 48 |
# File 'lib/lastfm/api/album.rb', line 45 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.
60 61 62 63 64 65 |
# File 'lib/lastfm/api/album.rb', line 60 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.
75 76 77 78 79 80 81 82 |
# File 'lib/lastfm/api/album.rb', line 75 def ( 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.
92 93 94 95 96 97 |
# File 'lib/lastfm/api/album.rb', line 92 def ( 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.
105 106 107 108 |
# File 'lib/lastfm/api/album.rb', line 105 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.
117 118 119 120 121 122 |
# File 'lib/lastfm/api/album.rb', line 117 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.
132 133 134 135 |
# File 'lib/lastfm/api/album.rb', line 132 def share( params ) LastFM.requires_authentication LastFM.post( "album.share", params ) end |