From a365685b3e5e5be4aefc264e092d3cafd60379c1 Mon Sep 17 00:00:00 2001 From: Kieran Eglin Date: Tue, 17 Dec 2024 11:10:22 -0800 Subject: [PATCH] Updated get_downloadable_status to pass yt cookies --- lib/pinchflat/downloading/media_downloader.ex | 6 ++++-- lib/pinchflat/yt_dlp/media.ex | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/pinchflat/downloading/media_downloader.ex b/lib/pinchflat/downloading/media_downloader.ex index 5425932..0c4c016 100644 --- a/lib/pinchflat/downloading/media_downloader.ex +++ b/lib/pinchflat/downloading/media_downloader.ex @@ -113,9 +113,11 @@ defmodule Pinchflat.Downloading.MediaDownloader do defp download_with_options(url, item_with_preloads, output_filepath, override_opts) do {:ok, options} = DownloadOptionBuilder.build(item_with_preloads, override_opts) - runner_opts = [output_filepath: output_filepath, use_cookies: item_with_preloads.source.use_cookies] + use_cookies = item_with_preloads.source.use_cookies + runner_opts = [output_filepath: output_filepath, use_cookies: use_cookies] - case YtDlpMedia.get_downloadable_status(url) do + # TODO: test + case YtDlpMedia.get_downloadable_status(url, use_cookies: use_cookies) do {:ok, :downloadable} -> YtDlpMedia.download(url, options, runner_opts) {:ok, :ignorable} -> {:error, :unsuitable_for_download} err -> err diff --git a/lib/pinchflat/yt_dlp/media.ex b/lib/pinchflat/yt_dlp/media.ex index 4f68a35..d936041 100644 --- a/lib/pinchflat/yt_dlp/media.ex +++ b/lib/pinchflat/yt_dlp/media.ex @@ -55,8 +55,11 @@ defmodule Pinchflat.YtDlp.Media do Returns {:ok, :downloadable | :ignorable} | {:error, any} """ - def get_downloadable_status(url) do - case backend_runner().run(url, :get_downloadable_status, [:simulate, :skip_download], "%(.{live_status})j") do + def get_downloadable_status(url, addl_opts \\ []) do + action = :get_downloadable_status + command_opts = [:simulate, :skip_download] + + case backend_runner().run(url, action, command_opts, "%(.{live_status})j", addl_opts) do {:ok, output} -> output |> Phoenix.json_library().decode!()