Class Playlist

java.lang.Object
de.umass.lastfm.Playlist

public class Playlist extends Object
Bean for music playlists. Contains the fetch method and various fetchXXX methods to retrieve playlists from the server. Playlists are identified by lastfm:// playlist urls. Valid urls include:
  • Album Playlists: lastfm://playlist/album/<album_id>
  • User Playlists: lastfm://playlist/<playlist_id>
  • Tag Playlists: lastfm://playlist/tag/<tag_name>/freetracks
See http://www.last.fm/api/playlists for more information about playlists.
Author:
Janni Kovacs
  • Method Details

    • getCreator

      public String getCreator()
    • getId

      public int getId()
    • getSize

      public int getSize()
    • getTitle

      public String getTitle()
    • getAnnotation

      public String getAnnotation()
    • getTracks

      public Collection<Track> getTracks()
    • fetchAlbumPlaylist

      public static Playlist fetchAlbumPlaylist(String albumId, String apiKey)
      Fetches an album playlist, which contains the tracks of the specified album.
      Parameters:
      albumId - The album id as returned in Album.getInfo.
      apiKey - A Last.fm API key.
      Returns:
      a playlist
    • fetchUserPlaylist

      public static Playlist fetchUserPlaylist(int playlistId, String apiKey)
      Fetches a user-created playlist.
      Parameters:
      playlistId - A playlist id.
      apiKey - A Last.fm API key.
      Returns:
      a playlist
    • fetchTagPlaylist

      public static Playlist fetchTagPlaylist(String tag, String apiKey)
      Fetches a playlist of freetracks for a given tag name.
      Parameters:
      tag - A tag name.
      apiKey - A Last.fm API key.
      Returns:
      a playlist
    • fetch

      public static Playlist fetch(String playlistUrl, String apiKey)
      Fetches a playlist using a lastfm playlist url. See the class description for a list of valid playlist urls.
      Parameters:
      playlistUrl - A valid playlist url.
      apiKey - A Last.fm API key.
      Returns:
      a playlist
    • addTrack

      public static Result addTrack(int playlistId, String artist, String track, Session session)
      Add a track to a Last.fm user's playlist.
      Parameters:
      playlistId - The ID of the playlist - this is available in user.getPlaylists
      artist - The artist name that corresponds to the track to be added.
      track - The track name to add to the playlist.
      session - A Session instance.
      Returns:
      the result of the operation
    • create

      public static Playlist create(String title, String description, Session session)
      Creates a Last.fm playlist.
      Parameters:
      title - A title for the playlist
      description - A description for the playlist
      session - A Session instance
      Returns:
      the result of the operation