Print out file bitrates as table

This commit is contained in:
2024-05-30 00:01:31 +02:00
parent 6787decec6
commit e39f6e9d66

View File

@@ -3,7 +3,7 @@ defmodule FindOldMp3s.Application do
Main module to run when invoking the binary Main module to run when invoking the binary
""" """
@dialyzer {:no_return, show_exiftool_error: 0, start: 2 } @dialyzer {:no_return, show_exiftool_error: 0, start: 2}
def start(_, _) do def start(_, _) do
check_exif_tools() check_exif_tools()
@@ -80,7 +80,10 @@ defmodule FindOldMp3s.Application do
System.halt(0) System.halt(0)
end end
Enum.each(files, fn file -> IO.puts(file) end) IO.puts("Running exiftool...\n")
Stream.map(files, fn file -> {get_bitrate(file), file} end)
|> Enum.each(fn {bitrate, path} -> IO.puts("#{bitrate}\t|\t#{path}") end)
end end
defp show_exiftool_error() do defp show_exiftool_error() do
@@ -112,4 +115,13 @@ defmodule FindOldMp3s.Application do
""") """)
end end
defp get_bitrate(file) do
System.cmd("exiftool", ["-AudioBitrate", file])
|> elem(0)
|> String.split(":")
|> Enum.at(1, "---")
|> String.trim()
|> String.pad_trailing(8)
end
end end