module Text.Playlist.Internal.ReadWrite
( parserForFormat
, parsePlaylist
, generatePlaylist
) where
import qualified Data.Attoparsec.ByteString as Atto
import Data.ByteString (ByteString)
import qualified Data.ByteString.Lazy as BL
import qualified Data.ByteString.Builder as BL
import qualified Text.Playlist.M3U.Reader as M3U
import qualified Text.Playlist.M3U.Writer as M3U
import qualified Text.Playlist.PLS.Reader as PLS
import qualified Text.Playlist.PLS.Writer as PLS
import Text.Playlist.Types
parserForFormat :: Format -> Atto.Parser Playlist
parserForFormat :: Format -> Parser Playlist
parserForFormat Format
M3U = Parser Playlist
M3U.parsePlaylist
parserForFormat Format
PLS = Parser Playlist
PLS.parsePlaylist
parsePlaylist :: Format -> ByteString -> Either String Playlist
parsePlaylist :: Format -> ByteString -> Either String Playlist
parsePlaylist Format
f = Parser Playlist -> ByteString -> Either String Playlist
forall a. Parser a -> ByteString -> Either String a
Atto.parseOnly (Format -> Parser Playlist
parserForFormat Format
f)
generatePlaylist :: Format -> Playlist -> BL.ByteString
generatePlaylist :: Format -> Playlist -> ByteString
generatePlaylist Format
M3U = Builder -> ByteString
BL.toLazyByteString (Builder -> ByteString)
-> (Playlist -> Builder) -> Playlist -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Playlist -> Builder
M3U.writePlaylist
generatePlaylist Format
PLS = Builder -> ByteString
BL.toLazyByteString (Builder -> ByteString)
-> (Playlist -> Builder) -> Playlist -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Playlist -> Builder
PLS.writePlaylist