Added yt-dlp version to sidebar (#155)
This commit is contained in:
@@ -14,6 +14,7 @@ defmodule Pinchflat.Boot.PreJobStartupTasks do
|
|||||||
|
|
||||||
alias Pinchflat.Repo
|
alias Pinchflat.Repo
|
||||||
alias Pinchflat.Settings
|
alias Pinchflat.Settings
|
||||||
|
alias Pinchflat.YtDlp.CommandRunner
|
||||||
alias Pinchflat.Filesystem.FilesystemHelpers
|
alias Pinchflat.Filesystem.FilesystemHelpers
|
||||||
|
|
||||||
def start_link(opts \\ []) do
|
def start_link(opts \\ []) do
|
||||||
@@ -62,7 +63,10 @@ defmodule Pinchflat.Boot.PreJobStartupTasks do
|
|||||||
end
|
end
|
||||||
|
|
||||||
defp apply_default_settings do
|
defp apply_default_settings do
|
||||||
|
{:ok, yt_dlp_version} = CommandRunner.version()
|
||||||
|
|
||||||
Settings.fetch!(:onboarding, true)
|
Settings.fetch!(:onboarding, true)
|
||||||
Settings.fetch!(:pro_enabled, false)
|
Settings.fetch!(:pro_enabled, false)
|
||||||
|
Settings.set!(:yt_dlp_version, yt_dlp_version)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,4 +8,5 @@ defmodule Pinchflat.YtDlp.BackendCommandRunner do
|
|||||||
|
|
||||||
@callback run(binary(), keyword(), binary()) :: {:ok, binary()} | {:error, binary(), integer()}
|
@callback run(binary(), keyword(), binary()) :: {:ok, binary()} | {:error, binary(), integer()}
|
||||||
@callback run(binary(), keyword(), binary(), keyword()) :: {:ok, binary()} | {:error, binary(), integer()}
|
@callback run(binary(), keyword(), binary(), keyword()) :: {:ok, binary()} | {:error, binary(), integer()}
|
||||||
|
@callback version() :: {:ok, binary()} | {:error, binary()}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -48,6 +48,19 @@ defmodule Pinchflat.YtDlp.CommandRunner do
|
|||||||
end
|
end
|
||||||
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
|
defp build_cookie_options do
|
||||||
base_dir = Application.get_env(:pinchflat, :extras_directory)
|
base_dir = Application.get_env(:pinchflat, :extras_directory)
|
||||||
cookie_file = Path.join(base_dir, "cookies.txt")
|
cookie_file = Path.join(base_dir, "cookies.txt")
|
||||||
|
|||||||
@@ -58,8 +58,11 @@
|
|||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<span class="group relative flex items-center gap-2.5 px-4 py-2 text-sm">
|
<span class="group relative flex items-center gap-2.5 px-4 pt-2 text-sm">
|
||||||
v<%= Application.spec(:pinchflat)[:vsn] %>
|
Pinchflat v<%= Application.spec(:pinchflat)[:vsn] %>
|
||||||
|
</span>
|
||||||
|
<span class="group relative flex items-center gap-2.5 px-4 text-sm">
|
||||||
|
yt-dlp <%= Settings.get!(:yt_dlp_version) %>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -102,6 +102,14 @@ defmodule Pinchflat.YtDlp.CommandRunnerTest do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "version/0" do
|
||||||
|
test "adds the version arg" do
|
||||||
|
assert {:ok, output} = Runner.version()
|
||||||
|
|
||||||
|
assert String.contains?(output, "--version")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp wrap_executable(new_executable, fun) do
|
defp wrap_executable(new_executable, fun) do
|
||||||
Application.put_env(:pinchflat, :yt_dlp_executable, new_executable)
|
Application.put_env(:pinchflat, :yt_dlp_executable, new_executable)
|
||||||
fun.()
|
fun.()
|
||||||
|
|||||||
@@ -12,5 +12,9 @@ for ((i = 1; i <= $#; i++)); do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Write all args to the file
|
if [ "${!i}" == "--print-to-file" ]; then
|
||||||
echo "$@" >"$file_location"
|
# Write all args to the file
|
||||||
|
echo "$@" >"$file_location"
|
||||||
|
else
|
||||||
|
echo "$@"
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user