From 2eaf3fe7a2c5dadbf5db4e9863f88698f134c3da Mon Sep 17 00:00:00 2001 From: Pascal Schmid Date: Wed, 29 May 2024 22:13:21 +0200 Subject: [PATCH] Check for exiftool dependency --- lib/find_old_mp3s.ex | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/find_old_mp3s.ex b/lib/find_old_mp3s.ex index 6d330bd..1c53eaa 100644 --- a/lib/find_old_mp3s.ex +++ b/lib/find_old_mp3s.ex @@ -4,6 +4,8 @@ defmodule FindOldMp3s.Application do """ def start(_, _) do + check_exif_tools() + get_options() |> validate_options() |> execute() @@ -11,6 +13,13 @@ defmodule FindOldMp3s.Application do System.halt(0) end + defp check_exif_tools() do + case System.find_executable("exiftool") do + nil -> show_exiftool_error() + _ -> true + end + end + defp get_options() do Burrito.Util.Args.get_arguments() |> OptionParser.parse( @@ -72,6 +81,15 @@ defmodule FindOldMp3s.Application do Enum.each(files, fn file -> IO.puts(file) end) end + defp show_exiftool_error() do + IO.puts( + :stderr, + "This command needs to have tool 'exiftool' installed! Please consult your OS manual in order to install it." + ) + + System.halt(2) + end + defp print_help() do IO.puts(""" This command will find audio files with low bitrates in a folder folder (recursively) and shows the bitrate and