Package de.umass.lastfm
Class Track
java.lang.Object
de.umass.lastfm.ImageHolder
de.umass.lastfm.MusicEntry
de.umass.lastfm.Track
Bean that contains information related to
Track
s and provides bindings to methods
in the track.
namespace.- Author:
- Janni Kovacs
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
static final String
protected String
protected String
static final String
protected String
protected int
protected boolean
protected String
protected boolean
protected Date
protected int
static final String
Fields inherited from class de.umass.lastfm.MusicEntry
id, listeners, mbid, name, percentageChange, playcount, streamable, tags, url, userPlaycount
Fields inherited from class de.umass.lastfm.ImageHolder
imageUrls
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Result
Tag an album using a list of user supplied tags.static Result
Ban a track for a given user profile.getAlbum()
static Collection
<BuyLink> getBuylinks
(String artist, String albumOrMbid, String country, String apiKey) Get a list of Buy Links for a particular Track.static Track
getCorrection
(String artist, String track, String apiKey) Use the last.fm corrections data to check whether the supplied track has a correction to a canonical track.int
Returns the duration of the song, if available, in seconds.static Track
Get the metadata for a track on Last.fm using the artist/track name or a musicbrainz id.static Track
Get the metadata for a track on Last.fm using the artist/track name or a musicbrainz id.getLastFmInfo
(String key) Returns last.fm specific information about this Track.Returns the location (URL) of this Track.Returns the time when the track was played, if this data is available (e.g.int
Returns the position of this track in its associated album, or -1 if not available.static Collection
<Track> getSimilar
(String artist, String trackOrMbid, String apiKey) Get the similar tracks for this track on Last.fm, based on listening data.
You have to provide either an artist and a track name or an mbid.static Collection
<String> Get the tags applied by an individual user to an track on Last.fm.static Collection
<User> getTopFans
(String artist, String trackOrMbid, String apiKey) Retrieves the top fans for the given track.static Collection
<Tag> getTopTags
(String artist, String trackOrMbid, String apiKey) Retrieves the top tags for the given track.boolean
boolean
static Result
Love a track for a user profile.static Result
Remove a user's tag from a track.static ScrobbleResult
scrobble
(ScrobbleData scrobbleData, Session session) static ScrobbleResult
static List
<ScrobbleResult> scrobble
(List<ScrobbleData> scrobbleData, Session session) static Collection
<Track> Searches for a track with the given name and returns a list of possible matches.static Collection
<Track> Searches for a track with the given name and returns a list of possible matches.static Result
Share a track twith one or more Last.fm users or other friends.toString()
static Result
UnBan a track for a given user profile.static Result
UnLove a track for a user profile.static ScrobbleResult
updateNowPlaying
(ScrobbleData scrobbleData, Session session) static ScrobbleResult
updateNowPlaying
(String artistName, String trackName, Session session) Methods inherited from class de.umass.lastfm.MusicEntry
getId, getListeners, getMbid, getName, getPercentageChange, getPlaycount, getTags, getUrl, getUserPlaycount, getWikiLastChanged, getWikiSummary, getWikiText, isStreamable, loadStandardInfo
Methods inherited from class de.umass.lastfm.ImageHolder
availableSizes, getImageURL, loadImages
-
Field Details
-
ARTIST_PAGE
- See Also:
-
ALBUM_PAGE
- See Also:
-
TRACK_PAGE
- See Also:
-
artist
-
artistMbid
-
album
-
albumMbid
-
position
protected int position -
fullTrackAvailable
protected boolean fullTrackAvailable -
nowPlaying
protected boolean nowPlaying -
playedWhen
-
duration
protected int duration -
location
-
lastFmExtensionInfos
-
-
Constructor Details
-
Track
-
Track
-
-
Method Details
-
getDuration
public int getDuration()Returns the duration of the song, if available, in seconds. The duration attribute is only available for tracks retrieved byPlaylist.fetch
andTrack.getInfo
.- Returns:
- duration in seconds
-
getArtist
-
getArtistMbid
-
getAlbum
-
getAlbumMbid
-
isFullTrackAvailable
public boolean isFullTrackAvailable() -
isNowPlaying
public boolean isNowPlaying() -
getLocation
Returns the location (URL) of this Track. This information is only available with theRadio
services.- Returns:
- the location
-
getLastFmInfo
Returns last.fm specific information about this Track. Only available in Tracks, fetched from radio-playlists. key can be one of the following:- artistpage
- albumpage
- trackpage
- buyTrackURL
- buyAlbumURL
- freeTrackURL
Note that the key string is case sensitive.- Parameters:
key
- A key- Returns:
- associated value
- See Also:
-
getPlayedWhen
Returns the time when the track was played, if this data is available (e.g. for recent tracks) ornull
, if this data is not available.- Returns:
- the date when the track was played or
null
-
getPosition
public int getPosition()Returns the position of this track in its associated album, or -1 if not available.- Returns:
- the album position
-
search
Searches for a track with the given name and returns a list of possible matches.- Parameters:
track
- Track nameapiKey
- The API key- Returns:
- a list of possible matches
- See Also:
-
search
Searches for a track with the given name and returns a list of possible matches. Specify an artist name or a limit to narrow down search results. Passnull
for the artist parameter if you want to specify a limit but don't want to define an artist.- Parameters:
artist
- Artist's name ornull
track
- Track namelimit
- Number of maximum resultsapiKey
- The API key- Returns:
- a list of possible matches
-
getTopTags
Retrieves the top tags for the given track. You either have to specify a track and artist name or a mbid. If you specify an mbid you may passnull
for the first parameter.- Parameters:
artist
- Artist name ornull
if an MBID is specifiedtrackOrMbid
- Track name or MBIDapiKey
- The API key- Returns:
- list of tags
-
getTopFans
Retrieves the top fans for the given track. You either have to specify a track and artist name or a mbid. If you specify an mbid you may passnull
for the first parameter.- Parameters:
artist
- Artist name ornull
if an MBID is specifiedtrackOrMbid
- Track name or MBIDapiKey
- The API key- Returns:
- list of fans
-
addTags
Tag an album using a list of user supplied tags.- Parameters:
artist
- The artist name in questiontrack
- The track name in questiontags
- A comma delimited list of user supplied tags to apply to this track. Accepts a maximum of 10 tags.session
- A Session instance.- Returns:
- the Result of the operation
-
removeTag
Remove a user's tag from a track.- Parameters:
artist
- The artist name in questiontrack
- The track name in questiontag
- A single user tag to remove from this track.session
- A Session instance.- Returns:
- the Result of the operation
-
love
Love a track for a user profile. This needs to be supplemented with a scrobbling submission containing the 'love' rating (see the audioscrobbler API).- Parameters:
artist
- An artist nametrack
- A track namesession
- A Session instance- Returns:
- the Result of the operation
-
unlove
UnLove a track for a user profile.- Parameters:
artist
- An artist nametrack
- A track namesession
- A Session instance- Returns:
- the Result of the operation
-
ban
Ban a track for a given user profile. This needs to be supplemented with a scrobbling submission containing the 'ban' rating (see the audioscrobbler API).- Parameters:
artist
- An artist nametrack
- A track namesession
- A Session instance- Returns:
- the Result of the operation
-
unban
UnBan a track for a given user profile.- Parameters:
artist
- An artist nametrack
- A track namesession
- A Session instance- Returns:
- the Result of the operation
-
getSimilar
Get the similar tracks for this track on Last.fm, based on listening data.
You have to provide either an artist and a track name or an mbid. Passnull
for parameters you don't need.- Parameters:
artist
- The artist name in questiontrackOrMbid
- The track name in question or the track's MBIDapiKey
- A Last.fm API key.- Returns:
- a list of similar
Track
s
-
getTags
Get the tags applied by an individual user to an track on Last.fm.- Parameters:
artist
- The artist name in questiontrack
- The track name in questionsession
- A Session instance- Returns:
- a list of tags
-
getInfo
Get the metadata for a track on Last.fm using the artist/track name or a musicbrainz id.- Parameters:
artist
- The artist name in question ornull
if an mbid is specifiedtrackOrMbid
- The track name in question or the musicbrainz id for the trackapiKey
- A Last.fm API key.- Returns:
- Track information
-
getInfo
public static Track getInfo(String artist, String trackOrMbid, Locale locale, String username, String apiKey) Get the metadata for a track on Last.fm using the artist/track name or a musicbrainz id.- Parameters:
artist
- The artist name in question ornull
if an mbid is specifiedtrackOrMbid
- The track name in question or the musicbrainz id for the tracklocale
- The language to fetch info in, ornull
username
- The username for the context of the request, ornull
. If supplied, the user's playcount for this track and whether they have loved the track is included in the responseapiKey
- A Last.fm API key.- Returns:
- Track information
-
getBuylinks
public static Collection<BuyLink> getBuylinks(String artist, String albumOrMbid, String country, String apiKey) Get a list of Buy Links for a particular Track. It is required that you supply either the artist and track params or the mbid param.- Parameters:
artist
- The artist name in questionalbumOrMbid
- Track name or MBIDcountry
- A country name, as defined by the ISO 3166-1 country names standardapiKey
- A Last.fm API key- Returns:
- a Collection of
BuyLink
s
-
getCorrection
Use the last.fm corrections data to check whether the supplied track has a correction to a canonical track. This method returns a newTrack
object containing the corrected data, ornull
if the supplied Artist/Track combination was not found.- Parameters:
artist
- The artist name to correcttrack
- The track name to correctapiKey
- A Last.fm API key- Returns:
- a new
Track
, ornull
-
scrobble
-
scrobble
public static ScrobbleResult scrobble(String artistName, String trackName, int timestamp, Session session) -
scrobble
-
updateNowPlaying
-
updateNowPlaying
-
toString
-