diff --git a/lib/pinchflat/profiles/media_profile.ex b/lib/pinchflat/profiles/media_profile.ex index 34b3fdf..39bb6db 100644 --- a/lib/pinchflat/profiles/media_profile.ex +++ b/lib/pinchflat/profiles/media_profile.ex @@ -8,9 +8,24 @@ defmodule Pinchflat.Profiles.MediaProfile do alias Pinchflat.MediaSource.Channel + @allowed_fields ~w( + name + output_path_template + download_subs + download_auto_subs + embed_subs + sub_langs + )a + + @required_fields ~w(name output_path_template)a + schema "media_profiles" do field :name, :string field :output_path_template, :string + field :download_subs, :boolean, default: true + field :download_auto_subs, :boolean, default: true + field :embed_subs, :boolean, default: true + field :sub_langs, :string, default: "en" has_many :channels, Channel @@ -20,8 +35,8 @@ defmodule Pinchflat.Profiles.MediaProfile do @doc false def changeset(media_profile, attrs) do media_profile - |> cast(attrs, [:name, :output_path_template]) - |> validate_required([:name, :output_path_template]) + |> cast(attrs, @allowed_fields) + |> validate_required(@required_fields) |> unique_constraint(:name) end end diff --git a/priv/repo/migrations/20240131042824_add_subtitle_options_to_media_profiles.exs b/priv/repo/migrations/20240131042824_add_subtitle_options_to_media_profiles.exs new file mode 100644 index 0000000..ecc36c1 --- /dev/null +++ b/priv/repo/migrations/20240131042824_add_subtitle_options_to_media_profiles.exs @@ -0,0 +1,12 @@ +defmodule Pinchflat.Repo.Migrations.AddSubtitleOptionsToMediaProfiles do + use Ecto.Migration + + def change do + alter table(:media_profiles) do + add :download_subs, :boolean, default: true, null: false + add :download_auto_subs, :boolean, default: true, null: false + add :embed_subs, :boolean, default: true, null: false + add :sub_langs, :string, default: "en", null: false + end + end +end