diff --git a/lib/pinchflat/boot/pre_job_startup_tasks.ex b/lib/pinchflat/boot/pre_job_startup_tasks.ex index 0e28d94..bc52ee1 100644 --- a/lib/pinchflat/boot/pre_job_startup_tasks.ex +++ b/lib/pinchflat/boot/pre_job_startup_tasks.ex @@ -14,6 +14,7 @@ defmodule Pinchflat.Boot.PreJobStartupTasks do alias Pinchflat.Repo alias Pinchflat.Settings + alias Pinchflat.YtDlp.CommandRunner alias Pinchflat.Filesystem.FilesystemHelpers def start_link(opts \\ []) do @@ -62,7 +63,10 @@ defmodule Pinchflat.Boot.PreJobStartupTasks do end defp apply_default_settings do + {:ok, yt_dlp_version} = CommandRunner.version() + Settings.fetch!(:onboarding, true) Settings.fetch!(:pro_enabled, false) + Settings.set!(:yt_dlp_version, yt_dlp_version) end end diff --git a/lib/pinchflat/yt_dlp/backend_command_runner.ex b/lib/pinchflat/yt_dlp/backend_command_runner.ex index fef612c..e09eaeb 100644 --- a/lib/pinchflat/yt_dlp/backend_command_runner.ex +++ b/lib/pinchflat/yt_dlp/backend_command_runner.ex @@ -8,4 +8,5 @@ defmodule Pinchflat.YtDlp.BackendCommandRunner do @callback run(binary(), keyword(), binary()) :: {:ok, binary()} | {:error, binary(), integer()} @callback run(binary(), keyword(), binary(), keyword()) :: {:ok, binary()} | {:error, binary(), integer()} + @callback version() :: {:ok, binary()} | {:error, binary()} end diff --git a/lib/pinchflat/yt_dlp/command_runner.ex b/lib/pinchflat/yt_dlp/command_runner.ex index 9fa2136..7512768 100644 --- a/lib/pinchflat/yt_dlp/command_runner.ex +++ b/lib/pinchflat/yt_dlp/command_runner.ex @@ -48,6 +48,19 @@ defmodule Pinchflat.YtDlp.CommandRunner do end end + @impl BackendCommandRunner + def version do + command = backend_executable() + + case System.cmd(command, ["--version"]) do + {output, 0} -> + {:ok, String.trim(output)} + + {output, _} -> + {:error, output} + end + end + defp build_cookie_options do base_dir = Application.get_env(:pinchflat, :extras_directory) cookie_file = Path.join(base_dir, "cookies.txt") diff --git a/lib/pinchflat_web/components/layouts/partials/sidebar.html.heex b/lib/pinchflat_web/components/layouts/partials/sidebar.html.heex index fc34749..978c471 100644 --- a/lib/pinchflat_web/components/layouts/partials/sidebar.html.heex +++ b/lib/pinchflat_web/components/layouts/partials/sidebar.html.heex @@ -58,8 +58,11 @@