Added fast_index field and adds it to source form

This commit is contained in:
Kieran Eglin 2024-03-09 13:30:01 -08:00
parent 45677a8012
commit 45329f7e99
No known key found for this signature in database
GPG key ID: 193984967FCF432D
4 changed files with 58 additions and 3 deletions

View file

@ -17,6 +17,7 @@ defmodule Pinchflat.Sources.Source do
collection_type collection_type
custom_name custom_name
index_frequency_minutes index_frequency_minutes
fast_index
download_media download_media
last_indexed_at last_indexed_at
original_url original_url
@ -29,6 +30,7 @@ defmodule Pinchflat.Sources.Source do
collection_type collection_type
custom_name custom_name
index_frequency_minutes index_frequency_minutes
fast_index
download_media download_media
original_url original_url
media_profile_id media_profile_id
@ -40,6 +42,7 @@ defmodule Pinchflat.Sources.Source do
field :collection_id, :string field :collection_id, :string
field :collection_type, Ecto.Enum, values: [:channel, :playlist] field :collection_type, Ecto.Enum, values: [:channel, :playlist]
field :index_frequency_minutes, :integer, default: 60 * 24 field :index_frequency_minutes, :integer, default: 60 * 24
field :fast_index, :boolean, default: false
field :download_media, :boolean, default: true field :download_media, :boolean, default: true
field :last_indexed_at, :utc_datetime field :last_indexed_at, :utc_datetime
# This should only be used for user reference going forward # This should only be used for user reference going forward

View file

@ -0,0 +1,21 @@
<aside>
<h2 class="text-xl font-bold mb-2">What is fast indexing (experimental)?</h2>
<section class="ml-2 md:ml-4 mb-4 max-w-prose">
<p>
Indexing is the act of scanning a channel or playlist (aka: source) for new media.
</p>
<p class="mt-2">
Normal indexing uses <code class="text-sm">yt-dlp</code>
to scan the entire source on your specified frequency, but it's very slow for large sources. This is the most accurate way to find uploaded media with the tradeoff being that pairing a large source with a low index frequency will result in you spending most of your time indexing. Only so many indexing operations can be running at the same time, so this can impact your other source's ability to index.
</p>
<p class="mt-2">
Fast indexing takes a different approach. It still does an initial scan the slow way but after that it uses an RSS feed to frequently check for new videos. This has the potential to be hundreds of times faster, but it can miss videos if the uploader un-privates an old video or uploads dozens of videos in the space of a few minutes. It works well for most channels or playlists but it's not perfect.
</p>
<p class="mt-2">
To make up for this limitation, a normal index is still run monthly to catch any videos that were missed by fast indexing. Fast indexing overrides the normal index frequency.
</p>
<p class="mt-2">
Fast indexing is experimental so please report any issues on GitHub. It's only recommended for sources with over 200-ish videos and that upload frequently. Not recommended for small or inactive sources.
</p>
</section>
</aside>

View file

@ -3,6 +3,10 @@
Oops, something went wrong! Please check the errors below. Oops, something went wrong! Please check the errors below.
</.error> </.error>
<h3 class="mt-8 text-2xl text-black dark:text-white">
General Options
</h3>
<.input <.input
field={f[:custom_name]} field={f[:custom_name]}
type="text" type="text"
@ -19,6 +23,10 @@
label="Media Profile" label="Media Profile"
/> />
<h3 class="mt-8 text-2xl text-black dark:text-white">
Indexing Options
</h3>
<.input <.input
field={f[:index_frequency_minutes]} field={f[:index_frequency_minutes]}
options={friendly_index_frequencies()} options={friendly_index_frequencies()}
@ -27,6 +35,18 @@
help="Time between one index of this source finishing and the next one starting. Setting to 'On Create' will still run an initial index but no subsequent ones" help="Time between one index of this source finishing and the next one starting. Setting to 'On Create' will still run an initial index but no subsequent ones"
/> />
<%!-- TODO: use Alpine to disable the index frequency when fast indexing is enabled --%>
<.input
field={f[:fast_index]}
type="toggle"
label="Use Fast Indexing?"
help="Experimental. Ignores 'Index Frequency'. Recommended for large channels that upload frequently. See below for more info"
/>
<h3 class="mt-8 text-2xl text-black dark:text-white">
Downloading Options
</h3>
<.input <.input
field={f[:download_media]} field={f[:download_media]}
type="toggle" type="toggle"
@ -34,7 +54,9 @@
help="Unchecking still indexes media but it won't be downloaded until you enable this option" help="Unchecking still indexes media but it won't be downloaded until you enable this option"
/> />
<:actions> <.button class="my-10 sm:mb-7.5 w-full sm:w-auto">Save Source</.button>
<.button class="my-10 sm:mb-7.5 w-full sm:w-auto">Save Source</.button>
</:actions> <div class="rounded-sm dark:bg-meta-4 p-4 md:p-6 mb-5">
<.fast_indexing_help />
</div>
</.simple_form> </.simple_form>

View file

@ -0,0 +1,9 @@
defmodule Pinchflat.Repo.Migrations.AddFastIndexToSources do
use Ecto.Migration
def change do
alter table(:sources) do
add :fast_index, :boolean, null: false, default: false
end
end
end