Added description to source (#124)
This commit is contained in:
parent
42a418f79e
commit
7411177e7d
4 changed files with 30 additions and 0 deletions
|
|
@ -32,6 +32,7 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorker do
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Fetches and stores various forms of metadata for a source:
|
Fetches and stores various forms of metadata for a source:
|
||||||
|
- Attributes like `description`
|
||||||
- JSON metadata for internal use
|
- JSON metadata for internal use
|
||||||
- The series directory for the source
|
- The series directory for the source
|
||||||
- The NFO file for the source (if specified)
|
- The NFO file for the source (if specified)
|
||||||
|
|
@ -59,6 +60,7 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorker do
|
||||||
%{
|
%{
|
||||||
series_directory: series_directory,
|
series_directory: series_directory,
|
||||||
nfo_filepath: store_source_nfo(source, series_directory, source_metadata),
|
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)
|
metadata: Map.merge(%{metadata_filepath: source_metadata_filepath}, metadata_image_attrs)
|
||||||
},
|
},
|
||||||
source_image_attrs
|
source_image_attrs
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ defmodule Pinchflat.Sources.Source do
|
||||||
collection_id
|
collection_id
|
||||||
collection_type
|
collection_type
|
||||||
custom_name
|
custom_name
|
||||||
|
description
|
||||||
nfo_filepath
|
nfo_filepath
|
||||||
poster_filepath
|
poster_filepath
|
||||||
fanart_filepath
|
fanart_filepath
|
||||||
|
|
@ -55,6 +56,7 @@ defmodule Pinchflat.Sources.Source do
|
||||||
|
|
||||||
schema "sources" do
|
schema "sources" do
|
||||||
field :custom_name, :string
|
field :custom_name, :string
|
||||||
|
field :description, :string
|
||||||
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]
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -50,6 +50,23 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do
|
||||||
end
|
end
|
||||||
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
|
describe "perform/1 when testing metadata storage" do
|
||||||
test "sets metadata location for source" do
|
test "sets metadata location for source" do
|
||||||
stub(YtDlpRunnerMock, :run, fn
|
stub(YtDlpRunnerMock, :run, fn
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue