public class Track extends MusicEntry
Track
s and provides bindings to methods
in the track.
namespace.Modifier and Type | Class and Description |
---|---|
private static class |
Track.ScrobbleResultType |
private static class |
Track.TrackFactory |
Modifier and Type | Field and Description |
---|---|
protected String |
album |
static String |
ALBUM_PAGE |
private String |
albumMbid |
private String |
artist |
static String |
ARTIST_PAGE |
private String |
artistMbid |
protected int |
duration |
(package private) static ItemFactory<Track> |
FACTORY |
private boolean |
fullTrackAvailable |
protected Map<String,String> |
lastFmExtensionInfos |
protected String |
location |
private boolean |
nowPlaying |
private Date |
playedWhen |
private int |
position |
static String |
TRACK_PAGE |
id, listeners, mbid, name, percentageChange, playcount, streamable, tags, url, userPlaycount
imageUrls
Modifier | Constructor and Description |
---|---|
protected |
Track(String name,
String url,
String artist) |
protected |
Track(String name,
String url,
String mbid,
int playcount,
int listeners,
boolean streamable,
String artist,
String artistMbid,
boolean fullTrackAvailable,
boolean nowPlaying) |
Modifier and Type | Method and Description |
---|---|
static Result |
addTags(String artist,
String track,
String tags,
Session session)
Tag an album using a list of user supplied tags.
|
static Result |
ban(String artist,
String track,
Session session)
Ban a track for a given user profile.
|
private static List<ScrobbleResult> |
convertToScrobbleResults(Result result,
Track.ScrobbleResultType scrobbleResultType)
Converts a generic web services Result object into a more specific ScrobbleResult.
|
String |
getAlbum() |
String |
getAlbumMbid() |
String |
getArtist() |
String |
getArtistMbid() |
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 |
getDuration()
Returns the duration of the song, if available, in seconds.
|
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.
|
static Track |
getInfo(String artist,
String trackOrMbid,
String apiKey)
Get the metadata for a track on Last.fm using the artist/track name or a musicbrainz id.
|
String |
getLastFmInfo(String key)
Returns last.fm specific information about this Track.
|
String |
getLocation()
Returns the location (URL) of this Track.
|
Date |
getPlayedWhen()
Returns the time when the track was played, if this data is available (e.g. for recent tracks) or
null ,
if this data is not available. |
int |
getPosition()
Returns the position of this track in its associated album, or -1 if not available.
|
static PaginatedResult<Shout> |
getShouts(String artist,
String trackOrMbid,
int page,
int limit,
String apiKey)
Get shouts for a track.
|
static PaginatedResult<Shout> |
getShouts(String artist,
String trackOrMbid,
int page,
String apiKey)
Get shouts for a track.
|
static PaginatedResult<Shout> |
getShouts(String artist,
String trackOrMbid,
String apiKey)
Get shouts for a track.
|
static Collection<Track> |
getSimilar(String artist,
String trackOrMbid,
String apiKey)
Get the similar tracks for this track on Last.fm, based on listening data.
|
static Collection<Track> |
getSimilar(String artist,
String trackOrMbid,
String apiKey,
int limit)
Get the similar tracks for this track on Last.fm, based on listening data.
|
static Collection<String> |
getTags(String artist,
String track,
Session session)
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 |
isFullTrackAvailable() |
boolean |
isNowPlaying() |
static Result |
love(String artist,
String track,
Session session)
Love a track for a user profile.
|
private static void |
parseIntoScrobbleResult(DomElement scrobbleElement,
ScrobbleResult scrobbleResult)
Parses a DomElement containing scrobble or now playing response data into the passed ScrobbleResult.
|
static Result |
removeTag(String artist,
String track,
String tag,
Session session)
Remove a user's tag from a track.
|
static List<ScrobbleResult> |
scrobble(List<ScrobbleData> scrobbleData,
Session session) |
static ScrobbleResult |
scrobble(ScrobbleData scrobbleData,
Session session) |
static ScrobbleResult |
scrobble(String artistName,
String trackName,
int timestamp,
Session session) |
static ScrobbleResult |
scrobble(String artistName,
String albumName,
String trackName,
int timestamp,
Session session) |
static Collection<Track> |
search(String track,
String apiKey)
Searches for a track with the given name and returns a list of possible matches.
|
static Collection<Track> |
search(String artist,
String track,
int limit,
String apiKey)
Searches for a track with the given name and returns a list of possible matches.
|
static Result |
share(String artist,
String track,
String message,
String recipient,
Session session)
Share a track twith one or more Last.fm users or other friends.
|
String |
toString() |
static Result |
unban(String artist,
String track,
Session session)
UnBan a track for a given user profile.
|
static Result |
unlove(String artist,
String track,
Session session)
UnLove a track for a user profile.
|
static ScrobbleResult |
updateNowPlaying(ScrobbleData scrobbleData,
Session session) |
static ScrobbleResult |
updateNowPlaying(String artistName,
String trackName,
Session session) |
getId, getListeners, getMbid, getName, getPercentageChange, getPlaycount, getSimilarityMatch, getTags, getUrl, getUserPlaycount, getWikiLastChanged, getWikiSummary, getWikiText, isStreamable, loadStandardInfo, maybeParseInt
availableSizes, getImageURL, loadImages
static final ItemFactory<Track> FACTORY
public static final String ARTIST_PAGE
public static final String ALBUM_PAGE
public static final String TRACK_PAGE
private String artistMbid
private int position
private boolean fullTrackAvailable
private boolean nowPlaying
private Date playedWhen
protected int duration
protected Map<String,String> lastFmExtensionInfos
public int getDuration()
Playlist.fetch
and
Track.getInfo
.public String getArtistMbid()
public String getAlbumMbid()
public boolean isFullTrackAvailable()
public boolean isNowPlaying()
public String getLocation()
Radio
services.public String getLastFmInfo(String key)
key
- A keyARTIST_PAGE
,
ALBUM_PAGE
,
TRACK_PAGE
public Date getPlayedWhen()
null
,
if this data is not available.null
public int getPosition()
public static Collection<Track> search(String track, String apiKey)
track
- Track nameapiKey
- The API keysearch(String, String, int, String)
public static Collection<Track> search(String artist, String track, int limit, String apiKey)
null
for the artist parameter if you want to specify a limit but don't want
to define an artist.artist
- Artist's name or null
track
- Track namelimit
- Number of maximum resultsapiKey
- The API keypublic static Collection<Tag> getTopTags(String artist, String trackOrMbid, String apiKey)
null
for the first parameter.artist
- Artist name or null
if an MBID is specifiedtrackOrMbid
- Track name or MBIDapiKey
- The API keypublic static Collection<User> getTopFans(String artist, String trackOrMbid, String apiKey)
null
for the first parameter.artist
- Artist name or null
if an MBID is specifiedtrackOrMbid
- Track name or MBIDapiKey
- The API keypublic static Result addTags(String artist, String track, String tags, Session session)
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.public static Result removeTag(String artist, String track, String tag, Session session)
artist
- The artist name in questiontrack
- The track name in questiontag
- A single user tag to remove from this track.session
- A Session instance.public static Result share(String artist, String track, String message, String recipient, Session session)
artist
- An artist name.track
- A track name.message
- A message to send with the recommendation or null
. If not supplied a default message will be used.recipient
- A comma delimited list of email addresses or Last.fm usernames. Maximum is 10.session
- A Session instancepublic static Result love(String artist, String track, Session session)
artist
- An artist nametrack
- A track namesession
- A Session instancepublic static Result unlove(String artist, String track, Session session)
artist
- An artist nametrack
- A track namesession
- A Session instancepublic static Result ban(String artist, String track, Session session)
artist
- An artist nametrack
- A track namesession
- A Session instancepublic static Result unban(String artist, String track, Session session)
artist
- An artist nametrack
- A track namesession
- A Session instancepublic static Collection<Track> getSimilar(String artist, String trackOrMbid, String apiKey)
null
for parameters you don't need.artist
- The artist name in questiontrackOrMbid
- The track name in question or the track's MBIDapiKey
- A Last.fm API key.Track
spublic static Collection<Track> getSimilar(String artist, String trackOrMbid, String apiKey, int limit)
null
for parameters you don't need.artist
- The artist name in questiontrackOrMbid
- The track name in question or the track's MBIDapiKey
- A Last.fm API key.limit
- number of results to returnTrack
spublic static Collection<String> getTags(String artist, String track, Session session)
artist
- The artist name in questiontrack
- The track name in questionsession
- A Session instancepublic static Track getInfo(String artist, String trackOrMbid, String apiKey)
artist
- The artist name in question or null
if an mbid is specifiedtrackOrMbid
- The track name in question or the musicbrainz id for the trackapiKey
- A Last.fm API key.public static Track getInfo(String artist, String trackOrMbid, Locale locale, String username, String apiKey)
artist
- The artist name in question or null
if an mbid is specifiedtrackOrMbid
- The track name in question or the musicbrainz id for the tracklocale
- The language to fetch info in, or null
username
- The username for the context of the request, or null
. 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.public static Collection<BuyLink> getBuylinks(String artist, String albumOrMbid, String country, String apiKey)
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 keyBuyLink
spublic static Track getCorrection(String artist, String track, String apiKey)
Track
object containing the corrected data, or null
if the supplied Artist/Track combination was not found.artist
- The artist name to correcttrack
- The track name to correctapiKey
- A Last.fm API keyTrack
, or null
public static PaginatedResult<Shout> getShouts(String artist, String trackOrMbid, String apiKey)
artist
- The artist nametrackOrMbid
- The track name or a mausicbrainz idapiKey
- A Last.fm API key.Shout
spublic static PaginatedResult<Shout> getShouts(String artist, String trackOrMbid, int page, String apiKey)
artist
- The artist nametrackOrMbid
- The track name or a mausicbrainz idpage
- The page number to fetchapiKey
- A Last.fm API key.Shout
spublic static PaginatedResult<Shout> getShouts(String artist, String trackOrMbid, int page, int limit, String apiKey)
artist
- The artist nametrackOrMbid
- The track name or a mausicbrainz idpage
- The page number to fetchlimit
- An integer used to limit the number of shouts returned per page or -1 for defaultapiKey
- A Last.fm API key.Shout
sprivate static List<ScrobbleResult> convertToScrobbleResults(Result result, Track.ScrobbleResultType scrobbleResultType)
result
- Web services Result.scrobbleResultType
- The type of scrobble result contained within the Result.private static void parseIntoScrobbleResult(DomElement scrobbleElement, ScrobbleResult scrobbleResult)
scrobbleElement
- DomElement containing scrobble or now playing response data.scrobbleResult
- ScrobbleResult to add the response data to.public static ScrobbleResult scrobble(ScrobbleData scrobbleData, Session session)
public static ScrobbleResult scrobble(String artistName, String trackName, int timestamp, Session session)
public static ScrobbleResult scrobble(String artistName, String albumName, String trackName, int timestamp, Session session)
public static List<ScrobbleResult> scrobble(List<ScrobbleData> scrobbleData, Session session)
public static ScrobbleResult updateNowPlaying(ScrobbleData scrobbleData, Session session)
public static ScrobbleResult updateNowPlaying(String artistName, String trackName, Session session)
public String toString()
toString
in class MusicEntry
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses