diff --git a/lib/pinchflat/downloading/download_option_builder.ex b/lib/pinchflat/downloading/download_option_builder.ex index 3bd8830a..0bafc2e1 100644 --- a/lib/pinchflat/downloading/download_option_builder.ex +++ b/lib/pinchflat/downloading/download_option_builder.ex @@ -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