Skip to content

Commit 559f449

Browse files
committed
Export mp3 with .mp3 ending (untested)
1 parent b2fb07f commit 559f449

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tttool.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,11 @@ fileMagics :: [(B.ByteString, String)]
541541
fileMagics =
542542
[ (BC.pack "RIFF", "wav")
543543
, (BC.pack "OggS", "ogg")
544-
, (BC.pack "fLaC", "flac")]
544+
, (BC.pack "fLaC", "flac")
545+
, (BC.pack "ID3", "mp3")]
545546

546547
decodeOnlyFiles :: [String]
547-
decodeOnlyFiles = ["mp3"]
548+
decodeOnlyFiles = []
548549

549550
decypher :: Word8 -> B.ByteString -> B.ByteString
550551
decypher x = B.map go
@@ -863,7 +864,7 @@ dumpAudioTo directory file = do
863864

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

0 commit comments

Comments
 (0)