diff --git a/lib/pinchflat/media/media_item.ex b/lib/pinchflat/media/media_item.ex index 52633b2..3abcd48 100644 --- a/lib/pinchflat/media/media_item.ex +++ b/lib/pinchflat/media/media_item.ex @@ -34,7 +34,8 @@ defmodule Pinchflat.Media.MediaItem do # These are user or system controlled fields :prevent_download, :prevent_culling, - :culled_at + :culled_at, + :redownloaded_at ] # Pretty much all the fields captured at index are required. @required_fields ~w( @@ -77,6 +78,7 @@ defmodule Pinchflat.Media.MediaItem do field :prevent_download, :boolean, default: false field :prevent_culling, :boolean, default: false field :culled_at, :utc_datetime + field :redownloaded_at, :utc_datetime field :matching_search_term, :string, virtual: true diff --git a/lib/pinchflat/profiles/media_profile.ex b/lib/pinchflat/profiles/media_profile.ex index 57a3b7f..0b351a9 100644 --- a/lib/pinchflat/profiles/media_profile.ex +++ b/lib/pinchflat/profiles/media_profile.ex @@ -26,12 +26,14 @@ defmodule Pinchflat.Profiles.MediaProfile do shorts_behaviour livestream_behaviour preferred_resolution + redownload_delay_days )a @required_fields ~w(name output_path_template)a schema "media_profiles" do field :name, :string + field :redownload_delay_days, :integer field :output_path_template, :string, default: "/{{ source_custom_name }}/{{ upload_yyyy_mm_dd }} {{ title }}/{{ title }} [{{ id }}].{{ ext }}" @@ -60,7 +62,6 @@ defmodule Pinchflat.Profiles.MediaProfile do # See `build_format_clauses` in the Media context for more. field :shorts_behaviour, Ecto.Enum, values: ~w(include exclude only)a, default: :include field :livestream_behaviour, Ecto.Enum, values: ~w(include exclude only)a, default: :include - field :preferred_resolution, Ecto.Enum, values: ~w(2160p 1080p 720p 480p 360p audio)a, default: :"1080p" has_many :sources, Source @@ -75,6 +76,7 @@ defmodule Pinchflat.Profiles.MediaProfile do |> validate_required(@required_fields) # Ensures it ends with `.{{ ext }}` or `.%(ext)s` or similar (with a little wiggle room) |> validate_format(:output_path_template, ext_regex(), message: "must end with .{{ ext }}") + |> validate_number(:redownload_delay_days, greater_than_or_equal_to: 0) |> unique_constraint(:name) end diff --git a/priv/repo/migrations/20240409224152_add_redownloaded_fields.exs b/priv/repo/migrations/20240409224152_add_redownloaded_fields.exs new file mode 100644 index 0000000..d399110 --- /dev/null +++ b/priv/repo/migrations/20240409224152_add_redownloaded_fields.exs @@ -0,0 +1,13 @@ +defmodule Pinchflat.Repo.Migrations.AddRedownloadedFields do + use Ecto.Migration + + def change do + alter table(:media_profiles) do + add :redownload_delay_days, :integer + end + + alter table(:media_items) do + add :redownloaded_at, :utc_datetime + end + end +end