Started capturing playlist_index on indexing pass
This commit is contained in:
parent
5a10015634
commit
41524cd01b
2 changed files with 17 additions and 8 deletions
|
|
@ -11,7 +11,8 @@ defmodule Pinchflat.YtDlp.Media do
|
|||
:livestream,
|
||||
:short_form_content,
|
||||
:uploaded_at,
|
||||
:duration_seconds
|
||||
:duration_seconds,
|
||||
:playlist_index
|
||||
]
|
||||
|
||||
defstruct [
|
||||
|
|
@ -22,7 +23,8 @@ defmodule Pinchflat.YtDlp.Media do
|
|||
:livestream,
|
||||
:short_form_content,
|
||||
:uploaded_at,
|
||||
:duration_seconds
|
||||
:duration_seconds,
|
||||
:playlist_index
|
||||
]
|
||||
|
||||
alias __MODULE__
|
||||
|
|
@ -84,9 +86,11 @@ defmodule Pinchflat.YtDlp.Media do
|
|||
|
||||
@doc """
|
||||
Returns the output template for yt-dlp's indexing command.
|
||||
|
||||
NOTE: playlist_index is really only useful for playlists that will never change their order.
|
||||
"""
|
||||
def indexing_output_template do
|
||||
"%(.{id,title,was_live,webpage_url,description,aspect_ratio,duration,upload_date,timestamp})j"
|
||||
"%(.{id,title,was_live,webpage_url,description,aspect_ratio,duration,upload_date,timestamp,playlist_index})j"
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
|
@ -104,7 +108,8 @@ defmodule Pinchflat.YtDlp.Media do
|
|||
livestream: !!response["was_live"],
|
||||
duration_seconds: response["duration"] && round(response["duration"]),
|
||||
short_form_content: response["webpage_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
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -110,8 +110,10 @@ defmodule Pinchflat.YtDlp.MediaTest do
|
|||
|
||||
describe "indexing_output_template/0" do
|
||||
test "contains all the greatest hits" do
|
||||
assert "%(.{id,title,was_live,webpage_url,description,aspect_ratio,duration,upload_date,timestamp})j" ==
|
||||
Media.indexing_output_template()
|
||||
attrs = ~w(id title was_live webpage_url description aspect_ratio duration upload_date timestamp playlist_index)a
|
||||
formatted_attrs = "%(.{#{Enum.join(attrs, ",")}})j"
|
||||
|
||||
assert formatted_attrs == Media.indexing_output_template()
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -126,7 +128,8 @@ defmodule Pinchflat.YtDlp.MediaTest do
|
|||
"aspect_ratio" => 1.0,
|
||||
"duration" => 60,
|
||||
"upload_date" => "20210101",
|
||||
"timestamp" => 1_600_000_000
|
||||
"timestamp" => 1_600_000_000,
|
||||
"playlist_index" => 1
|
||||
}
|
||||
|
||||
assert %Media{
|
||||
|
|
@ -137,7 +140,8 @@ defmodule Pinchflat.YtDlp.MediaTest do
|
|||
livestream: false,
|
||||
short_form_content: false,
|
||||
uploaded_at: ~U[2020-09-13 12:26:40Z],
|
||||
duration_seconds: 60
|
||||
duration_seconds: 60,
|
||||
playlist_index: 1
|
||||
} == Media.response_to_struct(response)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue