Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/pinchflat/media/media_query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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()
)
Expand Down
3 changes: 3 additions & 0 deletions lib/pinchflat/sources/source.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions lib/pinchflat/yt_dlp/media.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ defmodule Pinchflat.YtDlp.Media do
:short_form_content,
:uploaded_at,
:duration_seconds,
:predicted_media_filepath
:predicted_media_filepath,
:public
]

defstruct [
Expand All @@ -25,7 +26,8 @@ defmodule Pinchflat.YtDlp.Media do
:uploaded_at,
:duration_seconds,
:playlist_index,
:predicted_media_filepath
:predicted_media_filepath,
:public
]

alias __MODULE__
Expand Down Expand Up @@ -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 """
Expand All @@ -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

Expand Down
8 changes: 8 additions & 0 deletions lib/pinchflat_web/controllers/sources/source_html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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