module Network.Lastfm.API.Track
( addTags, ban, getBuyLinks, getCorrection, getFingerprintMetadata
, getInfo, getShouts, getSimilar, getTags, getTopFans, getTopTags
, love, removeTag, scrobble, search, share, unban, unlove, updateNowPlaying
) where
import Control.Arrow ((|||))
import Network.Lastfm
addTags :: Artist -> Track -> [Tag] -> APIKey -> SessionKey -> Secret -> Lastfm Response
addTags artist track tags apiKey sessionKey secret = callAPIsigned secret
[ (#) (Method "track.addTags")
, (#) artist
, (#) track
, (#) tags
, (#) apiKey
, (#) sessionKey
]
ban :: Artist -> Track -> APIKey -> SessionKey -> Secret -> Lastfm Response
ban artist track apiKey sessionKey secret = callAPIsigned secret
[ (#) (Method "track.ban")
, (#) artist
, (#) track
, (#) apiKey
, (#) sessionKey
]
getBuyLinks :: Either (Artist, Track) Mbid -> Maybe Autocorrect -> Country -> APIKey -> Lastfm Response
getBuyLinks a autocorrect country apiKey = callAPI $
target a ++
[ (#) (Method "track.getBuyLinks")
, (#) autocorrect
, (#) country
, (#) apiKey
]
getCorrection :: Artist -> Track -> APIKey -> Lastfm Response
getCorrection artist track apiKey = callAPI
[ (#) (Method "track.getCorrection")
, (#) artist
, (#) track
, (#) apiKey
]
getFingerprintMetadata :: Fingerprint -> APIKey -> Lastfm Response
getFingerprintMetadata fingerprint apiKey = callAPI
[ (#) (Method "track.getFingerprintMetadata")
, (#) fingerprint
, (#) apiKey
]
getInfo :: Either (Artist, Track) Mbid -> Maybe Autocorrect -> Maybe Username -> APIKey -> Lastfm Response
getInfo a autocorrect username apiKey = callAPI $
target a ++
[ (#) (Method "track.getInfo")
, (#) autocorrect
, (#) username
, (#) apiKey
]
getShouts :: Either (Artist, Track) Mbid -> Maybe Autocorrect -> Maybe Page -> Maybe Limit -> APIKey -> Lastfm Response
getShouts a autocorrect page limit apiKey = callAPI $
target a ++
[ (#) (Method "track.getShouts")
, (#) autocorrect
, (#) page
, (#) limit
, (#) apiKey
]
getSimilar :: Either (Artist, Track) Mbid -> Maybe Autocorrect -> Maybe Limit -> APIKey -> Lastfm Response
getSimilar a autocorrect limit apiKey = callAPI $
target a ++
[ (#) (Method "track.getSimilar")
, (#) autocorrect
, (#) limit
, (#) apiKey
]
getTags :: Either (Artist, Track) Mbid -> Maybe Autocorrect -> Either User (SessionKey, Secret) -> APIKey -> Lastfm Response
getTags a autocorrect b apiKey = case b of
Left user -> callAPI $ target a ++ [(#) user] ++ args
Right (sessionKey, secret) -> callAPIsigned secret $ target a ++ [(#) sessionKey] ++ args
where args =
[ (#) (Method "track.getTags")
, (#) autocorrect
, (#) apiKey
]
getTopFans :: Either (Artist, Track) Mbid -> Maybe Autocorrect -> APIKey -> Lastfm Response
getTopFans a autocorrect apiKey = callAPI $
target a ++
[ (#) (Method "track.getTopFans")
, (#) autocorrect
, (#) apiKey
]
getTopTags :: Either (Artist, Track) Mbid -> Maybe Autocorrect -> APIKey -> Lastfm Response
getTopTags a autocorrect apiKey = callAPI $
target a ++
[ (#) (Method "track.getTopTags")
, (#) autocorrect
, (#) apiKey
]
love :: Artist -> Track -> APIKey -> SessionKey -> Secret -> Lastfm Response
love artist track apiKey sessionKey secret = callAPIsigned secret
[ (#) (Method "track.love")
, (#) artist
, (#) track
, (#) apiKey
, (#) sessionKey
]
removeTag :: Artist -> Track -> Tag -> APIKey -> SessionKey -> Secret -> Lastfm Response
removeTag artist track tag apiKey sessionKey secret = callAPIsigned secret
[ (#) (Method "track.removeTag")
, (#) artist
, (#) track
, (#) tag
, (#) apiKey
, (#) sessionKey
]
scrobble :: ( Timestamp, Maybe Album, Artist, Track, Maybe AlbumArtist
, Maybe Duration, Maybe StreamId, Maybe ChosenByUser
, Maybe Context, Maybe TrackNumber, Maybe Mbid )
-> APIKey
-> SessionKey
-> Secret
-> Lastfm Response
scrobble (timestamp, album, artist, track, albumArtist, duration, streamId, chosenByUser, context, trackNumber, mbid) apiKey sessionKey secret = callAPIsigned secret
[ (#) (Method "track.scrobble")
, (#) timestamp
, (#) artist
, (#) track
, (#) album
, (#) albumArtist
, (#) duration
, (#) streamId
, (#) chosenByUser
, (#) context
, (#) trackNumber
, (#) mbid
, (#) apiKey
, (#) sessionKey
]
search :: Track -> Maybe Page -> Maybe Limit -> Maybe Artist -> APIKey -> Lastfm Response
search track page limit artist apiKey = callAPI
[ (#) (Method "track.search")
, (#) track
, (#) page
, (#) limit
, (#) artist
, (#) apiKey
]
share :: Artist -> Track -> Recipient -> Maybe Message -> Maybe Public -> APIKey -> SessionKey -> Secret -> Lastfm Response
share artist track recipient message public apiKey sessionKey secret = callAPIsigned secret
[ (#) (Method "track.share")
, (#) artist
, (#) track
, (#) recipient
, (#) public
, (#) message
, (#) apiKey
, (#) sessionKey
]
unban :: Artist -> Track -> APIKey -> SessionKey -> Secret -> Lastfm Response
unban artist track apiKey sessionKey secret = callAPIsigned secret
[ (#) (Method "track.unban")
, (#) artist
, (#) track
, (#) apiKey
, (#) sessionKey
]
unlove :: Artist -> Track -> APIKey -> SessionKey -> Secret -> Lastfm Response
unlove artist track apiKey sessionKey secret = callAPIsigned secret
[ (#) (Method "track.unlove")
, (#) artist
, (#) track
, (#) apiKey
, (#) sessionKey
]
updateNowPlaying :: Artist
-> Track
-> Maybe Album
-> Maybe AlbumArtist
-> Maybe Context
-> Maybe TrackNumber
-> Maybe Mbid
-> Maybe Duration
-> APIKey
-> SessionKey
-> Secret
-> Lastfm Response
updateNowPlaying artist track album albumArtist context trackNumber mbid duration apiKey sessionKey secret = callAPIsigned secret
[ (#) (Method "track.updateNowPlaying")
, (#) artist
, (#) track
, (#) album
, (#) albumArtist
, (#) context
, (#) trackNumber
, (#) mbid
, (#) duration
, (#) apiKey
, (#) sessionKey
]
target :: Either (Artist, Track) Mbid -> [(String, String)]
target = (\(artist, track) -> [(#) artist, (#) track]) ||| return . (#)