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,
|
:livestream,
|
||||||
:short_form_content,
|
:short_form_content,
|
||||||
:uploaded_at,
|
:uploaded_at,
|
||||||
:duration_seconds
|
:duration_seconds,
|
||||||
|
:predicted_filepath
|
||||||
]
|
]
|
||||||
|
|
||||||
defstruct [
|
defstruct [
|
||||||
|
|
@ -23,7 +24,8 @@ defmodule Pinchflat.YtDlp.Media do
|
||||||
:short_form_content,
|
:short_form_content,
|
||||||
:uploaded_at,
|
:uploaded_at,
|
||||||
:duration_seconds,
|
:duration_seconds,
|
||||||
:playlist_index
|
:playlist_index,
|
||||||
|
:predicted_filepath
|
||||||
]
|
]
|
||||||
|
|
||||||
alias __MODULE__
|
alias __MODULE__
|
||||||
|
|
@ -93,7 +95,7 @@ defmodule Pinchflat.YtDlp.Media do
|
||||||
if something is a short via the URL again
|
if something is a short via the URL again
|
||||||
"""
|
"""
|
||||||
def indexing_output_template do
|
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
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
@ -112,7 +114,8 @@ defmodule Pinchflat.YtDlp.Media do
|
||||||
duration_seconds: response["duration"] && round(response["duration"]),
|
duration_seconds: response["duration"] && round(response["duration"]),
|
||||||
short_form_content: response["original_url"] && short_form_content?(response),
|
short_form_content: response["original_url"] && short_form_content?(response),
|
||||||
uploaded_at: response["upload_date"] && parse_uploaded_at(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
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ defmodule Pinchflat.YtDlp.MediaTest do
|
||||||
describe "indexing_output_template/0" do
|
describe "indexing_output_template/0" do
|
||||||
test "contains all the greatest hits" do
|
test "contains all the greatest hits" do
|
||||||
attrs =
|
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"
|
formatted_attrs = "%(.{#{Enum.join(attrs, ",")}})j"
|
||||||
|
|
||||||
|
|
@ -168,7 +168,8 @@ defmodule Pinchflat.YtDlp.MediaTest do
|
||||||
"duration" => 60,
|
"duration" => 60,
|
||||||
"upload_date" => "20210101",
|
"upload_date" => "20210101",
|
||||||
"timestamp" => 1_600_000_000,
|
"timestamp" => 1_600_000_000,
|
||||||
"playlist_index" => 1
|
"playlist_index" => 1,
|
||||||
|
"filename" => "TiZPUDkDYbk.mp4"
|
||||||
}
|
}
|
||||||
|
|
||||||
assert %Media{
|
assert %Media{
|
||||||
|
|
@ -180,7 +181,8 @@ defmodule Pinchflat.YtDlp.MediaTest do
|
||||||
short_form_content: false,
|
short_form_content: false,
|
||||||
uploaded_at: ~U[2020-09-13 12:26:40Z],
|
uploaded_at: ~U[2020-09-13 12:26:40Z],
|
||||||
duration_seconds: 60,
|
duration_seconds: 60,
|
||||||
playlist_index: 1
|
playlist_index: 1,
|
||||||
|
predicted_filepath: "TiZPUDkDYbk.mp4"
|
||||||
} == Media.response_to_struct(response)
|
} == Media.response_to_struct(response)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue