From dcf033f10ac19f63c8ada3d2552920607f22ea6a Mon Sep 17 00:00:00 2001 From: Kieran Date: Wed, 15 May 2024 13:17:11 -0700 Subject: [PATCH] Added support for ytdlp cache (#245) --- lib/pinchflat/yt_dlp/command_runner.ex | 6 +++++- test/pinchflat/yt_dlp/command_runner_test.exs | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/pinchflat/yt_dlp/command_runner.ex b/lib/pinchflat/yt_dlp/command_runner.ex index fe9aadaa..30b2404a 100644 --- a/lib/pinchflat/yt_dlp/command_runner.ex +++ b/lib/pinchflat/yt_dlp/command_runner.ex @@ -71,7 +71,11 @@ defmodule Pinchflat.YtDlp.CommandRunner do end defp global_options do - [:windows_filenames, :quiet] + [ + :windows_filenames, + :quiet, + cache_dir: Path.join(Application.get_env(:pinchflat, :tmpfile_directory), "yt-dlp-cache") + ] end defp cookie_file_options do diff --git a/test/pinchflat/yt_dlp/command_runner_test.exs b/test/pinchflat/yt_dlp/command_runner_test.exs index a5e685ae..6dbb8565 100644 --- a/test/pinchflat/yt_dlp/command_runner_test.exs +++ b/test/pinchflat/yt_dlp/command_runner_test.exs @@ -93,6 +93,12 @@ defmodule Pinchflat.YtDlp.CommandRunnerTest do assert String.contains?(output, "--quiet") end + + test "sets the cache directory" do + assert {:ok, output} = Runner.run(@media_url, [], "") + + assert String.contains?(output, "--cache-dir /tmp/test/tmpfiles/yt-dlp-cache") + end end describe "version/0" do