This commit is contained in:
Jack 2025-12-17 11:32:55 -05:00 committed by GitHub
commit 3bb9ed255d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 49 additions and 4 deletions

View file

@ -68,6 +68,16 @@ defmodule Pinchflat.Media.MediaQuery do
)
end
def format_matching_source_profile_preference do
dynamic(
[mi, source],
# TODO: this isn't actually correct when not public it could also be unlisted,
# there may be other cases but the exclude case should be correct
(source.members_content_behaviour == :only and mi.public == false) or
(source.members_content_behaviour == :exclude and mi.public == true)
)
end
def matches_source_title_regex do
dynamic(
[mi, source],
@ -131,6 +141,7 @@ defmodule Pinchflat.Media.MediaQuery do
not (^download_prevented()) and
^upload_date_after_source_cutoff() and
^format_matching_profile_preference() and
^format_matching_source_profile_preference() and
^matches_source_title_regex() and
^meets_min_and_max_duration()
)

View file

@ -40,6 +40,7 @@ defmodule Pinchflat.Sources.Source do
marked_for_deletion_at
min_duration_seconds
max_duration_seconds
members_content_behaviour
)a
# Expensive API calls are made when a source is inserted/updated so
@ -80,6 +81,8 @@ defmodule Pinchflat.Sources.Source do
field :fast_index, :boolean, default: false
field :cookie_behaviour, Ecto.Enum, values: [:disabled, :when_needed, :all_operations], default: :disabled
field :download_media, :boolean, default: true
field :members_content_behaviour, Ecto.Enum, values: ~w(include exclude only)a, default: :include
field :last_indexed_at, :utc_datetime
# Only download media items that were published after this date
field :download_cutoff_date, :date

View file

@ -12,7 +12,8 @@ defmodule Pinchflat.YtDlp.Media do
:short_form_content,
:uploaded_at,
:duration_seconds,
:predicted_media_filepath
:predicted_media_filepath,
:public
]
defstruct [
@ -25,7 +26,8 @@ defmodule Pinchflat.YtDlp.Media do
:uploaded_at,
:duration_seconds,
:playlist_index,
:predicted_media_filepath
:predicted_media_filepath,
:public
]
alias __MODULE__
@ -115,7 +117,7 @@ defmodule Pinchflat.YtDlp.Media do
if something is a short via the URL again
"""
def indexing_output_template do
"%(.{id,title,live_status,original_url,description,aspect_ratio,duration,upload_date,timestamp,playlist_index,filename})j"
"%(.{id,title,live_status,original_url,description,aspect_ratio,duration,upload_date,timestamp,playlist_index,filename,availability})j"
end
@doc """
@ -135,7 +137,8 @@ defmodule Pinchflat.YtDlp.Media do
short_form_content: response["original_url"] && short_form_content?(response),
uploaded_at: response["upload_date"] && parse_uploaded_at(response),
playlist_index: response["playlist_index"] || 0,
predicted_media_filepath: response["filename"]
predicted_media_filepath: response["filename"],
public: response["availability"] == "public"
}
end

View file

@ -27,6 +27,14 @@ defmodule PinchflatWeb.Sources.SourceHTML do
]
end
def friendly_format_type_options do
[
{"Include (default)", :include},
{"Exclude", :exclude},
{"Only", :only}
]
end
def friendly_cookie_behaviours do
[
{"Disabled", :disabled},

View file

@ -79,6 +79,17 @@
Downloading Options
</h3>
<section x-data="{ presets: { default: 'include' } }">
<.input
field={f[:members_content_behaviour]}
options={friendly_format_type_options()}
type="select"
label="Include Member Videos"
help="Experimental. Please report any issues on GitHub"
x-init="$watch('selectedPreset', p => p && ($el.value = presets[p]))"
/>
</section>
<.input
field={f[:download_media]}
type="toggle"

View file

@ -0,0 +1,9 @@
defmodule Pinchflat.Repo.Migrations.AddMembersContentBehaviourToSource do
use Ecto.Migration
def change do
alter table(:sources) do
add :members_content_behaviour, :string, null: false, default: "include"
end
end
end