From eda2d236a3fd6e5195a07475181f30c5bcf9af07 Mon Sep 17 00:00:00 2001 From: Kieran Eglin Date: Mon, 18 Mar 2024 14:22:18 -0700 Subject: [PATCH] Consolidated NFO selection options in media profile instead of source --- .../source_metadata_storage_worker.ex | 2 +- lib/pinchflat/sources/source.ex | 3 -- .../media_profile_form.html.heex | 33 +++++++++++++------ .../sources/source_html/source_form.html.heex | 16 --------- ...20240318161405_add_nfo_path_to_sources.exs | 1 - .../source_metadata_storage_worker_test.exs | 10 ++++-- 6 files changed, 31 insertions(+), 34 deletions(-) diff --git a/lib/pinchflat/metadata/source_metadata_storage_worker.ex b/lib/pinchflat/metadata/source_metadata_storage_worker.ex index bee50db..3380ea3 100644 --- a/lib/pinchflat/metadata/source_metadata_storage_worker.ex +++ b/lib/pinchflat/metadata/source_metadata_storage_worker.ex @@ -86,7 +86,7 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorker do end defp store_source_nfo(source, series_directory, metadata) do - if source.download_nfo && series_directory do + if source.media_profile.download_nfo && series_directory do nfo_filepath = Path.join(series_directory, "tvshow.nfo") NfoBuilder.build_and_store_for_source(nfo_filepath, metadata) diff --git a/lib/pinchflat/sources/source.ex b/lib/pinchflat/sources/source.ex index baab932..56bcb91 100644 --- a/lib/pinchflat/sources/source.ex +++ b/lib/pinchflat/sources/source.ex @@ -17,7 +17,6 @@ defmodule Pinchflat.Sources.Source do collection_id collection_type custom_name - download_nfo nfo_filepath series_directory index_frequency_minutes @@ -40,7 +39,6 @@ defmodule Pinchflat.Sources.Source do download_media original_url media_profile_id - download_nfo )a @pre_insert_required_fields @initially_required_fields ++ @@ -56,7 +54,6 @@ defmodule Pinchflat.Sources.Source do field :collection_name, :string field :collection_id, :string field :collection_type, Ecto.Enum, values: [:channel, :playlist] - field :download_nfo, :boolean, default: false field :nfo_filepath, :string field :series_directory, :string field :index_frequency_minutes, :integer, default: 60 * 24 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 1a0ee5b..07cc07e 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 @@ -162,16 +162,6 @@ /> -
- <.input - field={f[:download_nfo]} - type="toggle" - label="Download episode NFO data" - help="Downloads episode NFO data alongside media file for use with Jellyfin, Kodi, etc." - x-init="$watch('selectedPreset', p => p && (enabled = presets[p]))" - /> -
-

Release Format Options

@@ -213,6 +203,29 @@ /> +

+ Media Center Options +

+

+ Everything in this section is experimental - please open a GitHub issue if you see something odd. + These options only work if this Media Profile's output template is set to split media into seasons. + Try the "Media Center" preset if you're not sure. +

+ +
+ <.input + field={f[:download_nfo]} + type="toggle" + label="Download NFO data" + label_suffix="(pro)" + help="Downloads NFO data alongside media file for use with Jellyfin, Kodi, etc." + x-init="$watch('selectedPreset', p => p && (enabled = presets[p]))" + /> +
+ <.button class="my-10 sm:mb-7.5 w-full sm:w-auto">Save Media profile diff --git a/lib/pinchflat_web/controllers/sources/source_html/source_form.html.heex b/lib/pinchflat_web/controllers/sources/source_html/source_form.html.heex index 2ddff50..564296b 100644 --- a/lib/pinchflat_web/controllers/sources/source_html/source_form.html.heex +++ b/lib/pinchflat_web/controllers/sources/source_html/source_form.html.heex @@ -69,22 +69,6 @@ help="Only download media uploaded after this date. Leave blank to download all media. Must be in YYYY-MM-DD format" /> -

- Metadata Options -

-

- Everything in this section is experimental - please open a GitHub issue if you see something odd. - These options only work if your Media Profile's output template is set to split media into seasons. - Try the "Media Center" preset for Media Profiles if you're not sure. -

- - <.input - field={f[:download_nfo]} - type="toggle" - label="Download series NFO data" - help="Downloads series NFO data for use with Jellyfin, Kodi, etc. Uneffected by 'Download Media'" - /> - <.button class="my-10 sm:mb-7.5 w-full sm:w-auto">Save Source
diff --git a/priv/repo/migrations/20240318161405_add_nfo_path_to_sources.exs b/priv/repo/migrations/20240318161405_add_nfo_path_to_sources.exs index dd336c3..da1f1b9 100644 --- a/priv/repo/migrations/20240318161405_add_nfo_path_to_sources.exs +++ b/priv/repo/migrations/20240318161405_add_nfo_path_to_sources.exs @@ -3,7 +3,6 @@ defmodule Pinchflat.Repo.Migrations.AddNfoPathToSources do def change do alter table(:sources) do - add :download_nfo, :boolean, default: false, null: false add :nfo_filepath, :string add :series_directory, :string end diff --git a/test/pinchflat/metadata/source_metadata_storage_worker_test.exs b/test/pinchflat/metadata/source_metadata_storage_worker_test.exs index 7c15ba2..c8a096e 100644 --- a/test/pinchflat/metadata/source_metadata_storage_worker_test.exs +++ b/test/pinchflat/metadata/source_metadata_storage_worker_test.exs @@ -2,6 +2,7 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do use Pinchflat.DataCase import Mox import Pinchflat.SourcesFixtures + import Pinchflat.ProfilesFixtures alias Pinchflat.Metadata.MetadataFileHelpers alias Pinchflat.Metadata.SourceMetadataStorageWorker @@ -133,7 +134,8 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do {:ok, "{}"} end) - source = source_fixture(%{download_nfo: true, nfo_filepath: nil}) + profile = media_profile_fixture(%{download_nfo: true}) + source = source_fixture(%{nfo_filepath: nil, media_profile_id: profile.id}) perform_job(SourceMetadataStorageWorker, %{id: source.id}) source = Repo.reload(source) @@ -155,7 +157,8 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do {:ok, "{}"} end) - source = source_fixture(%{download_nfo: false, nfo_filepath: nil}) + profile = media_profile_fixture(%{download_nfo: false}) + source = source_fixture(%{nfo_filepath: nil, media_profile_id: profile.id}) perform_job(SourceMetadataStorageWorker, %{id: source.id}) source = Repo.reload(source) @@ -173,7 +176,8 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do {:ok, "{}"} end) - source = source_fixture(%{download_nfo: true, nfo_filepath: nil}) + profile = media_profile_fixture(%{download_nfo: true}) + source = source_fixture(%{nfo_filepath: nil, media_profile_id: profile.id}) perform_job(SourceMetadataStorageWorker, %{id: source.id}) source = Repo.reload(source)