Added yt-dlp version to sidebar (#155)
This commit is contained in:
parent
0eca0acbe8
commit
c58e176619
6 changed files with 37 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -58,8 +58,11 @@
|
|||
</span>
|
||||
</li>
|
||||
<li>
|
||||
<span class="group relative flex items-center gap-2.5 px-4 py-2 text-sm">
|
||||
v<%= Application.spec(:pinchflat)[:vsn] %>
|
||||
<span class="group relative flex items-center gap-2.5 px-4 pt-2 text-sm">
|
||||
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>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -102,6 +102,14 @@ defmodule Pinchflat.YtDlp.CommandRunnerTest do
|
|||
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
|
||||
Application.put_env(:pinchflat, :yt_dlp_executable, new_executable)
|
||||
fun.()
|
||||
|
|
|
|||
|
|
@ -12,5 +12,9 @@ for ((i = 1; i <= $#; i++)); do
|
|||
fi
|
||||
done
|
||||
|
||||
# Write all args to the file
|
||||
echo "$@" >"$file_location"
|
||||
if [ "${!i}" == "--print-to-file" ]; then
|
||||
# Write all args to the file
|
||||
echo "$@" >"$file_location"
|
||||
else
|
||||
echo "$@"
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in a new issue