packages feed

htaglib 1.0.0 → 1.0.1

raw patch · 13 files changed

+72/−31 lines, 13 filesdep ~htaglib

Dependency ranges changed: htaglib

Files

CHANGELOG.md view
@@ -1,3 +1,10 @@+## HTagLib 1.0.1++* Rewritten setters (without changing the API), so at most one writing+  operation is performed for every settable value. When combining setters+  that happen to set the same tags to different values, value on the left+  side of `mappend` wins.+ ## HTagLib 1.0.0  * Make the module `Sound.HTagLib.Internal` hidden for end users.
LICENSE.md view
@@ -1,4 +1,4 @@-Copyright © 2015 Mark Karpov+Copyright © 2015–2016 Mark Karpov  All rights reserved. 
README.md view
@@ -184,6 +184,6 @@  ## License -Copyright © 2015 Mark Karpov+Copyright © 2015–2016 Mark Karpov  Distributed under BSD 3 clause license.
Sound/HTagLib.hs view
@@ -1,6 +1,6 @@ -- | -- Module      :  Sound.HTagLib--- Copyright   :  © 2015 Mark Karpov+-- Copyright   :  © 2015–2016 Mark Karpov -- License     :  BSD 3 clause -- -- Maintainer  :  Mark Karpov <markkarpov@opmbx.org>
Sound/HTagLib/Getter.hs view
@@ -1,6 +1,6 @@ -- | -- Module      :  Sound.HTagLib.Getter--- Copyright   :  © 2015 Mark Karpov+-- Copyright   :  © 2015–2016 Mark Karpov -- License     :  BSD 3 clause -- -- Maintainer  :  Mark Karpov <markkarpov@opmbx.org>
Sound/HTagLib/Internal.hs view
@@ -1,6 +1,6 @@ -- | -- Module      :  Sound.HTagLib.Internal--- Copyright   :  © 2015 Mark Karpov+-- Copyright   :  © 2015–2016 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 Mark Karpov+-- Copyright   :  © 2015–2016 Mark Karpov -- License     :  BSD 3 clause -- -- Maintainer  :  Mark Karpov <markkarpov@opmbx.org>@@ -10,7 +10,8 @@ -- High-level interface for writing audio meta data. You don't need to -- import this module directly, import "Sound.HTagLib" instead. -{-# LANGUAGE CPP #-}+{-# LANGUAGE CPP             #-}+{-# LANGUAGE RecordWildCards #-}  module Sound.HTagLib.Setter   ( -- * High-level API@@ -27,6 +28,7 @@   , trackNumberSetter ) where +import Control.Applicative ((<|>)) import Data.Foldable (forM_) import Sound.HTagLib.Type import qualified Sound.HTagLib.Internal as I@@ -37,14 +39,39 @@  -- | Composable entity that can be used together with 'setTags' or -- 'setTags'' to write meta data to audio file.+--+-- Note that in case of (for example):+--+-- > titleSetter "foo" <> titleSetter "bar"+--+-- The first value wins. -newtype TagSetter = TagSetter { runSetter :: I.FileId -> IO () }+data TagSetter = TagSetter+  { sdTitle       :: Maybe Title+  , sdArtist      :: Maybe Artist+  , sdAlbum       :: Maybe Album+  , sdComment     :: Maybe Comment+  , sdGenre       :: Maybe Genre+  , sdYear        :: Maybe (Maybe Year)+  , sdTrackNumber :: Maybe (Maybe TrackNumber) }  instance Monoid TagSetter where-  mempty  = TagSetter $ const (return ())-  x `mappend` y = TagSetter $ \fid ->-    do runSetter x fid-       runSetter y fid+  mempty = TagSetter+    { sdTitle       = Nothing+    , sdArtist      = Nothing+    , sdAlbum       = Nothing+    , sdComment     = Nothing+    , sdGenre       = Nothing+    , sdYear        = Nothing+    , sdTrackNumber = Nothing }+  mappend x y = let f g = g x <|> g y in TagSetter+    { sdTitle       = f sdTitle+    , sdArtist      = f sdArtist+    , sdAlbum       = f sdAlbum+    , sdComment     = f sdComment+    , sdGenre       = f sdGenre+    , sdYear        = f sdYear+    , sdTrackNumber = f sdTrackNumber }  -- | Set tags in specified file using given setter. --@@ -77,42 +104,49 @@   -> Maybe FileType    -- ^ Type of audio file (if known)   -> TagSetter         -- ^ Setter   -> IO ()-execSetter path enc t s = I.withFile path t $ \fid -> do+execSetter path enc t TagSetter {..} = I.withFile path t $ \fid -> do   forM_ enc I.id3v2SetEncoding-  runSetter s fid+  let writeTag x f = forM_ x (`f` fid)+  writeTag sdTitle       I.setTitle+  writeTag sdArtist      I.setArtist+  writeTag sdAlbum       I.setAlbum+  writeTag sdComment     I.setComment+  writeTag sdGenre       I.setGenre+  writeTag sdYear        I.setYear+  writeTag sdTrackNumber I.setTrackNumber   I.saveFile path fid  -- | Setter for track title.  titleSetter :: Title -> TagSetter-titleSetter = TagSetter . I.setTitle+titleSetter x = mempty { sdTitle = Just x }  -- | Setter for track artist.  artistSetter :: Artist -> TagSetter-artistSetter = TagSetter . I.setArtist+artistSetter x = mempty { sdArtist = Just x }  -- | Setter for track album.  albumSetter :: Album -> TagSetter-albumSetter = TagSetter . I.setAlbum+albumSetter x = mempty { sdAlbum = Just x }  -- | Setter for track comment.  commentSetter :: Comment -> TagSetter-commentSetter = TagSetter . I.setComment+commentSetter x = mempty { sdComment = Just x }  -- | Setter for track genre.  genreSetter :: Genre -> TagSetter-genreSetter = TagSetter . I.setGenre+genreSetter x = mempty { sdGenre = Just x }  -- | Setter for year tag, use 'Nothing' to clear the field.  yearSetter :: Maybe Year -> TagSetter-yearSetter = TagSetter . I.setYear+yearSetter x = mempty { sdYear = Just x }  -- | Setter for track number, use 'Nothing' to clear the field.  trackNumberSetter :: Maybe TrackNumber -> TagSetter-trackNumberSetter = TagSetter . I.setTrackNumber+trackNumberSetter x = mempty { sdTrackNumber = Just x }
Sound/HTagLib/Type.hs view
@@ -1,6 +1,6 @@ -- | -- Module      :  Sound.HTagLib.Type--- Copyright   :  © 2015 Mark Karpov+-- Copyright   :  © 2015–2016 Mark Karpov -- License     :  BSD 3 clause -- -- Maintainer  :  Mark Karpov <markkarpov@opmbx.org>
htaglib.cabal view
@@ -2,7 +2,7 @@ -- -- Cabal config for HTagLib. ----- Copyright © 2015 Mark Karpov+-- Copyright © 2015–2016 Mark Karpov -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are@@ -32,7 +32,7 @@ -- POSSIBILITY OF SUCH DAMAGE.  name:                htaglib-version:             1.0.0+version:             1.0.1 cabal-version:       >= 1.10 license:             BSD3 license-file:        LICENSE.md@@ -51,7 +51,7 @@                    , audio-samples/sample.mp3  flag dev-  description:       Turn development settings.+  description:       Turn on development settings.   manual:            True   default:           False @@ -86,7 +86,7 @@                    , HUnit                >= 1.2 && < 1.4                    , directory            >= 1.2                    , filepath             >= 1.4 && < 2-                   , htaglib              >= 0.1.1+                   , htaglib              >= 1.0                    , test-framework       >= 0.6 && < 1                    , test-framework-hunit >= 0.2 && < 0.4   default-extensions:@@ -95,4 +95,4 @@  source-repository head   type:              git-  location:          https://github.com/mrkkrp/htaglib+  location:          https://github.com/mrkkrp/htaglib.git
tests/Getter.hs view
@@ -2,7 +2,7 @@ -- -- HTagLib tests, testing of getters. ----- Copyright © 2015 Mark Karpov+-- Copyright © 2015–2016 Mark Karpov -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are
tests/Main.hs view
@@ -2,7 +2,7 @@ -- -- HTagLib tests, main module. ----- Copyright © 2015 Mark Karpov+-- Copyright © 2015–2016 Mark Karpov -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are
tests/Setter.hs view
@@ -2,7 +2,7 @@ -- -- HTagLib tests, testing of Setters. ----- Copyright © 2015 Mark Karpov+-- Copyright © 2015–2016 Mark Karpov -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are
tests/Util.hs view
@@ -2,7 +2,7 @@ -- -- HTagLib tests, utility definitions. ----- Copyright © 2015 Mark Karpov+-- Copyright © 2015–2016 Mark Karpov -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are