diff --git a/lib/pinchflat/media/media_query.ex b/lib/pinchflat/media/media_query.ex index 840e82c..d031be0 100644 --- a/lib/pinchflat/media/media_query.ex +++ b/lib/pinchflat/media/media_query.ex @@ -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() ) diff --git a/lib/pinchflat/sources/source.ex b/lib/pinchflat/sources/source.ex index 00b4776..5f6f058 100644 --- a/lib/pinchflat/sources/source.ex +++ b/lib/pinchflat/sources/source.ex @@ -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 diff --git a/lib/pinchflat/yt_dlp/media.ex b/lib/pinchflat/yt_dlp/media.ex index 9abf8e5..f4583b1 100644 --- a/lib/pinchflat/yt_dlp/media.ex +++ b/lib/pinchflat/yt_dlp/media.ex @@ -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 diff --git a/lib/pinchflat_web/controllers/sources/source_html.ex b/lib/pinchflat_web/controllers/sources/source_html.ex index 00ab498..39f9867 100644 --- a/lib/pinchflat_web/controllers/sources/source_html.ex +++ b/lib/pinchflat_web/controllers/sources/source_html.ex @@ -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}, 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 014d597..c561ca3 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 @@ -79,6 +79,17 @@ Downloading Options +
+ <.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]))" + /> +
+ <.input field={f[:download_media]} type="toggle" diff --git a/priv/repo/migrations/20250810213740_add_member_content_behaviour_to_source.exs b/priv/repo/migrations/20250810213740_add_member_content_behaviour_to_source.exs new file mode 100644 index 0000000..4faf0f3 --- /dev/null +++ b/priv/repo/migrations/20250810213740_add_member_content_behaviour_to_source.exs @@ -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