diff --git a/config/runtime.exs b/config/runtime.exs index 9b8585f..89d1d1a 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -25,6 +25,21 @@ config :pinchflat, basic_auth_username: System.get_env("BASIC_AUTH_USERNAME"), basic_auth_password: System.get_env("BASIC_AUTH_PASSWORD") +arch_string = to_string(:erlang.system_info(:system_architecture)) + +system_arch = + cond do + String.contains?(arch_string, "arm") -> "arm" + String.contains?(arch_string, "aarch") -> "arm" + String.contains?(arch_string, "x86") -> "x86" + true -> "unknown" + end + +config :pinchflat, Pinchflat.Repo, + load_extensions: [ + Path.join([:code.priv_dir(:pinchflat), "repo", "extensions", "sqlean-linux-#{system_arch}", "sqlean"]) + ] + if config_env() == :prod do config_path = System.get_env("CONFIG_PATH") || diff --git a/lib/pinchflat/media/media.ex b/lib/pinchflat/media/media.ex index e074ce1..e457ae7 100644 --- a/lib/pinchflat/media/media.ex +++ b/lib/pinchflat/media/media.ex @@ -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) diff --git a/lib/pinchflat/sources/source.ex b/lib/pinchflat/sources/source.ex index ec3075f..266ac85 100644 --- a/lib/pinchflat/sources/source.ex +++ b/lib/pinchflat/sources/source.ex @@ -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 diff --git a/lib/pinchflat_web/controllers/media_profiles/media_profile_html/media_profile_form.html.heex b/lib/pinchflat_web/controllers/media_profiles/media_profile_html/media_profile_form.html.heex index 33976a2..f662a20 100644 --- a/lib/pinchflat_web/controllers/media_profiles/media_profile_html/media_profile_form.html.heex +++ b/lib/pinchflat_web/controllers/media_profiles/media_profile_html/media_profile_form.html.heex @@ -238,7 +238,7 @@ /> - <.button class="my-10 sm:mb-7.5 w-full sm:w-auto">Save Media profile + <.button class="my-10 sm:mb-7.5 w-full sm:w-auto" rounding="rounded-lg">Save Media profile