{-# LANGUAGE OverloadedStrings, FlexibleContexts #-}
module Network.MPD.Commands.CurrentPlaylist
( addId
, add
, clear
, delete
, deleteId
, move
, moveId
, playlist
, playlistFind
, playlistInfo
, playlistInfoRange
, playlistId
, playlistSearch
, plChanges
, plChangesPosId
, shuffle
, swap
, swapId
) where
import qualified Network.MPD.Applicative.Internal as A
import qualified Network.MPD.Applicative.CurrentPlaylist as A
import Network.MPD.Commands.Query
import Network.MPD.Commands.Types
import Network.MPD.Core
import Network.MPD.Util
import Control.Monad.Error (throwError)
addId :: MonadMPD m => Path -> Maybe Position -> m Id
addId path = A.runCommand . A.addId path
add :: MonadMPD m => Path -> m ()
add = A.runCommand . A.add
clear :: MonadMPD m => m ()
clear = A.runCommand A.clear
delete :: MonadMPD m => Position -> m ()
delete = A.runCommand . A.delete
deleteId :: MonadMPD m => Id -> m ()
deleteId = A.runCommand . A.deleteId
move :: MonadMPD m => Position -> Position -> m ()
move pos = A.runCommand . A.move pos
moveId :: MonadMPD m => Id -> Position -> m ()
moveId i = A.runCommand . A.moveId i
playlist :: MonadMPD m => m [(Position, Path)]
playlist = mapM f =<< getResponse "playlist"
where f s | (pos, name) <- breakChar ':' s
, Just pos' <- parseNum pos
= return (pos', Path name)
| otherwise = throwError . Unexpected $ show s
{-# WARNING playlist "this is deprecated; please use 'playlistInfo' instead." #-}
playlistFind :: MonadMPD m => Query -> m [Song]
playlistFind = A.runCommand . A.playlistFind
playlistInfo :: MonadMPD m => Maybe Position -> m [Song]
playlistInfo = A.runCommand . A.playlistInfo
playlistInfoRange :: MonadMPD m => Maybe (Position, Position) -> m [Song]
playlistInfoRange = A.runCommand . A.playlistInfoRange
playlistId :: MonadMPD m => Maybe Id -> m [Song]
playlistId = A.runCommand . A.playlistId
playlistSearch :: MonadMPD m => Query -> m [Song]
playlistSearch = A.runCommand . A.playlistSearch
plChanges :: MonadMPD m => Integer -> m [Song]
plChanges = A.runCommand . A.plChanges
plChangesPosId :: MonadMPD m => Integer -> m [(Position, Id)]
plChangesPosId = A.runCommand . A.plChangesPosId
shuffle :: MonadMPD m => Maybe (Position, Position)
-> m ()
shuffle = A.runCommand . A.shuffle
swap :: MonadMPD m => Position -> Position -> m ()
swap pos1 = A.runCommand . A.swap pos1
swapId :: MonadMPD m => Id -> Id -> m ()
swapId id1 = A.runCommand . A.swapId id1