diff --git a/lib/pinchflat/media_source/source.ex b/lib/pinchflat/media_source/source.ex index ed77c7b..6282e28 100644 --- a/lib/pinchflat/media_source/source.ex +++ b/lib/pinchflat/media_source/source.ex @@ -15,7 +15,7 @@ defmodule Pinchflat.Sources.Source do collection_name collection_id collection_type - friendly_name + custom_name index_frequency_minutes download_media last_indexed_at @@ -27,7 +27,7 @@ defmodule Pinchflat.Sources.Source do collection_name collection_id collection_type - friendly_name + custom_name index_frequency_minutes download_media original_url @@ -35,7 +35,7 @@ defmodule Pinchflat.Sources.Source do )a schema "sources" do - field :friendly_name, :string + field :custom_name, :string field :collection_name, :string field :collection_id, :string field :collection_type, Ecto.Enum, values: [:channel, :playlist] @@ -58,7 +58,7 @@ defmodule Pinchflat.Sources.Source do def changeset(source, attrs) do source |> 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) |> unique_constraint([:collection_id, :media_profile_id]) end diff --git a/lib/pinchflat/profiles/options/yt_dlp/download_option_builder.ex b/lib/pinchflat/profiles/options/yt_dlp/download_option_builder.ex index fd12193..e9b37cf 100644 --- a/lib/pinchflat/profiles/options/yt_dlp/download_option_builder.ex +++ b/lib/pinchflat/profiles/options/yt_dlp/download_option_builder.ex @@ -110,7 +110,7 @@ defmodule Pinchflat.Profiles.Options.YtDlp.DownloadOptionBuilder do source = media_item_with_preloads.source %{ - "source_friendly_name" => source.friendly_name, + "source_custom_name" => source.custom_name, "source_collection_type" => source.collection_type } end diff --git a/lib/pinchflat_web/controllers/media_items/media_item_html/show.html.heex b/lib/pinchflat_web/controllers/media_items/media_item_html/show.html.heex index 95da677..8056359 100644 --- a/lib/pinchflat_web/controllers/media_items/media_item_html/show.html.heex +++ b/lib/pinchflat_web/controllers/media_items/media_item_html/show.html.heex @@ -17,7 +17,7 @@
Source: <.inline_link href={~p"/sources/#{@media_item.source_id}"}> - <%= @media_item.source.friendly_name %> + <%= @media_item.source.custom_name %>
diff --git a/lib/pinchflat_web/controllers/media_profiles/media_profile_html/show.html.heex b/lib/pinchflat_web/controllers/media_profiles/media_profile_html/show.html.heex index 7cdb2df..a7e5b1f 100644 --- a/lib/pinchflat_web/controllers/media_profiles/media_profile_html/show.html.heex +++ b/lib/pinchflat_web/controllers/media_profiles/media_profile_html/show.html.heex @@ -50,7 +50,7 @@ <:tab title="Sources"> <.table rows={@media_profile.sources} table_class="text-black dark:text-white"> <:col :let={source} label="Name"> - <%= source.friendly_name || source.collection_name %> + <%= source.custom_name || source.collection_name %> <:col :let={source} label="Type"><%= source.collection_type %> <:col :let={source} label="Should Download?"> diff --git a/lib/pinchflat_web/controllers/sources/source_html/index.html.heex b/lib/pinchflat_web/controllers/sources/source_html/index.html.heex index 3dbfec2..0b3f743 100644 --- a/lib/pinchflat_web/controllers/sources/source_html/index.html.heex +++ b/lib/pinchflat_web/controllers/sources/source_html/index.html.heex @@ -14,7 +14,7 @@
<.table rows={@sources} table_class="text-black dark:text-white"> <:col :let={source} label="Name"> - <%= source.friendly_name || source.collection_name %> + <%= source.custom_name || source.collection_name %> <:col :let={source} label="Type"><%= source.collection_type %> <:col :let={source} label="Should Download?"> 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 c4f8f70..f7f5fe0 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 @@ -4,7 +4,7 @@ <.input - field={f[:friendly_name]} + field={f[:custom_name]} type="text" label="Custom Name" help="Something descriptive. Does not impact indexing or downloading" diff --git a/priv/repo/migrations/20240302194115_rename_friendly_name_to_custom_name.exs b/priv/repo/migrations/20240302194115_rename_friendly_name_to_custom_name.exs new file mode 100644 index 0000000..16bfba5 --- /dev/null +++ b/priv/repo/migrations/20240302194115_rename_friendly_name_to_custom_name.exs @@ -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 diff --git a/test/pinchflat/profiles/options/yt_dlp/download_option_builder_test.exs b/test/pinchflat/profiles/options/yt_dlp/download_option_builder_test.exs index 357b072..38e1ea0 100644 --- a/test/pinchflat/profiles/options/yt_dlp/download_option_builder_test.exs +++ b/test/pinchflat/profiles/options/yt_dlp/download_option_builder_test.exs @@ -9,7 +9,7 @@ defmodule Pinchflat.Profiles.Options.YtDlp.DownloadOptionBuilderTest do setup do 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) {: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 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 {: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 diff --git a/test/pinchflat/sources_test.exs b/test/pinchflat/sources_test.exs index 9fccb70..2426c52 100644 --- a/test/pinchflat/sources_test.exs +++ b/test/pinchflat/sources_test.exs @@ -66,18 +66,18 @@ defmodule Pinchflat.SourcesTest do assert String.starts_with?(source.collection_id, "some_playlist_id_") 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) valid_attrs = %{ media_profile_id: media_profile_fixture().id, 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 source.friendly_name == "some custom name" + assert source.custom_name == "some custom name" end 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 source.friendly_name == "some channel name" + assert source.custom_name == "some channel name" end test "collection_type is inferred from source details" do diff --git a/test/support/fixtures/sources_fixtures.ex b/test/support/fixtures/sources_fixtures.ex index 2a8d8ad..5c25ffc 100644 --- a/test/support/fixtures/sources_fixtures.ex +++ b/test/support/fixtures/sources_fixtures.ex @@ -19,7 +19,7 @@ defmodule Pinchflat.SourcesFixtures do collection_name: "Source ##{:rand.uniform(1_000_000)}", collection_id: Base.encode16(:crypto.hash(:md5, "#{:rand.uniform(1_000_000)}")), 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)}", media_profile_id: ProfilesFixtures.media_profile_fixture().id, index_frequency_minutes: 60