{-# LANGUAGE OverloadedStrings, FlexibleContexts #-}
module Network.MPD.Commands.CurrentPlaylist
( addId
, add
, clear
, delete
, deleteRange
, deleteId
, move
, moveRange
, moveId
, playlist
, playlistFind
, playlistInfo
, playlistInfoRange
, playlistId
, playlistSearch
, plChanges
, plChangesPosId
, prio
, prioId
, shuffle
, swap
, swapId
, addTagId
, clearTagId
, rangeId
) 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
deleteRange :: MonadMPD m => (Position, Position) -> m ()
deleteRange = A.runCommand . A.deleteRange
deleteId :: MonadMPD m => Id -> m ()
deleteId = A.runCommand . A.deleteId
move :: MonadMPD m => Position -> Position -> m ()
move pos = A.runCommand . A.move pos
moveRange :: MonadMPD m => (Position, Position) -> Position -> m ()
moveRange range = A.runCommand . A.moveRange range
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
prio :: MonadMPD m => Priority -> (Position, Position) -> m ()
prio p = A.runCommand . A.prio p
prioId :: MonadMPD m => Priority -> Id -> m ()
prioId p = A.runCommand . A.prioId p
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
addTagId :: (MonadMPD m) => Id -> Metadata -> Value -> m ()
addTagId id' tag = A.runCommand . A.addTagId id' tag
clearTagId :: (MonadMPD m) => Id -> Metadata -> m ()
clearTagId id' = A.runCommand . A.clearTagId id'
rangeId :: (MonadMPD m) => Id -> (Maybe Double, Maybe Double) -> m ()
rangeId id' = A.runCommand . A.rangeId id'