Refactored windows_filenames to be a global flag; added tests
This commit is contained in:
parent
9fc42abe62
commit
36f576ca93
5 changed files with 16 additions and 7 deletions
|
|
@ -44,7 +44,6 @@ defmodule Pinchflat.Downloading.DownloadOptionBuilder do
|
|||
defp default_options do
|
||||
[
|
||||
:no_progress,
|
||||
:windows_filenames,
|
||||
# Add force-overwrites to make sure redownloading works
|
||||
:force_overwrites,
|
||||
# This makes the date metadata conform to what jellyfin expects
|
||||
|
|
|
|||
|
|
@ -30,10 +30,9 @@ defmodule Pinchflat.YtDlp.CommandRunner do
|
|||
|
||||
output_filepath = generate_output_filepath(addl_opts)
|
||||
print_to_file_opts = [{:print_to_file, output_template}, output_filepath]
|
||||
external_file_opts = build_external_file_options()
|
||||
user_configured_opts = cookie_file_options() ++ global_options()
|
||||
# These must stay in exactly this order, hence why I'm giving it its own variable.
|
||||
all_opts = command_opts ++ print_to_file_opts ++ external_file_opts
|
||||
|
||||
all_opts = command_opts ++ print_to_file_opts ++ user_configured_opts
|
||||
formatted_command_opts = [url] ++ CliUtils.parse_options(all_opts)
|
||||
Logger.info("[yt-dlp] called with: #{Enum.join(formatted_command_opts, " ")}")
|
||||
|
||||
|
|
@ -58,6 +57,7 @@ defmodule Pinchflat.YtDlp.CommandRunner do
|
|||
def version do
|
||||
command = backend_executable()
|
||||
|
||||
# TODO: fix to use CliUtils.wrap_cmd (and look at apprise too)
|
||||
case System.cmd(command, ["--version"]) do
|
||||
{output, 0} ->
|
||||
{:ok, String.trim(output)}
|
||||
|
|
@ -74,7 +74,11 @@ defmodule Pinchflat.YtDlp.CommandRunner do
|
|||
end
|
||||
end
|
||||
|
||||
defp build_external_file_options do
|
||||
defp global_options do
|
||||
[:windows_filenames]
|
||||
end
|
||||
|
||||
defp cookie_file_options do
|
||||
base_dir = Application.get_env(:pinchflat, :extras_directory)
|
||||
filename_options_map = %{cookies: "cookies.txt"}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ defmodule Pinchflat.YtDlp.MediaCollection do
|
|||
# the first video has not released yet (ie: is a premier). We don't care about
|
||||
# available formats since we're just getting the source details
|
||||
default_opts = [
|
||||
:windows_filenames,
|
||||
:simulate,
|
||||
:skip_download,
|
||||
:ignore_no_formats_error,
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ defmodule Pinchflat.Downloading.DownloadOptionBuilderTest do
|
|||
assert {:ok, res} = DownloadOptionBuilder.build(media_item)
|
||||
|
||||
assert :no_progress in res
|
||||
assert :windows_filenames in res
|
||||
assert :force_overwrites in res
|
||||
assert {:parse_metadata, "%(upload_date>%Y-%m-%d)s:(?P<meta_date>.+)"} in res
|
||||
end
|
||||
|
|
|
|||
|
|
@ -78,6 +78,14 @@ defmodule Pinchflat.YtDlp.CommandRunnerTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "run/4 when testing global options" do
|
||||
test "creates windows-safe filenames" do
|
||||
assert {:ok, output} = Runner.run(@media_url, [], "")
|
||||
|
||||
assert String.contains?(output, "--windows-filenames")
|
||||
end
|
||||
end
|
||||
|
||||
describe "version/0" do
|
||||
test "adds the version arg" do
|
||||
assert {:ok, output} = Runner.version()
|
||||
|
|
|
|||
Loading…
Reference in a new issue