packages feed

htaglib 1.0.4 → 1.1.0

raw patch · 12 files changed

+85/−66 lines, 12 filesdep +transformersdep ~basedep ~htaglib

Dependencies added: transformers

Dependency ranges changed: base, htaglib

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+## HTagLib 1.1.0++* Made `getTags`, `getTags'`, `setTags`, and `setTags'` callable from any+  instance of `MonadIO`, not only `IO`.+ ## HTagLib 1.0.4  * Re-wrote the test suite with Hspec.
LICENSE.md view
@@ -1,4 +1,4 @@-Copyright © 2015–2016 Mark Karpov+Copyright © 2015–2017 Mark Karpov  All rights reserved. 
README.md view
@@ -8,6 +8,7 @@ [![Coverage Status](https://coveralls.io/repos/mrkkrp/htaglib/badge.svg?branch=master&service=github)](https://coveralls.io/github/mrkkrp/htaglib?branch=master)  * [Alternatives](#alternatives)+* [A note for FLAC users](#a-note-for-flac-users) * [Quick start](#quick-start)     * [Reading meta data](#reading-meta-data)     * [Writing meta data](#writing-meta-data)@@ -45,6 +46,15 @@ abstractions, not really type-safe. I personally don't want to use them, so I wrote this. +## A note for FLAC users++If you want to work with FLAC, there is+a [complete Haskell binding](https://github.com/mrkkrp/flac) to `libFLAC` —+reference FLAC implementation. It allows to work with all FLAC metadata+(read and write) and also provides Haskell API to stream encoder and stream+decoder. Please prefer that package if you don't need to work with other+audio formats.+ ## Quick start  First, since this is bindings to C-interface of the library, you'll need to@@ -146,7 +156,8 @@ of seconds as an integer. This means that if you want to calculate total duration, you'll have slightly incorrect result. Proper solution is to extract duration as floating-point number, for that we recommend bindings to-`libsndfile` — [`hsndfile`](https://hackage.haskell.org/package/hsndfile).+`libsndfile` — [`hsndfile`](https://hackage.haskell.org/package/hsndfile)+(or the above-mentioned `flac` package for Haskell if you work with FLAC).  ### Writing meta data @@ -185,6 +196,6 @@  ## License -Copyright © 2015–2016 Mark Karpov+Copyright © 2015–2017 Mark Karpov  Distributed under BSD 3 clause license.
Sound/HTagLib.hs view
@@ -1,6 +1,6 @@ -- | -- Module      :  Sound.HTagLib--- Copyright   :  © 2015–2016 Mark Karpov+-- Copyright   :  © 2015–2017 Mark Karpov -- License     :  BSD 3 clause -- -- Maintainer  :  Mark Karpov <markkarpov@opmbx.org>@@ -11,8 +11,32 @@ -- module you should import to use in your projects.  module Sound.HTagLib-  ( -- * Data types-    Title+  ( -- * Getters+    getTags+  , getTags'+  , titleGetter+  , artistGetter+  , albumGetter+  , commentGetter+  , genreGetter+  , yearGetter+  , trackNumberGetter+  , durationGetter+  , bitRateGetter+  , sampleRateGetter+  , channelsGetter+    -- * Setters+  , setTags+  , setTags'+  , titleSetter+  , artistSetter+  , albumSetter+  , commentSetter+  , genreSetter+  , yearSetter+  , trackNumberSetter+    -- * Data types+  , Title   , mkTitle   , unTitle   , Artist@@ -47,33 +71,9 @@   , unChannels   , FileType (..)   , ID3v2Encoding (..)-  , HTagLibException (..)-    -- * Getters   , TagGetter-  , getTags-  , getTags'-  , titleGetter-  , artistGetter-  , albumGetter-  , commentGetter-  , genreGetter-  , yearGetter-  , trackNumberGetter-  , durationGetter-  , bitRateGetter-  , sampleRateGetter-  , channelsGetter-    -- * Setters   , TagSetter-  , setTags-  , setTags'-  , titleSetter-  , artistSetter-  , albumSetter-  , commentSetter-  , genreSetter-  , yearSetter-  , trackNumberSetter )+  , HTagLibException (..) ) where  import Sound.HTagLib.Getter
Sound/HTagLib/Getter.hs view
@@ -1,6 +1,6 @@ -- | -- Module      :  Sound.HTagLib.Getter--- Copyright   :  © 2015–2016 Mark Karpov+-- Copyright   :  © 2015–2017 Mark Karpov -- License     :  BSD 3 clause -- -- Maintainer  :  Mark Karpov <markkarpov@opmbx.org>@@ -32,6 +32,7 @@   , channelsGetter ) where +import Control.Monad.IO.Class import Sound.HTagLib.Type import qualified Sound.HTagLib.Internal as I @@ -60,31 +61,31 @@ -- -- In case of trouble 'I.HTagLibException' will be thrown. -getTags-  :: FilePath          -- ^ Path to audio file+getTags :: MonadIO m+  => FilePath          -- ^ Path to audio file   -> TagGetter a       -- ^ Getter-  -> IO a              -- ^ Extracted data+  -> m a              -- ^ Extracted data getTags path = execGetter path Nothing  -- | This is essentially the same as 'getTags', but allows to explicitly--- choose file type (see 'I.FileType').+-- choose file type (see 'FileType'). -getTags'-  :: FilePath          -- ^ Path to audio file+getTags' :: MonadIO m+  => FilePath          -- ^ Path to audio file   -> FileType          -- ^ Type of audio file   -> TagGetter a       -- ^ Getter-  -> IO a              -- ^ Extracted data+  -> m a               -- ^ Extracted data getTags' path t = execGetter path (Just t)  -- | This is the most general way to read meta data from file. 'getTags' and -- 'getTags'' are just wrappers around the function. -execGetter-  :: FilePath         -- ^ Path to audio file+execGetter :: MonadIO m+  => FilePath         -- ^ Path to audio file   -> Maybe FileType   -- ^ Type of audio file (if known)   -> TagGetter a      -- ^ Getter-  -> IO a             -- ^ Extracted data-execGetter path t = I.withFile path t . runGetter+  -> m a              -- ^ Extracted data+execGetter path t = liftIO . I.withFile path t . runGetter  -- | Getter to retrieve track title. 
Sound/HTagLib/Internal.hs view
@@ -1,6 +1,6 @@ -- | -- Module      :  Sound.HTagLib.Internal--- Copyright   :  © 2015–2016 Mark Karpov+-- Copyright   :  © 2015–2017 Mark Karpov -- License     :  BSD 3 clause -- -- Maintainer  :  Mark Karpov <markkarpov@opmbx.org>
Sound/HTagLib/Setter.hs view
@@ -1,6 +1,6 @@ -- | -- Module      :  Sound.HTagLib.Setter--- Copyright   :  © 2015–2016 Mark Karpov+-- Copyright   :  © 2015–2017 Mark Karpov -- License     :  BSD 3 clause -- -- Maintainer  :  Mark Karpov <markkarpov@opmbx.org>@@ -29,6 +29,7 @@ where  import Control.Applicative ((<|>))+import Control.Monad.IO.Class import Data.Foldable (forM_) import Sound.HTagLib.Type import qualified Sound.HTagLib.Internal as I@@ -77,34 +78,34 @@ -- -- In case of trouble 'I.HTagLibException' will be thrown. -setTags-  :: FilePath          -- ^ Path to audio file+setTags :: MonadIO m+  => FilePath          -- ^ Path to audio file   -> Maybe ID3v2Encoding -- ^ Encoding for ID3v2 frames   -> TagSetter         -- ^ Setter-  -> IO ()+  -> m () setTags path enc = execSetter path enc Nothing  -- | Similar to 'setTags', but you can also specify type of audio file -- explicitly (otherwise it's guessed from file extension). -setTags'-  :: FilePath          -- ^ Path to audio file+setTags' :: MonadIO m+  => FilePath          -- ^ Path to audio file   -> Maybe ID3v2Encoding -- ^ Encoding for ID3v2 frames   -> FileType          -- ^ Type of audio file   -> TagSetter         -- ^ Setter-  -> IO ()+  -> m () setTags' path enc t = execSetter path enc (Just t)  -- | The most general way to set meta data. 'setTags' and 'setTags'' are -- just wrappers around this function. -execSetter-  :: FilePath          -- ^ Path to audio file+execSetter :: MonadIO m+  => FilePath          -- ^ Path to audio file   -> Maybe ID3v2Encoding -- ^ Encoding for ID3v2 frames   -> Maybe FileType    -- ^ Type of audio file (if known)   -> TagSetter         -- ^ Setter-  -> IO ()-execSetter path enc t TagSetter {..} = I.withFile path t $ \fid -> do+  -> m ()+execSetter path enc t TagSetter {..} = liftIO . I.withFile path t $ \fid -> do   forM_ enc I.id3v2SetEncoding   let writeTag x f = forM_ x (`f` fid)   writeTag sdTitle       I.setTitle
Sound/HTagLib/Type.hs view
@@ -1,6 +1,6 @@ -- | -- Module      :  Sound.HTagLib.Type--- Copyright   :  © 2015–2016 Mark Karpov+-- Copyright   :  © 2015–2017 Mark Karpov -- License     :  BSD 3 clause -- -- Maintainer  :  Mark Karpov <markkarpov@opmbx.org>
htaglib.cabal view
@@ -1,7 +1,7 @@ -- -- Cabal config for HTagLib. ----- Copyright © 2015–2016 Mark Karpov+-- Copyright © 2015–2017 Mark Karpov -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are@@ -31,7 +31,7 @@ -- POSSIBILITY OF SUCH DAMAGE.  name:                htaglib-version:             1.0.4+version:             1.1.0 cabal-version:       >= 1.10 license:             BSD3 license-file:        LICENSE.md@@ -55,9 +55,10 @@   default:           False  library-  build-depends:     base       >= 4.7 && < 5.0-                   , bytestring >= 0.9 && < 0.11-                   , text       >= 1.0 && < 1.3+  build-depends:     base         >= 4.7 && < 5.0+                   , bytestring   >= 0.9 && < 0.11+                   , text         >= 1.0 && < 1.3+                   , transformers >= 0.4 && < 0.6   extra-libraries:   tag_c   exposed-modules:   Sound.HTagLib                    , Sound.HTagLib.Type@@ -82,10 +83,10 @@                    , Sound.HTagLib.SetterSpec                    , Sound.HTagLib.Test.Util   build-depends:     base       >= 4.7 && < 5.0-                   , directory  >= 1.2 && < 1.3+                   , directory  >= 1.2 && < 1.4                    , filepath   >= 1.4 && < 2.0                    , hspec      >= 2.0 && < 3.0-                   , htaglib    >= 1.0.4+                   , htaglib    >= 1.1.0   default-extensions:                      CPP   default-language:  Haskell2010
tests/Sound/HTagLib/GetterSpec.hs view
@@ -1,7 +1,7 @@ -- -- HTagLib tests, testing of getters. ----- Copyright © 2015–2016 Mark Karpov+-- Copyright © 2015–2017 Mark Karpov -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are
tests/Sound/HTagLib/SetterSpec.hs view
@@ -1,7 +1,7 @@ -- -- HTagLib tests, testing of Setters. ----- Copyright © 2015–2016 Mark Karpov+-- Copyright © 2015–2017 Mark Karpov -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are
tests/Sound/HTagLib/Test/Util.hs view
@@ -1,7 +1,7 @@ -- -- HTagLib tests, utility definitions. ----- Copyright © 2015–2016 Mark Karpov+-- Copyright © 2015–2017 Mark Karpov -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are