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
Tracks and provides bindings to methods
in the track. namespace.- Author:
- Janni Kovacs
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringstatic final Stringprotected Stringprotected Stringstatic final Stringprotected Stringprotected intprotected booleanprotected Stringprotected booleanprotected Dateprotected intstatic final StringFields inherited from class de.umass.lastfm.MusicEntry
id, listeners, mbid, name, percentageChange, playcount, streamable, tags, url, userPlaycountFields inherited from class de.umass.lastfm.ImageHolder
imageUrls -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ResultTag an album using a list of user supplied tags.static ResultBan 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 TrackgetCorrection(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.intReturns the duration of the song, if available, in seconds.static TrackGet the metadata for a track on Last.fm using the artist/track name or a musicbrainz id.static TrackGet 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.intReturns 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.booleanbooleanstatic ResultLove a track for a user profile.static ResultRemove a user's tag from a track.static ScrobbleResultscrobble(ScrobbleData scrobbleData, Session session) static ScrobbleResultstatic 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 ResultShare a track twith one or more Last.fm users or other friends.toString()static ResultUnBan a track for a given user profile.static ResultUnLove a track for a user profile.static ScrobbleResultupdateNowPlaying(ScrobbleData scrobbleData, Session session) static ScrobbleResultupdateNowPlaying(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, loadStandardInfoMethods 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.fetchandTrack.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 theRadioservices.- 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. Passnullfor the artist parameter if you want to specify a limit but don't want to define an artist.- Parameters:
artist- Artist's name ornulltrack- 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 passnullfor the first parameter.- Parameters:
artist- Artist name ornullif 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 passnullfor the first parameter.- Parameters:
artist- Artist name ornullif 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. Passnullfor 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
Tracks
-
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 ornullif 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 ornullif an mbid is specifiedtrackOrMbid- The track name in question or the musicbrainz id for the tracklocale- The language to fetch info in, ornullusername- 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
BuyLinks
-
getCorrection
Use the last.fm corrections data to check whether the supplied track has a correction to a canonical track. This method returns a newTrackobject containing the corrected data, ornullif 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
-