Added actions to all callers of the yt-dlp runner
This commit is contained in:
parent
493d36a8ad
commit
22183d87e8
2 changed files with 10 additions and 7 deletions
|
|
@ -41,7 +41,7 @@ defmodule Pinchflat.YtDlp.Media do
|
||||||
def download(url, command_opts \\ [], addl_opts \\ []) do
|
def download(url, command_opts \\ [], addl_opts \\ []) do
|
||||||
all_command_opts = [:no_simulate] ++ command_opts
|
all_command_opts = [:no_simulate] ++ command_opts
|
||||||
|
|
||||||
with {:ok, output} <- backend_runner().run(url, all_command_opts, "after_move:%()j", addl_opts),
|
with {:ok, output} <- backend_runner().run(url, :download, all_command_opts, "after_move:%()j", addl_opts),
|
||||||
{:ok, parsed_json} <- Phoenix.json_library().decode(output) do
|
{:ok, parsed_json} <- Phoenix.json_library().decode(output) do
|
||||||
{:ok, parsed_json}
|
{:ok, parsed_json}
|
||||||
else
|
else
|
||||||
|
|
@ -56,7 +56,7 @@ defmodule Pinchflat.YtDlp.Media do
|
||||||
Returns {:ok, :downloadable | :ignorable} | {:error, any}
|
Returns {:ok, :downloadable | :ignorable} | {:error, any}
|
||||||
"""
|
"""
|
||||||
def get_downloadable_status(url) do
|
def get_downloadable_status(url) do
|
||||||
case backend_runner().run(url, [:simulate, :skip_download], "%(.{live_status})j") do
|
case backend_runner().run(url, :get_downloadable_status, [:simulate, :skip_download], "%(.{live_status})j") do
|
||||||
{:ok, output} ->
|
{:ok, output} ->
|
||||||
output
|
output
|
||||||
|> Phoenix.json_library().decode!()
|
|> Phoenix.json_library().decode!()
|
||||||
|
|
@ -78,7 +78,7 @@ defmodule Pinchflat.YtDlp.Media do
|
||||||
|
|
||||||
# NOTE: it doesn't seem like this command actually returns anything in `after_move` since
|
# NOTE: it doesn't seem like this command actually returns anything in `after_move` since
|
||||||
# we aren't downloading the main media file
|
# we aren't downloading the main media file
|
||||||
backend_runner().run(url, all_command_opts, "after_move:%()j", addl_opts)
|
backend_runner().run(url, :download_thumbnail, all_command_opts, "after_move:%()j", addl_opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
@ -92,7 +92,7 @@ defmodule Pinchflat.YtDlp.Media do
|
||||||
all_command_opts = [:simulate, :skip_download] ++ command_opts
|
all_command_opts = [:simulate, :skip_download] ++ command_opts
|
||||||
output_template = indexing_output_template()
|
output_template = indexing_output_template()
|
||||||
|
|
||||||
case backend_runner().run(url, all_command_opts, output_template, addl_opts) do
|
case backend_runner().run(url, :get_media_attributes, all_command_opts, output_template, addl_opts) do
|
||||||
{:ok, output} ->
|
{:ok, output} ->
|
||||||
output
|
output
|
||||||
|> Phoenix.json_library().decode!()
|
|> Phoenix.json_library().decode!()
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,13 @@ defmodule Pinchflat.YtDlp.MediaCollection do
|
||||||
output_filepath = FilesystemUtils.generate_metadata_tmpfile(:json)
|
output_filepath = FilesystemUtils.generate_metadata_tmpfile(:json)
|
||||||
file_listener_handler = Keyword.get(addl_opts, :file_listener_handler, false)
|
file_listener_handler = Keyword.get(addl_opts, :file_listener_handler, false)
|
||||||
runner_opts = [output_filepath: output_filepath, use_cookies: use_cookies]
|
runner_opts = [output_filepath: output_filepath, use_cookies: use_cookies]
|
||||||
|
action = :get_media_attributes_for_collection
|
||||||
|
|
||||||
if file_listener_handler do
|
if file_listener_handler do
|
||||||
file_listener_handler.(output_filepath)
|
file_listener_handler.(output_filepath)
|
||||||
end
|
end
|
||||||
|
|
||||||
case runner.run(url, all_command_opts, output_template, runner_opts) do
|
case runner.run(url, action, all_command_opts, output_template, runner_opts) do
|
||||||
{:ok, output} ->
|
{:ok, output} ->
|
||||||
parsed_lines =
|
parsed_lines =
|
||||||
output
|
output
|
||||||
|
|
@ -82,8 +83,9 @@ defmodule Pinchflat.YtDlp.MediaCollection do
|
||||||
|
|
||||||
all_command_opts = default_opts ++ command_opts
|
all_command_opts = default_opts ++ command_opts
|
||||||
output_template = "%(.{channel,channel_id,playlist_id,playlist_title,filename})j"
|
output_template = "%(.{channel,channel_id,playlist_id,playlist_title,filename})j"
|
||||||
|
action = :get_source_details
|
||||||
|
|
||||||
with {:ok, output} <- backend_runner().run(source_url, all_command_opts, output_template, addl_opts),
|
with {:ok, output} <- backend_runner().run(source_url, action, all_command_opts, output_template, addl_opts),
|
||||||
{:ok, parsed_json} <- Phoenix.json_library().decode(output) do
|
{:ok, parsed_json} <- Phoenix.json_library().decode(output) do
|
||||||
{:ok, format_source_details(parsed_json)}
|
{:ok, format_source_details(parsed_json)}
|
||||||
else
|
else
|
||||||
|
|
@ -121,8 +123,9 @@ defmodule Pinchflat.YtDlp.MediaCollection do
|
||||||
|
|
||||||
all_command_opts = [:skip_download] ++ command_opts
|
all_command_opts = [:skip_download] ++ command_opts
|
||||||
output_template = "playlist:%()j"
|
output_template = "playlist:%()j"
|
||||||
|
action = :get_source_metadata
|
||||||
|
|
||||||
with {:ok, output} <- backend_runner().run(source_url, all_command_opts, output_template, addl_opts),
|
with {:ok, output} <- backend_runner().run(source_url, action, all_command_opts, output_template, addl_opts),
|
||||||
{:ok, parsed_json} <- Phoenix.json_library().decode(output) do
|
{:ok, parsed_json} <- Phoenix.json_library().decode(output) do
|
||||||
{:ok, parsed_json}
|
{:ok, parsed_json}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue