Added description to source (#124)

This commit is contained in:
Kieran 2024-03-25 20:40:09 -07:00 committed by GitHub
parent 42a418f79e
commit 7411177e7d
4 changed files with 30 additions and 0 deletions

View file

@ -32,6 +32,7 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorker do
@doc """
Fetches and stores various forms of metadata for a source:
- Attributes like `description`
- JSON metadata for internal use
- The series directory for the source
- The NFO file for the source (if specified)
@ -59,6 +60,7 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorker do
%{
series_directory: series_directory,
nfo_filepath: store_source_nfo(source, series_directory, source_metadata),
description: source_metadata["description"],
metadata: Map.merge(%{metadata_filepath: source_metadata_filepath}, metadata_image_attrs)
},
source_image_attrs

View file

@ -17,6 +17,7 @@ defmodule Pinchflat.Sources.Source do
collection_id
collection_type
custom_name
description
nfo_filepath
poster_filepath
fanart_filepath
@ -55,6 +56,7 @@ defmodule Pinchflat.Sources.Source do
schema "sources" do
field :custom_name, :string
field :description, :string
field :collection_name, :string
field :collection_id, :string
field :collection_type, Ecto.Enum, values: [:channel, :playlist]

View file

@ -0,0 +1,9 @@
defmodule Pinchflat.Repo.Migrations.AddDescriptionToSource do
use Ecto.Migration
def change do
alter table(:sources) do
add :description, :string
end
end
end

View file

@ -50,6 +50,23 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do
end
end
describe "perform/1 when testing attribute updates" do
test "the source description is saved" do
stub(YtDlpRunnerMock, :run, fn
_url, _opts, ot when ot == @source_details_ot -> {:ok, source_details_return_fixture()}
_url, _opts, ot when ot == @metadata_ot -> {:ok, render_metadata(:channel_source_metadata)}
end)
source = source_fixture()
refute source.description
perform_job(SourceMetadataStorageWorker, %{id: source.id})
source = Repo.preload(Repo.reload(source), :metadata)
assert source.description == "This is a test file for Pinchflat"
end
end
describe "perform/1 when testing metadata storage" do
test "sets metadata location for source" do
stub(YtDlpRunnerMock, :run, fn