Skip to content

Commit

Permalink
Added padding to playlist_index output template (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
kieraneglin authored Jul 16, 2024
1 parent 4c7a63c commit d423e44
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/pinchflat/downloading/download_option_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit d423e44

Please sign in to comment.