playlists-0.1.0.0: Library and executable for working with playlist files.

Safe HaskellNone

Text.Playlist

Contents

Synopsis

Playlist Types

data Track Source

A single music file or streaming URL.

Constructors

Track 

Fields

trackURL :: Text

URL for a file or streaming resource.

trackTitle :: Maybe Text

Optional title.

Instances

type Playlist = [Track]Source

A list of Tracks.

Playlist Formats

Parsing and Generating

parsePlaylist :: Format -> ByteString -> Either String PlaylistSource

Parse a playlist from a ByteString. Parsing may fail in which case an error message is returned in Left.

 content <- BS.getContents
 case parsePlaylist M3U content of
  Left err -> fail $ "failed to parse playlist: " ++ err
  Right x  -> return x

generatePlaylist :: Format -> Playlist -> ByteStringSource

Generate a lazy ByteString containing playlist data from the given playlist and in the given format.

 BL.putStr $ generatePlaylist M3U somePlaylist