Added redownload-related columns
This commit is contained in:
parent
1994ea5b08
commit
6c4d1411a7
3 changed files with 19 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Reference in a new issue