Added padding to playlist_index output template (#321)

This commit is contained in:
Kieran 2024-07-16 15:30:27 -07:00 committed by GitHub
parent 4c7a63c970
commit d423e4486f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -203,11 +203,8 @@ defmodule Pinchflat.Downloading.DownloadOptionBuilder do
"source_collection_id" => source.collection_id,
"source_collection_name" => source.collection_name,
"source_collection_type" => to_string(source.collection_type),
"media_playlist_index" => to_string(media_item_with_preloads.playlist_index),
"media_upload_date_index" =>
media_item_with_preloads.upload_date_index
|> to_string()
|> String.pad_leading(2, "0")
"media_playlist_index" => pad_int(media_item_with_preloads.playlist_index),
"media_upload_date_index" => pad_int(media_item_with_preloads.upload_date_index)
}
end
@ -224,6 +221,12 @@ defmodule Pinchflat.Downloading.DownloadOptionBuilder do
|> build_output_path(media_item_with_preloads)
end
defp pad_int(integer, count \\ 2, padding \\ "0") do
integer
|> to_string()
|> String.pad_leading(count, padding)
end
defp base_directory do
Application.get_env(:pinchflat, :media_directory)
end