Added predicted_filename to media struct
This commit is contained in:
parent
28da8db466
commit
0b38c9a813
2 changed files with 12 additions and 7 deletions
|
|
@ -11,7 +11,8 @@ defmodule Pinchflat.YtDlp.Media do
|
|||
:livestream,
|
||||
:short_form_content,
|
||||
:uploaded_at,
|
||||
:duration_seconds
|
||||
:duration_seconds,
|
||||
:predicted_filepath
|
||||
]
|
||||
|
||||
defstruct [
|
||||
|
|
@ -23,7 +24,8 @@ defmodule Pinchflat.YtDlp.Media do
|
|||
:short_form_content,
|
||||
:uploaded_at,
|
||||
:duration_seconds,
|
||||
:playlist_index
|
||||
:playlist_index,
|
||||
:predicted_filepath
|
||||
]
|
||||
|
||||
alias __MODULE__
|
||||
|
|
@ -93,7 +95,7 @@ defmodule Pinchflat.YtDlp.Media do
|
|||
if something is a short via the URL again
|
||||
"""
|
||||
def indexing_output_template do
|
||||
"%(.{id,title,live_status,original_url,description,aspect_ratio,duration,upload_date,timestamp,playlist_index})j"
|
||||
"%(.{id,title,live_status,original_url,description,aspect_ratio,duration,upload_date,timestamp,playlist_index,filename})j"
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
|
@ -112,7 +114,8 @@ defmodule Pinchflat.YtDlp.Media do
|
|||
duration_seconds: response["duration"] && round(response["duration"]),
|
||||
short_form_content: response["original_url"] && short_form_content?(response),
|
||||
uploaded_at: response["upload_date"] && parse_uploaded_at(response),
|
||||
playlist_index: response["playlist_index"] || 0
|
||||
playlist_index: response["playlist_index"] || 0,
|
||||
predicted_filepath: response["filename"]
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ defmodule Pinchflat.YtDlp.MediaTest do
|
|||
describe "indexing_output_template/0" do
|
||||
test "contains all the greatest hits" do
|
||||
attrs =
|
||||
~w(id title live_status original_url description aspect_ratio duration upload_date timestamp playlist_index)a
|
||||
~w(id title live_status original_url description aspect_ratio duration upload_date timestamp playlist_index filename)a
|
||||
|
||||
formatted_attrs = "%(.{#{Enum.join(attrs, ",")}})j"
|
||||
|
||||
|
|
@ -168,7 +168,8 @@ defmodule Pinchflat.YtDlp.MediaTest do
|
|||
"duration" => 60,
|
||||
"upload_date" => "20210101",
|
||||
"timestamp" => 1_600_000_000,
|
||||
"playlist_index" => 1
|
||||
"playlist_index" => 1,
|
||||
"filename" => "TiZPUDkDYbk.mp4"
|
||||
}
|
||||
|
||||
assert %Media{
|
||||
|
|
@ -180,7 +181,8 @@ defmodule Pinchflat.YtDlp.MediaTest do
|
|||
short_form_content: false,
|
||||
uploaded_at: ~U[2020-09-13 12:26:40Z],
|
||||
duration_seconds: 60,
|
||||
playlist_index: 1
|
||||
playlist_index: 1,
|
||||
predicted_filepath: "TiZPUDkDYbk.mp4"
|
||||
} == Media.response_to_struct(response)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue