diff --git a/lib/pinchflat/sources/sources.ex b/lib/pinchflat/sources/sources.ex index 40c0ad0..8842a05 100644 --- a/lib/pinchflat/sources/sources.ex +++ b/lib/pinchflat/sources/sources.ex @@ -41,7 +41,7 @@ defmodule Pinchflat.Sources do case source.cookie_behaviour do :disabled -> false :all_operations -> true - :indexing_only -> operation == :indexing + :when_needed -> operation == :indexing end end 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 94b4110..014d597 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 @@ -86,13 +86,13 @@ help="Unchecking still indexes media but it won't be downloaded until you enable this option" /> - <.input - field={f[:cookie_behaviour]} - options={friendly_cookie_behaviours()} - type="select" - label="Cookie Behaviour" - help="Uses your YouTube cookies for this source (if configured). 'When Needed' tries to minimize cookie usage except for certain indexing and downloading tasks. See docs" - /> + <.input + field={f[:cookie_behaviour]} + options={friendly_cookie_behaviours()} + type="select" + label="Cookie Behaviour" + help="Uses your YouTube cookies for this source (if configured). 'When Needed' tries to minimize cookie usage except for certain indexing and downloading tasks. See docs" + />
<.input diff --git a/test/pinchflat/downloading/media_downloader_test.exs b/test/pinchflat/downloading/media_downloader_test.exs index a2b9a9d..712102d 100644 --- a/test/pinchflat/downloading/media_downloader_test.exs +++ b/test/pinchflat/downloading/media_downloader_test.exs @@ -163,7 +163,7 @@ defmodule Pinchflat.Downloading.MediaDownloaderTest do assert {:ok, _} = MediaDownloader.download_for_media_item(media_item) end - test "does not set use_cookies if the source only uses cookies when indexing" do + test "does not set use_cookies if the source uses cookies when needed" do expect(YtDlpRunnerMock, :run, 3, fn _url, :get_downloadable_status, _opts, _ot, addl -> assert {:use_cookies, false} in addl @@ -177,7 +177,7 @@ defmodule Pinchflat.Downloading.MediaDownloaderTest do {:ok, ""} end) - source = source_fixture(%{cookie_behaviour: :indexing_only}) + source = source_fixture(%{cookie_behaviour: :when_needed}) media_item = media_item_fixture(%{source_id: source.id}) assert {:ok, _} = MediaDownloader.download_for_media_item(media_item) diff --git a/test/pinchflat/fast_indexing/fast_indexing_helpers_test.exs b/test/pinchflat/fast_indexing/fast_indexing_helpers_test.exs index 0cfcb77..77be803 100644 --- a/test/pinchflat/fast_indexing/fast_indexing_helpers_test.exs +++ b/test/pinchflat/fast_indexing/fast_indexing_helpers_test.exs @@ -167,7 +167,7 @@ defmodule Pinchflat.FastIndexing.FastIndexingHelpersTest do assert [%MediaItem{}] = FastIndexingHelpers.index_and_kickoff_downloads(source) end - test "does not set use_cookies if the source only uses cookies when indexing" do + test "does not set use_cookies if the source uses cookies when needed" do expect(HTTPClientMock, :get, fn _url -> {:ok, "test_1"} end) stub(YtDlpRunnerMock, :run, fn _url, :get_media_attributes, _opts, _ot, addl -> @@ -176,7 +176,7 @@ defmodule Pinchflat.FastIndexing.FastIndexingHelpersTest do {:ok, media_attributes_return_fixture()} end) - source = source_fixture(%{cookie_behaviour: :indexing_only}) + source = source_fixture(%{cookie_behaviour: :when_needed}) assert [%MediaItem{}] = FastIndexingHelpers.index_and_kickoff_downloads(source) end diff --git a/test/pinchflat/metadata/metadata_file_helpers_test.exs b/test/pinchflat/metadata/metadata_file_helpers_test.exs index 1b4961b..bacb861 100644 --- a/test/pinchflat/metadata/metadata_file_helpers_test.exs +++ b/test/pinchflat/metadata/metadata_file_helpers_test.exs @@ -110,13 +110,13 @@ defmodule Pinchflat.Metadata.MetadataFileHelpersTest do Helpers.download_and_store_thumbnail_for(media_item) end - test "does not set use_cookies if the source only uses cookies when indexing" do + test "does not set use_cookies if the source uses cookies when needed" do expect(YtDlpRunnerMock, :run, fn _url, :download_thumbnail, _opts, _ot, addl -> assert {:use_cookies, false} in addl {:ok, ""} end) - source = source_fixture(%{cookie_behaviour: :indexing_only}) + source = source_fixture(%{cookie_behaviour: :when_needed}) media_item = Repo.preload(media_item_fixture(%{source_id: source.id}), :source) Helpers.download_and_store_thumbnail_for(media_item) diff --git a/test/pinchflat/metadata/source_metadata_storage_worker_test.exs b/test/pinchflat/metadata/source_metadata_storage_worker_test.exs index e363e65..4965964 100644 --- a/test/pinchflat/metadata/source_metadata_storage_worker_test.exs +++ b/test/pinchflat/metadata/source_metadata_storage_worker_test.exs @@ -259,7 +259,7 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do perform_job(SourceMetadataStorageWorker, %{id: source.id}) end - test "does not set use_cookies if the source only uses cookies when indexing" do + test "does not set use_cookies if the source uses cookies when needed" do expect(YtDlpRunnerMock, :run, 2, fn _url, :get_source_details, _opts, _ot, _addl -> {:ok, source_details_return_fixture()} @@ -270,7 +270,7 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do end) profile = media_profile_fixture(%{download_source_images: true}) - source = source_fixture(media_profile_id: profile.id, cookie_behaviour: :indexing_only) + source = source_fixture(media_profile_id: profile.id, cookie_behaviour: :when_needed) perform_job(SourceMetadataStorageWorker, %{id: source.id}) end @@ -343,7 +343,7 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do perform_job(SourceMetadataStorageWorker, %{id: source.id}) end - test "does not set use_cookies if the source only uses cookies when indexing" do + test "does not set use_cookies if the source uses cookies when needed" do expect(YtDlpRunnerMock, :run, 2, fn _url, :get_source_details, _opts, _ot, addl -> assert {:use_cookies, false} in addl @@ -353,7 +353,7 @@ defmodule Pinchflat.Metadata.SourceMetadataStorageWorkerTest do {:ok, "{}"} end) - source = source_fixture(%{series_directory: nil, cookie_behaviour: :indexing_only}) + source = source_fixture(%{series_directory: nil, cookie_behaviour: :when_needed}) perform_job(SourceMetadataStorageWorker, %{id: source.id}) end diff --git a/test/pinchflat/slow_indexing/slow_indexing_helpers_test.exs b/test/pinchflat/slow_indexing/slow_indexing_helpers_test.exs index e74613f..d37721a 100644 --- a/test/pinchflat/slow_indexing/slow_indexing_helpers_test.exs +++ b/test/pinchflat/slow_indexing/slow_indexing_helpers_test.exs @@ -316,13 +316,13 @@ defmodule Pinchflat.SlowIndexing.SlowIndexingHelpersTest do SlowIndexingHelpers.index_and_enqueue_download_for_media_items(source) end - test "sets use_cookies if the source only uses cookies when indexing" do + test "sets use_cookies if the source uses cookies when needed" do expect(YtDlpRunnerMock, :run, fn _url, :get_media_attributes_for_collection, _opts, _ot, addl_opts -> assert {:use_cookies, true} in addl_opts {:ok, source_attributes_return_fixture()} end) - source = source_fixture(%{cookie_behaviour: :indexing_only}) + source = source_fixture(%{cookie_behaviour: :when_needed}) SlowIndexingHelpers.index_and_enqueue_download_for_media_items(source) end diff --git a/test/pinchflat/sources_test.exs b/test/pinchflat/sources_test.exs index 531cae1..7c347e8 100644 --- a/test/pinchflat/sources_test.exs +++ b/test/pinchflat/sources_test.exs @@ -71,13 +71,13 @@ defmodule Pinchflat.SourcesTest do refute Sources.use_cookies?(source, :downloading) end - test "returns true if the action is indexing and the source is set to :indexing_only" do - source = source_fixture(%{cookie_behaviour: :indexing_only}) + test "returns true if the action is indexing and the source is set to :when_needed" do + source = source_fixture(%{cookie_behaviour: :when_needed}) assert Sources.use_cookies?(source, :indexing) end - test "returns false if the action is downloading and the source is set to :indexing_only" do - source = source_fixture(%{cookie_behaviour: :indexing_only}) + test "returns false if the action is downloading and the source is set to :when_needed" do + source = source_fixture(%{cookie_behaviour: :when_needed}) refute Sources.use_cookies?(source, :downloading) end end @@ -421,7 +421,7 @@ defmodule Pinchflat.SourcesTest do assert {:ok, %Source{}} = Sources.create_source(valid_attrs) end - test "does not set use_cookies if the source only uses cookies when indexing" do + test "does not set use_cookies if the source uses cookies when needed" do expect(YtDlpRunnerMock, :run, fn _url, :get_source_details, _opts, _ot, addl -> refute Keyword.get(addl, :use_cookies) @@ -431,7 +431,7 @@ defmodule Pinchflat.SourcesTest do valid_attrs = %{ media_profile_id: media_profile_fixture().id, original_url: "https://www.youtube.com/channel/abc123", - cookie_behaviour: :indexing_only + cookie_behaviour: :when_needed } assert {:ok, %Source{}} = Sources.create_source(valid_attrs)