flaccuraterip 0.2.1 → 0.3.0
raw patch · 6 files changed
+98/−73 lines, 6 filesdep +optparse-applicativedep −cmdargsdep ~process
Dependencies added: optparse-applicative
Dependencies removed: cmdargs
Dependency ranges changed: process
Files
- CD/AccurateRip.hs +3/−3
- CD/CDDB.hs +1/−2
- CHANGELOG.md +21/−2
- Main.hs +51/−48
- README.md +6/−4
- flaccuraterip.cabal +16/−14
CD/AccurateRip.hs view
@@ -2,14 +2,14 @@ module CD.AccurateRip where -import CD.CDDB-import Control.Monad (liftM) import Data.Binary import Data.Binary.Get import Data.Binary.Put import Data.Bits import Data.List (find) +import CD.CDDB+ type Sample = Word32 type CRC = DiscID@@ -74,7 +74,7 @@ instance Binary ArData where put (ArData ents) = mapM_ put ents- get = liftM ArData getList+ get = fmap ArData getList where getList = do b <- isEmpty if b then return []
CD/CDDB.hs view
@@ -3,7 +3,6 @@ module CD.CDDB where import Control.DeepSeq-import Control.Monad (liftM) import Data.Binary import Data.Binary.Get import Data.Binary.Put@@ -15,7 +14,7 @@ instance Binary DiscID where put (DiscID w) = putWord32le w- get = liftM DiscID getWord32le+ get = fmap DiscID getWord32le instance Show DiscID where show (DiscID w) =
CHANGELOG.md view
@@ -1,4 +1,23 @@-Version 0.2.1--------------+Version 0.3.0 (2014-04-27)+-------------------------- +- Replace `cmdargs` with `optparse-applicative` for parsing command line.+- Improve description and help message.++Version 0.2.1 (2014-03-21)+--------------------------+ - Clean up code.++Version 0.2 (2012-11-08)+------------------------++- New option "--show-database-entry" to show the AccurateRip database entry of+ the rip.+- Improve description.+- Minor code changes.++Version 0.1 (2012-11-03)+------------------------++- Initial release.
Main.hs view
@@ -1,7 +1,3 @@-{-# LANGUAGE DeriveDataTypeable #-}--import CD.AccurateRip-import CD.CDDB import Control.DeepSeq import Control.Monad import Data.Binary@@ -9,21 +5,20 @@ import Data.String import Data.Version import Network.HTTP-import System.Console.CmdArgs+import Options.Applicative import System.Environment import System.Exit import System.IO import System.Process +import CD.AccurateRip+import CD.CDDB progName :: String progName = "flAccurateRip" -exeName :: String-exeName = "flaccuraterip"- version :: Version-version = Version [0,2,1] []+version = Version [0,3,0] [] intro :: String intro = progName ++ " " ++ showVersion version ++@@ -34,36 +29,47 @@ \This is free software: you are free to change and redistribute it.\n\ \There is NO WARRANTY, to the extent permitted by law." +bugReport :: String+bugReport = "Report bugs to: <https://github.com/tensor5/flAccurateRip/issues>"+ data Options = Options- { optOffset :: Int- , opt30Samples :: Bool+ { opt30Samples :: Bool+ , optOffset :: Int , optShowEntry :: Bool+ , optVerbose :: Bool , optFiles :: [String]- } deriving (Data, Typeable)+ } -options :: Options-options = Options { optOffset = def- &= explicit- &= opt "O"- &= name "sample-offset"- &= help "Set ripping offset to N"- &= typ "N"- , opt30Samples = False- &= explicit- &= name "with-30-samples-correction"- &= help "Add 30 samples to the offset (use if the CD was \- \ripped using the correct offset, which is 30 \- \samples less than that in \- \http://www.accuraterip.com/driveoffsets.htm)"- , optShowEntry = False- &= explicit- &= name "show-database-entry"- &= help "Show the AccurateRip database entry for this rip"- , optFiles = def- &= args- &= typ "FLAC FILES"- }+options :: Parser Options+options = Options+ <$> switch (short 'c'+ <> long "with-30-samples-correction"+ <> help "Add 30 samples to the offset (use if the CD was \+ \ripped using the correct offset, which is 30 \+ \samples less than that in \+ \<http://www.accuraterip.com/driveoffsets.htm>)"+ )+ <*> option (short 'o'+ <> long "with-sample-offset"+ <> metavar "N"+ <> value 0+ <> help "Set ripping offset to N"+ )+ <*> switch (short 's'+ <> long "show-database-entry"+ <> help "Show the AccurateRip database entry for this rip"+ )+ <*> switch (short 'v'+ <> long "verbose"+ <> help "Be verbose"+ )+ <*> some (argument str $+ metavar "track01.flac track02.flac ... trackNN.flac"+ ) +versionOption :: Parser (a -> a)+versionOption = infoOption intro (long "version"+ <> help "Show version information and exit") lengthsToOffsets :: Num a => [a] -> [a] lengthsToOffsets = scanl1 (+)@@ -131,7 +137,8 @@ CreatePipe Inherit True- True)+ True+ False) return b showAccuracy :: ArData -> RipHash -> IO ()@@ -149,21 +156,17 @@ show c2 ++ " (" ++ show s2 ++ ")") sR (i+1) cs ss -noInput :: [String] -> IO ()-noInput [] = do- prog <- getProgName- putStrLn (prog ++ ": no input files")- exitFailure-noInput _ = return ()- main :: IO () main = do- opts <- cmdArgs (options &= program exeName &= summary intro &= verbosity)+ opts <- execParser $ info (helper <*> versionOption <*> options)+ (fullDesc+ <> progDesc "Verify the given FLAC files"+ <> footer bugReport) let flaclist = optFiles opts- noInput flaclist+ verbose = optVerbose opts list <- getOffsetsFromFlacs flaclist putStr "Connecting to AccurateRip database"- whenLoud $ putStr (" (" ++ arUrl list ++ ")")+ when verbose $ putStr (" (<" ++ arUrl list ++ ">)") putStr "..." hFlush stdout res <- simpleHTTP (getRequest $ arUrl list)@@ -184,14 +187,14 @@ putStrLn $ showArData ardata let offset = optOffset opts + 30 * fromEnum (opt30Samples opts) putStr "Computing track checksums from input files"- whenLoud $ putStr (" (using " ++ show offset ++ " samples offset)")+ when verbose $ putStr (" (using " ++ show offset ++ " samples offset)") putStrLn "..." a <- pipeFlacs flaclist hSetBinaryMode a True- str <- hGetContents a+ fl <- hGetContents a let cs = listPairCrcs offset (map (\n -> samplesPerSector * n) (offsetsToLengths list))- (stringToWord32List str)+ (stringToWord32List fl) (showAccuracy ardata . RipHash (discId1 list) (discId2 list) (cddbDiscId list)) $!! cs
README.md view
@@ -2,7 +2,7 @@ ------------ *flAccurateRip* is a command line tool to verify the accuracy of FLAC files-ripped form CD, using the information contained in the AccurateRip™ database+ripped from CD, using the information contained in the AccurateRip™ database about other rips of the same CD. Usage@@ -17,6 +17,8 @@ If a pressing of this CD is present in the AccurateRip™ database, `flaccuraterip` will output the ripping accuracy for each track. If the CD was ripped without setting the drive offset, you should use the flag-`--sample-offset=N`, where N is the offset indicated-[here](http://accuraterip.com/driveoffsets.htm-"http://accuraterip.com/driveoffsets.htm") for your drive.+`--with-sample-offset=N`, where N is the offset indicated [here][offsets] for+your drive.++ [offsets]: http://accuraterip.com/driveoffsets.htm+ "http://accuraterip.com/driveoffsets.htm"
flaccuraterip.cabal view
@@ -1,6 +1,6 @@ Name: flaccuraterip-Version: 0.2.1-Cabal-Version: >= 1.8+Version: 0.3.0+Cabal-Version: >= 1.10 Build-Type: Simple License: GPL-3 License-File: LICENSE@@ -8,11 +8,12 @@ Author: Nicola Squartini Maintainer: Nicola Squartini <tensor5@gmail.com> Homepage: http://noaxiom.org/flAccurateRip+Bug-Reports: https://github.com/tensor5/flAccurateRip/issues Synopsis: Verify FLAC files ripped form CD using AccurateRip™ Description: /flAccurateRip/ is a command line tool to verify the accuracy of FLAC files- ripped form CD, using the information contained in the AccurateRip™ database+ ripped from CD, using the information contained in the AccurateRip™ database about other rips of the same CD. . Usage: suppose you ripped a CD into @track01.flac@, @track02.flac@, ...,@@ -24,7 +25,7 @@ If a pressing of this CD is present in the AccurateRip™ database, @flaccuraterip@ will output the ripping accuracy for each track. If the CD was ripped without setting the drive offset, you should use the flag- @--sample-offset=N@, where N is the offset indicated in+ @--with-sample-offset=N@, where N is the offset indicated in <http://accuraterip.com/driveoffsets.htm> for your drive. Category: Sound@@ -39,15 +40,16 @@ Source-Repository this Type: git Location: git://github.com/tensor5/flAccurateRip.git- Tag: v0.2.1+ Tag: v0.3.0 Executable flaccuraterip- Build-Depends: base == 4.*,- binary >= 0.5 && < 0.8,- cmdargs == 0.10.*,- deepseq == 1.3.*,- HTTP == 4000.2.*,- process >= 1.1 && < 1.3- GHC-Options: -Wall- Main-Is: Main.hs- Other-Modules: CD.CDDB, CD.AccurateRip+ Default-Language: Haskell2010+ Build-Depends: base == 4.*,+ binary >= 0.5 && < 0.8,+ deepseq == 1.3.*,+ HTTP == 4000.2.*,+ optparse-applicative == 0.8.*,+ process == 1.2.*+ GHC-Options: -Wall+ Main-Is: Main.hs+ Other-Modules: CD.CDDB, CD.AccurateRip