Consolidated NFO selection options in media profile instead of source

This commit is contained in:
Kieran Eglin 2024-03-18 14:22:18 -07:00
parent e81e987abe
commit eda2d236a3
No known key found for this signature in database
GPG key ID: 193984967FCF432D
6 changed files with 31 additions and 34 deletions

View file

@ -86,7 +86,7 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorker do
end end
defp store_source_nfo(source, series_directory, metadata) do 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") nfo_filepath = Path.join(series_directory, "tvshow.nfo")
NfoBuilder.build_and_store_for_source(nfo_filepath, metadata) NfoBuilder.build_and_store_for_source(nfo_filepath, metadata)

View file

@ -17,7 +17,6 @@ defmodule Pinchflat.Sources.Source do
collection_id collection_id
collection_type collection_type
custom_name custom_name
download_nfo
nfo_filepath nfo_filepath
series_directory series_directory
index_frequency_minutes index_frequency_minutes
@ -40,7 +39,6 @@ defmodule Pinchflat.Sources.Source do
download_media download_media
original_url original_url
media_profile_id media_profile_id
download_nfo
)a )a
@pre_insert_required_fields @initially_required_fields ++ @pre_insert_required_fields @initially_required_fields ++
@ -56,7 +54,6 @@ defmodule Pinchflat.Sources.Source do
field :collection_name, :string field :collection_name, :string
field :collection_id, :string field :collection_id, :string
field :collection_type, Ecto.Enum, values: [:channel, :playlist] field :collection_type, Ecto.Enum, values: [:channel, :playlist]
field :download_nfo, :boolean, default: false
field :nfo_filepath, :string field :nfo_filepath, :string
field :series_directory, :string field :series_directory, :string
field :index_frequency_minutes, :integer, default: 60 * 24 field :index_frequency_minutes, :integer, default: 60 * 24

View file

@ -162,16 +162,6 @@
/> />
</section> </section>
<section x-data="{ presets: { default: false, media_center: true, audio: false, archiving: true } }">
<.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]))"
/>
</section>
<h3 class="mt-10 text-2xl text-black dark:text-white"> <h3 class="mt-10 text-2xl text-black dark:text-white">
Release Format Options Release Format Options
</h3> </h3>
@ -213,6 +203,29 @@
/> />
</section> </section>
<h3 class="mt-8 text-2xl text-black dark:text-white">
Media Center Options
</h3>
<p class="text-sm mt-2 max-w-prose">
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.
</p>
<section
phx-click={show_modal("upgrade-modal")}
x-data="{ presets: { default: false, media_center: true, audio: false, archiving: false } }"
>
<.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]))"
/>
</section>
<.button class="my-10 sm:mb-7.5 w-full sm:w-auto">Save Media profile</.button> <.button class="my-10 sm:mb-7.5 w-full sm:w-auto">Save Media profile</.button>
</section> </section>

View file

@ -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" help="Only download media uploaded after this date. Leave blank to download all media. Must be in YYYY-MM-DD format"
/> />
<h3 class="mt-8 text-2xl text-black dark:text-white">
Metadata Options
</h3>
<p class="text-sm mt-2 max-w-prose">
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.
</p>
<.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</.button> <.button class="my-10 sm:mb-7.5 w-full sm:w-auto">Save Source</.button>
<div class="rounded-sm dark:bg-meta-4 p-4 md:p-6 mb-5"> <div class="rounded-sm dark:bg-meta-4 p-4 md:p-6 mb-5">

View file

@ -3,7 +3,6 @@ defmodule Pinchflat.Repo.Migrations.AddNfoPathToSources do
def change do def change do
alter table(:sources) do alter table(:sources) do
add :download_nfo, :boolean, default: false, null: false
add :nfo_filepath, :string add :nfo_filepath, :string
add :series_directory, :string add :series_directory, :string
end end

View file

@ -2,6 +2,7 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do
use Pinchflat.DataCase use Pinchflat.DataCase
import Mox import Mox
import Pinchflat.SourcesFixtures import Pinchflat.SourcesFixtures
import Pinchflat.ProfilesFixtures
alias Pinchflat.Metadata.MetadataFileHelpers alias Pinchflat.Metadata.MetadataFileHelpers
alias Pinchflat.Metadata.SourceMetadataStorageWorker alias Pinchflat.Metadata.SourceMetadataStorageWorker
@ -133,7 +134,8 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do
{:ok, "{}"} {:ok, "{}"}
end) 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}) perform_job(SourceMetadataStorageWorker, %{id: source.id})
source = Repo.reload(source) source = Repo.reload(source)
@ -155,7 +157,8 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do
{:ok, "{}"} {:ok, "{}"}
end) 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}) perform_job(SourceMetadataStorageWorker, %{id: source.id})
source = Repo.reload(source) source = Repo.reload(source)
@ -173,7 +176,8 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do
{:ok, "{}"} {:ok, "{}"}
end) 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}) perform_job(SourceMetadataStorageWorker, %{id: source.id})
source = Repo.reload(source) source = Repo.reload(source)