* Bumped up the line length because I fear no man * Refactored indexing Previously, indexing worked by collecting the video IDs of only videos that matched indexing criteria. This new model instead stores ALL videos for a given source, but will only _download_ videos that meet that criteria. This lets us backfill without indexing, makes it easier to add in other backends, lets us download one-off videos for a source that don't quite meet criteria, you name it. * Updated media finders to respect format filters; Added credo file
66 lines
2 KiB
Elixir
66 lines
2 KiB
Elixir
defmodule Pinchflat.Profiles.MediaProfile do
|
|
@moduledoc """
|
|
A media profile is a set of settings that can be applied to many media sources
|
|
"""
|
|
|
|
use Ecto.Schema
|
|
import Ecto.Changeset
|
|
|
|
alias Pinchflat.MediaSource.Source
|
|
|
|
@allowed_fields ~w(
|
|
name
|
|
output_path_template
|
|
download_subs
|
|
download_auto_subs
|
|
embed_subs
|
|
sub_langs
|
|
download_thumbnail
|
|
embed_thumbnail
|
|
download_metadata
|
|
embed_metadata
|
|
shorts_behaviour
|
|
livestream_behaviour
|
|
)a
|
|
|
|
@required_fields ~w(name output_path_template)a
|
|
|
|
schema "media_profiles" do
|
|
field :name, :string
|
|
|
|
field :output_path_template, :string, default: "/{{ uploader }}/{{ title }}.{{ ext }}"
|
|
|
|
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"
|
|
|
|
field :download_thumbnail, :boolean, default: true
|
|
field :embed_thumbnail, :boolean, default: true
|
|
|
|
field :download_metadata, :boolean, default: true
|
|
field :embed_metadata, :boolean, default: true
|
|
|
|
# NOTE: these do NOT speed up indexing - the indexer still has to go
|
|
# through the entire collection to determine if a video is a short or
|
|
# a livestream.
|
|
# NOTE: these can BOTH be set to :only which will download shorts and
|
|
# livestreams _only_ and ignore regular videos. The redundant case
|
|
# is when one is set to :only and the other is set to :exclude.
|
|
# See `build_format_clauses` in the Media context for more.
|
|
field :shorts_behaviour, Ecto.Enum, values: [:include, :exclude, :only], default: :include
|
|
field :livestream_behaviour, Ecto.Enum, values: [:include, :exclude, :only], default: :include
|
|
|
|
has_many :sources, Source
|
|
|
|
timestamps(type: :utc_datetime)
|
|
end
|
|
|
|
@doc false
|
|
def changeset(media_profile, attrs) do
|
|
media_profile
|
|
|> cast(attrs, @allowed_fields)
|
|
|> validate_required(@required_fields)
|
|
|> unique_constraint(:name)
|
|
end
|
|
end
|