From 0a5eb3db3c707707a2366f0df5db3024d9b6ff27 Mon Sep 17 00:00:00 2001 From: phyzical <5182053+phyzical@users.noreply.github.com> Date: Fri, 8 Aug 2025 16:27:31 +0800 Subject: [PATCH 1/7] add logic to extract and set a video as 'public' --- lib/pinchflat/yt_dlp/media.ex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pinchflat/yt_dlp/media.ex b/lib/pinchflat/yt_dlp/media.ex index 9abf8e5..7c5c524 100644 --- a/lib/pinchflat/yt_dlp/media.ex +++ b/lib/pinchflat/yt_dlp/media.ex @@ -115,7 +115,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 +135,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 From bdf65bb0a0191a6d33918059c4d049ced48788c5 Mon Sep 17 00:00:00 2001 From: phyzical <5182053+phyzical@users.noreply.github.com> Date: Fri, 8 Aug 2025 16:29:46 +0800 Subject: [PATCH 2/7] update source schema with members contextn behaviour --- lib/pinchflat/sources/source.ex | 3 +++ 1 file changed, 3 insertions(+) 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 From c2a2947891c5a60dcabe69b967f42ad646b21c93 Mon Sep 17 00:00:00 2001 From: phyzical <5182053+phyzical@users.noreply.github.com> Date: Fri, 8 Aug 2025 16:30:10 +0800 Subject: [PATCH 3/7] add logic to filter out member only videos in the pending section --- lib/pinchflat/media/media_query.ex | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/pinchflat/media/media_query.ex b/lib/pinchflat/media/media_query.ex index 840e82c..7887d42 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 or + ) + 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() ) From 39621184c2c17907d9693e3e213980eb1e039a6d Mon Sep 17 00:00:00 2001 From: phyzical <5182053+phyzical@users.noreply.github.com> Date: Fri, 8 Aug 2025 16:30:35 +0800 Subject: [PATCH 4/7] update the source to support the new enum --- .../sources/source_html/source_form.html.heex | 11 +++++++++++ 1 file changed, 11 insertions(+) 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" From 95fc6000765cc816a751dbcecc5f17c20335f068 Mon Sep 17 00:00:00 2001 From: phyzical <5182053+phyzical@users.noreply.github.com> Date: Sun, 10 Aug 2025 00:34:57 +0800 Subject: [PATCH 5/7] fix compile --- lib/pinchflat/media/media_query.ex | 2 +- lib/pinchflat/yt_dlp/media.ex | 6 ++++-- lib/pinchflat_web/controllers/sources/source_html.ex | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/pinchflat/media/media_query.ex b/lib/pinchflat/media/media_query.ex index 7887d42..f3dcf4b 100644 --- a/lib/pinchflat/media/media_query.ex +++ b/lib/pinchflat/media/media_query.ex @@ -74,7 +74,7 @@ defmodule Pinchflat.Media.MediaQuery do # 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 or + source.members_content_behaviour == "exclude" and mi.public == true ) end diff --git a/lib/pinchflat/yt_dlp/media.ex b/lib/pinchflat/yt_dlp/media.ex index 7c5c524..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__ 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}, From f5fe55434564ba2e074128f846aa1967b1760291 Mon Sep 17 00:00:00 2001 From: phyzical <5182053+phyzical@users.noreply.github.com> Date: Sun, 10 Aug 2025 00:35:35 +0800 Subject: [PATCH 6/7] add migration --- ...0810213740_add_member_content_behaviour_to_source.exs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 priv/repo/migrations/20250810213740_add_member_content_behaviour_to_source.exs 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 From 12864c30fef102846897aa77b23bb322ea7b49c2 Mon Sep 17 00:00:00 2001 From: phyzical <5182053+phyzical@users.noreply.github.com> Date: Mon, 11 Aug 2025 11:50:50 +0800 Subject: [PATCH 7/7] fix qyuery --- lib/pinchflat/media/media_query.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pinchflat/media/media_query.ex b/lib/pinchflat/media/media_query.ex index f3dcf4b..d031be0 100644 --- a/lib/pinchflat/media/media_query.ex +++ b/lib/pinchflat/media/media_query.ex @@ -73,8 +73,8 @@ defmodule Pinchflat.Media.MediaQuery do [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 + (source.members_content_behaviour == :only and mi.public == false) or + (source.members_content_behaviour == :exclude and mi.public == true) ) end