module Web.Last.Library where import Control.Applicative import Control.Arrow import Web.Last.Types import Web.Last.Request import qualified Web.Last.Parsing as P import Text.JSON.Combinators -- addAlbum needs auth -- addArtist needs auth -- addTrack needs auth -- Strings are playcount,tagcount getAlbums :: String -> Last (Paged (Album,(String,String))) getAlbums user = pagedRequest "library.getalbums" [("user",user)] [] pa pno where pa = objOf $ inObj "albums" $ llArr "album" $ P.album &&& objOf ((ll "playcount" strJS) &&& (ll "tagcount" strJS)) pno = objOf $ inObj "albums" $ P.readInt <$> ll "totalPages" strJS -- Strings are playcount,tagcount getArtists :: String -> Last (Paged (Artist,(String,String))) getArtists user = pagedRequest "library.getartists" [("user",user)] [] pa pno where pa = objOf $ inObj "artists" $ llArr "artist" $ P.artist &&& objOf ((ll "playcount" strJS) &&& (ll "tagcount" strJS)) pno = objOf $ inObj "artists" $ P.readInt <$> ll "totalPages" strJS -- Strings are playcount,tagcount getTracks :: String -> Last (Paged (Track,(String,String))) getTracks user = pagedRequest "library.gettracks" [("user",user)] [] pa pno where pa = objOf $ inObj "tracks" $ llArr "track" $ P.track &&& objOf ((ll "playcount" strJS) &&& (ll "tagcount" strJS)) pno = objOf $ inObj "tracks" $ P.readInt <$> ll "totalPages" strJS