[Feature] Add SponsorBlock-based section removal (#144)

* Added sponsorblock columns to media profile

* Added sponsorblock options to profile form

* Added SB to download options builder
This commit is contained in:
Kieran
2024-03-28 19:02:13 -07:00
committed by GitHub
parent 216e05567f
commit 964ab2f89b
7 changed files with 147 additions and 1 deletions
@@ -32,6 +32,26 @@ defmodule PinchflatWeb.MediaProfiles.MediaProfileHTML do
]
end
def friendly_sponsorblock_options do
[
{"Disabled (default)", "disabled"},
{"Remove Segments", "remove"}
]
end
def frieldly_sponsorblock_categories do
[
{"Sponsor", "sponsor"},
{"Intro/Intermission", "intro"},
{"Outro/Credits", "outro"},
{"Self Promotion", "selfpromo"},
{"Preview/Recap", "preview"},
{"Filler Tangent", "filler"},
{"Interaction Reminder", "interaction"},
{"Non-music Section", "music_offtopic"}
]
end
def custom_output_template_options do
%{
upload_day: nil,
@@ -238,6 +238,36 @@
/>
</section>
<h3 class="mt-10 text-2xl text-black dark:text-white">
SponsorBlock Options
</h3>
<section x-data="{ sponsorblockBehaviour: null }">
<section x-data="{ presets: { default: 'disabled', media_center: 'disabled', audio: 'disabled', archiving: 'disabled' } }">
<.input
field={f[:sponsorblock_behaviour]}
options={friendly_sponsorblock_options()}
type="select"
label="SponsorBlock Behaviour"
help="Action to take when SponsorBlock segments are found. 'Disabled' won't take any action"
x-model="sponsorblockBehaviour"
x-init="
sponsorblockBehaviour = $el.value
$watch('selectedPreset', p => p && ($el.value = presets[p]))
"
/>
</section>
<section x-show="sponsorblockBehaviour !== 'disabled'" x-transition>
<.input
field={f[:sponsorblock_categories]}
options={frieldly_sponsorblock_categories()}
type="checkbox_group"
label="SponsorBlock Categories"
/>
</section>
</section>
<.button class="my-10 sm:mb-7.5 w-full sm:w-auto" rounding="rounded-lg">Save Media profile</.button>
</section>