Added subtitle options to media profile model
This commit is contained in:
parent
a5e7c48f70
commit
a138986d1f
2 changed files with 29 additions and 2 deletions
|
|
@ -8,9 +8,24 @@ defmodule Pinchflat.Profiles.MediaProfile do
|
||||||
|
|
||||||
alias Pinchflat.MediaSource.Channel
|
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
|
schema "media_profiles" do
|
||||||
field :name, :string
|
field :name, :string
|
||||||
field :output_path_template, :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
|
has_many :channels, Channel
|
||||||
|
|
||||||
|
|
@ -20,8 +35,8 @@ defmodule Pinchflat.Profiles.MediaProfile do
|
||||||
@doc false
|
@doc false
|
||||||
def changeset(media_profile, attrs) do
|
def changeset(media_profile, attrs) do
|
||||||
media_profile
|
media_profile
|
||||||
|> cast(attrs, [:name, :output_path_template])
|
|> cast(attrs, @allowed_fields)
|
||||||
|> validate_required([:name, :output_path_template])
|
|> validate_required(@required_fields)
|
||||||
|> unique_constraint(:name)
|
|> unique_constraint(:name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
Loading…
Reference in a new issue