Source title regex filtering (#98)

* Added a basic/advanced mode to source form

* Added regex field and UI to source form

* Implemented title regex filtering
This commit is contained in:
Kieran
2024-03-20 10:51:14 -07:00
committed by GitHub
parent 087c9c2d0f
commit 3db2e8190f
33 changed files with 95 additions and 11 deletions
+9
View File
@@ -66,6 +66,7 @@ defmodule Pinchflat.Media do
|> where([mi], mi.source_id == ^source.id and is_nil(mi.media_filepath))
|> where(^build_format_clauses(media_profile))
|> where(^maybe_apply_cutoff_date(source))
|> where(^maybe_apply_title_regex(source))
|> Repo.maybe_limit(limit)
|> Repo.all()
end
@@ -247,6 +248,14 @@ defmodule Pinchflat.Media do
end
end
defp maybe_apply_title_regex(source) do
if source.title_filter_regex do
dynamic([mi], fragment("regexp_like(?, ?)", mi.title, ^source.title_filter_regex))
else
dynamic(true)
end
end
defp build_format_clauses(media_profile) do
mapped_struct = Map.from_struct(media_profile)
+8 -5
View File
@@ -28,6 +28,7 @@ defmodule Pinchflat.Sources.Source do
last_indexed_at
original_url
download_cutoff_date
title_filter_regex
media_profile_id
)a
@@ -57,11 +58,6 @@ defmodule Pinchflat.Sources.Source do
field :collection_name, :string
field :collection_id, :string
field :collection_type, Ecto.Enum, values: [:channel, :playlist]
field :nfo_filepath, :string
field :poster_filepath, :string
field :fanart_filepath, :string
field :banner_filepath, :string
field :series_directory, :string
field :index_frequency_minutes, :integer, default: 60 * 24
field :fast_index, :boolean, default: false
field :download_media, :boolean, default: true
@@ -69,6 +65,13 @@ defmodule Pinchflat.Sources.Source do
# Only download media items that were published after this date
field :download_cutoff_date, :date
field :original_url, :string
field :title_filter_regex, :string
field :series_directory, :string
field :nfo_filepath, :string
field :poster_filepath, :string
field :fanart_filepath, :string
field :banner_filepath, :string
belongs_to :media_profile, MediaProfile