Skip to content

Commit

Permalink
Export mp3 with .mp3 ending (untested)
Browse files Browse the repository at this point in the history
  • Loading branch information
nomeata committed Mar 2, 2014
1 parent b2fb07f commit 559f449
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tttool.hs
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,11 @@ fileMagics :: [(B.ByteString, String)]
fileMagics =
[ (BC.pack "RIFF", "wav")
, (BC.pack "OggS", "ogg")
, (BC.pack "fLaC", "flac")]
, (BC.pack "fLaC", "flac")
, (BC.pack "ID3", "mp3")]

decodeOnlyFiles :: [String]
decodeOnlyFiles = ["mp3"]
decodeOnlyFiles = []

decypher :: Word8 -> B.ByteString -> B.ByteString
decypher x = B.map go
Expand Down Expand Up @@ -863,7 +864,7 @@ dumpAudioTo directory file = do

createDirectoryIfMissing False directory
forMn_ (ttAudioFiles tt) $ \n audio -> do
let audiotype = fromMaybe "raw" $ lookup (B.take 4 audio) fileMagics
let audiotype = maybe "raw" snd $ find (\(m,t) -> m `B.isPrefixOf` audio) fileMagics
let filename = printf "%s/%s_%d.%s" directory (takeBaseName file) n audiotype
if B.null audio
then do
Expand Down

0 comments on commit 559f449

Please sign in to comment.