module Web.Last.Geo 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 getEvents :: Maybe String -> Maybe String -> Maybe String -> Maybe String -> Last (Paged (Event)) getEvents location lat long distance = pagedRequest "geo.getevents" [] [("location",location),("lat",lat),("long",long),("distance",distance)] pa pno where pa = objOf $ inObj "events" $ llArr "event" P.event pno = objOf $ inObj "events" $ P.readInt <$> ll "totalpages" strJS -- String is playcount getTopArtists :: String -> Last [(Artist,String)] getTopArtists country = anonRequest "geo.gettopartists" [("country",country)] [] pa where pa = objOf $ inObj "topartists" $ llArr "artist" $ P.artist &&& (objOf $ ll "playcount" strJS) -- String is playcount getTopTracks :: String -> Last [(Track,String)] getTopTracks country = anonRequest "geo.gettoptracks" [("country",country)] [] pa where pa = objOf $ inObj "toptracks" $ llArr "track" $ P.track &&& (objOf $ ll "playcount" strJS)