Renamed friendly_name to custom_name
This commit is contained in:
parent
381eaed40a
commit
b65a88cc29
10 changed files with 24 additions and 17 deletions
|
|
@ -15,7 +15,7 @@ defmodule Pinchflat.Sources.Source do
|
||||||
collection_name
|
collection_name
|
||||||
collection_id
|
collection_id
|
||||||
collection_type
|
collection_type
|
||||||
friendly_name
|
custom_name
|
||||||
index_frequency_minutes
|
index_frequency_minutes
|
||||||
download_media
|
download_media
|
||||||
last_indexed_at
|
last_indexed_at
|
||||||
|
|
@ -27,7 +27,7 @@ defmodule Pinchflat.Sources.Source do
|
||||||
collection_name
|
collection_name
|
||||||
collection_id
|
collection_id
|
||||||
collection_type
|
collection_type
|
||||||
friendly_name
|
custom_name
|
||||||
index_frequency_minutes
|
index_frequency_minutes
|
||||||
download_media
|
download_media
|
||||||
original_url
|
original_url
|
||||||
|
|
@ -35,7 +35,7 @@ defmodule Pinchflat.Sources.Source do
|
||||||
)a
|
)a
|
||||||
|
|
||||||
schema "sources" do
|
schema "sources" do
|
||||||
field :friendly_name, :string
|
field :custom_name, :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]
|
||||||
|
|
@ -58,7 +58,7 @@ defmodule Pinchflat.Sources.Source do
|
||||||
def changeset(source, attrs) do
|
def changeset(source, attrs) do
|
||||||
source
|
source
|
||||||
|> cast(attrs, @allowed_fields)
|
|> cast(attrs, @allowed_fields)
|
||||||
|> dynamic_default(:friendly_name, fn cs -> get_field(cs, :collection_name) end)
|
|> dynamic_default(:custom_name, fn cs -> get_field(cs, :collection_name) end)
|
||||||
|> validate_required(@required_fields)
|
|> validate_required(@required_fields)
|
||||||
|> unique_constraint([:collection_id, :media_profile_id])
|
|> unique_constraint([:collection_id, :media_profile_id])
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ defmodule Pinchflat.Profiles.Options.YtDlp.DownloadOptionBuilder do
|
||||||
source = media_item_with_preloads.source
|
source = media_item_with_preloads.source
|
||||||
|
|
||||||
%{
|
%{
|
||||||
"source_friendly_name" => source.friendly_name,
|
"source_custom_name" => source.custom_name,
|
||||||
"source_collection_type" => source.collection_type
|
"source_collection_type" => source.collection_type
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
<section>
|
<section>
|
||||||
<strong>Source:</strong>
|
<strong>Source:</strong>
|
||||||
<.inline_link href={~p"/sources/#{@media_item.source_id}"}>
|
<.inline_link href={~p"/sources/#{@media_item.source_id}"}>
|
||||||
<%= @media_item.source.friendly_name %>
|
<%= @media_item.source.custom_name %>
|
||||||
</.inline_link>
|
</.inline_link>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
<:tab title="Sources">
|
<:tab title="Sources">
|
||||||
<.table rows={@media_profile.sources} table_class="text-black dark:text-white">
|
<.table rows={@media_profile.sources} table_class="text-black dark:text-white">
|
||||||
<:col :let={source} label="Name">
|
<:col :let={source} label="Name">
|
||||||
<%= source.friendly_name || source.collection_name %>
|
<%= source.custom_name || source.collection_name %>
|
||||||
</:col>
|
</:col>
|
||||||
<:col :let={source} label="Type"><%= source.collection_type %></:col>
|
<:col :let={source} label="Type"><%= source.collection_type %></:col>
|
||||||
<:col :let={source} label="Should Download?">
|
<:col :let={source} label="Should Download?">
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
<div class="flex flex-col gap-10 min-w-max">
|
<div class="flex flex-col gap-10 min-w-max">
|
||||||
<.table rows={@sources} table_class="text-black dark:text-white">
|
<.table rows={@sources} table_class="text-black dark:text-white">
|
||||||
<:col :let={source} label="Name">
|
<:col :let={source} label="Name">
|
||||||
<%= source.friendly_name || source.collection_name %>
|
<%= source.custom_name || source.collection_name %>
|
||||||
</:col>
|
</:col>
|
||||||
<:col :let={source} label="Type"><%= source.collection_type %></:col>
|
<:col :let={source} label="Type"><%= source.collection_type %></:col>
|
||||||
<:col :let={source} label="Should Download?">
|
<:col :let={source} label="Should Download?">
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
</.error>
|
</.error>
|
||||||
|
|
||||||
<.input
|
<.input
|
||||||
field={f[:friendly_name]}
|
field={f[:custom_name]}
|
||||||
type="text"
|
type="text"
|
||||||
label="Custom Name"
|
label="Custom Name"
|
||||||
help="Something descriptive. Does not impact indexing or downloading"
|
help="Something descriptive. Does not impact indexing or downloading"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
defmodule Pinchflat.Repo.Migrations.RenameFriendlyNameToCustomName do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
rename table(:sources), :friendly_name, to: :custom_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -9,7 +9,7 @@ defmodule Pinchflat.Profiles.Options.YtDlp.DownloadOptionBuilderTest do
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
media_profile = media_profile_fixture(%{output_path_template: "{{ title }}.%(ext)s"})
|
media_profile = media_profile_fixture(%{output_path_template: "{{ title }}.%(ext)s"})
|
||||||
source = source_fixture(%{media_profile_id: media_profile.id, friendly_name: "my source"})
|
source = source_fixture(%{media_profile_id: media_profile.id, custom_name: "my source"})
|
||||||
media_item = Repo.preload(media_item_fixture(source_id: source.id), source: :media_profile)
|
media_item = Repo.preload(media_item_fixture(source_id: source.id), source: :media_profile)
|
||||||
|
|
||||||
{:ok, media_item: media_item}
|
{:ok, media_item: media_item}
|
||||||
|
|
@ -24,11 +24,11 @@ defmodule Pinchflat.Profiles.Options.YtDlp.DownloadOptionBuilderTest do
|
||||||
|
|
||||||
test "it respects custom output path options", %{media_item: media_item} do
|
test "it respects custom output path options", %{media_item: media_item} do
|
||||||
media_item =
|
media_item =
|
||||||
update_media_profile_attribute(media_item, %{output_path_template: "{{ source_friendly_name }}.%(ext)s"})
|
update_media_profile_attribute(media_item, %{output_path_template: "{{ source_custom_name }}.%(ext)s"})
|
||||||
|
|
||||||
assert {:ok, res} = DownloadOptionBuilder.build(media_item)
|
assert {:ok, res} = DownloadOptionBuilder.build(media_item)
|
||||||
|
|
||||||
assert {:output, "/tmp/test/videos/#{media_item.source.friendly_name}.%(ext)s"} in res
|
assert {:output, "/tmp/test/videos/#{media_item.source.custom_name}.%(ext)s"} in res
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,18 +66,18 @@ defmodule Pinchflat.SourcesTest do
|
||||||
assert String.starts_with?(source.collection_id, "some_playlist_id_")
|
assert String.starts_with?(source.collection_id, "some_playlist_id_")
|
||||||
end
|
end
|
||||||
|
|
||||||
test "you can specify a custom friendly_name" do
|
test "you can specify a custom custom_name" do
|
||||||
expect(YtDlpRunnerMock, :run, &channel_mock/3)
|
expect(YtDlpRunnerMock, :run, &channel_mock/3)
|
||||||
|
|
||||||
valid_attrs = %{
|
valid_attrs = %{
|
||||||
media_profile_id: media_profile_fixture().id,
|
media_profile_id: media_profile_fixture().id,
|
||||||
original_url: "https://www.youtube.com/channel/abc123",
|
original_url: "https://www.youtube.com/channel/abc123",
|
||||||
friendly_name: "some custom name"
|
custom_name: "some custom name"
|
||||||
}
|
}
|
||||||
|
|
||||||
assert {:ok, %Source{} = source} = Sources.create_source(valid_attrs)
|
assert {:ok, %Source{} = source} = Sources.create_source(valid_attrs)
|
||||||
|
|
||||||
assert source.friendly_name == "some custom name"
|
assert source.custom_name == "some custom name"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "friendly name is pulled from collection_name if not specified" do
|
test "friendly name is pulled from collection_name if not specified" do
|
||||||
|
|
@ -90,7 +90,7 @@ defmodule Pinchflat.SourcesTest do
|
||||||
|
|
||||||
assert {:ok, %Source{} = source} = Sources.create_source(valid_attrs)
|
assert {:ok, %Source{} = source} = Sources.create_source(valid_attrs)
|
||||||
|
|
||||||
assert source.friendly_name == "some channel name"
|
assert source.custom_name == "some channel name"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "collection_type is inferred from source details" do
|
test "collection_type is inferred from source details" do
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ defmodule Pinchflat.SourcesFixtures do
|
||||||
collection_name: "Source ##{:rand.uniform(1_000_000)}",
|
collection_name: "Source ##{:rand.uniform(1_000_000)}",
|
||||||
collection_id: Base.encode16(:crypto.hash(:md5, "#{:rand.uniform(1_000_000)}")),
|
collection_id: Base.encode16(:crypto.hash(:md5, "#{:rand.uniform(1_000_000)}")),
|
||||||
collection_type: "channel",
|
collection_type: "channel",
|
||||||
friendly_name: "Cool and good internal name!",
|
custom_name: "Cool and good internal name!",
|
||||||
original_url: "https://www.youtube.com/channel/#{Faker.String.base64(12)}",
|
original_url: "https://www.youtube.com/channel/#{Faker.String.base64(12)}",
|
||||||
media_profile_id: ProfilesFixtures.media_profile_fixture().id,
|
media_profile_id: ProfilesFixtures.media_profile_fixture().id,
|
||||||
index_frequency_minutes: 60
|
index_frequency_minutes: 60
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue