Added a command for updating yt-dlp
This commit is contained in:
parent
62214b80a6
commit
330f7404c3
3 changed files with 27 additions and 0 deletions
|
|
@ -76,6 +76,24 @@ defmodule Pinchflat.YtDlp.CommandRunner do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Updates yt-dlp to the latest version
|
||||||
|
|
||||||
|
Returns {:ok, binary()} | {:error, binary()}
|
||||||
|
"""
|
||||||
|
@impl YtDlpCommandRunner
|
||||||
|
def update do
|
||||||
|
command = backend_executable()
|
||||||
|
|
||||||
|
case CliUtils.wrap_cmd(command, ["--update"]) do
|
||||||
|
{output, 0} ->
|
||||||
|
{:ok, String.trim(output)}
|
||||||
|
|
||||||
|
{output, _} ->
|
||||||
|
{:error, output}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp generate_output_filepath(addl_opts) do
|
defp generate_output_filepath(addl_opts) do
|
||||||
case Keyword.get(addl_opts, :output_filepath) do
|
case Keyword.get(addl_opts, :output_filepath) do
|
||||||
nil -> FSUtils.generate_metadata_tmpfile(:json)
|
nil -> FSUtils.generate_metadata_tmpfile(:json)
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,5 @@ defmodule Pinchflat.YtDlp.YtDlpCommandRunner do
|
||||||
@callback run(binary(), atom(), keyword(), binary()) :: {:ok, binary()} | {:error, binary(), integer()}
|
@callback run(binary(), atom(), keyword(), binary()) :: {:ok, binary()} | {:error, binary(), integer()}
|
||||||
@callback run(binary(), atom(), keyword(), binary(), keyword()) :: {:ok, binary()} | {:error, binary(), integer()}
|
@callback run(binary(), atom(), keyword(), binary(), keyword()) :: {:ok, binary()} | {:error, binary(), integer()}
|
||||||
@callback version() :: {:ok, binary()} | {:error, binary()}
|
@callback version() :: {:ok, binary()} | {:error, binary()}
|
||||||
|
@callback update() :: {:ok, binary()} | {:error, binary()}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,14 @@ defmodule Pinchflat.YtDlp.CommandRunnerTest do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "update/0" do
|
||||||
|
test "adds the update arg" do
|
||||||
|
assert {:ok, output} = Runner.update()
|
||||||
|
|
||||||
|
assert String.contains?(output, "--update")
|
||||||
|
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.()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue