From a2cc4e78ff422311a4f0cf8e84c7e03e4a6872b0 Mon Sep 17 00:00:00 2001 From: Kieran Eglin Date: Wed, 27 Nov 2024 10:23:05 -0800 Subject: [PATCH] Adds UI for audio_track to the media profile form --- lib/pinchflat/downloading/quality_option_builder.ex | 5 ++++- .../media_profile_html/media_profile_form.html.heex | 10 ++++++++++ .../downloading/quality_option_builder_test.exs | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/pinchflat/downloading/quality_option_builder.ex b/lib/pinchflat/downloading/quality_option_builder.ex index 1884502..cb89435 100644 --- a/lib/pinchflat/downloading/quality_option_builder.ex +++ b/lib/pinchflat/downloading/quality_option_builder.ex @@ -54,8 +54,11 @@ defmodule Pinchflat.Downloading.QualityOptionBuilder do end end + # Reminder to self: this conflicts with `--extractor-args "youtube:lang="` + # since that will translate the format_notes as well, which means they may not match. + # At least that's what happens now - worth a re-check if I have to come back to this defp build_format_modifier("original"), do: "format_note*=original" - defp build_format_modifier("default"), do: "format_note*=(default)" + defp build_format_modifier("default"), do: "format_note*='(default)'" # This uses the carat to anchor the language to the beginning of the string # since that's what's needed to match `en` to `en-US` and `en-GB`, etc. The user # can always specify the full language code if they want. diff --git a/lib/pinchflat_web/controllers/media_profiles/media_profile_html/media_profile_form.html.heex b/lib/pinchflat_web/controllers/media_profiles/media_profile_html/media_profile_form.html.heex index 18e2ed1..fb83857 100644 --- a/lib/pinchflat_web/controllers/media_profiles/media_profile_html/media_profile_form.html.heex +++ b/lib/pinchflat_web/controllers/media_profiles/media_profile_html/media_profile_form.html.heex @@ -125,6 +125,16 @@ /> +
+ <.input + field={f[:audio_track]} + placeholder="de" + type="text" + label="Audio Track Language" + help="Only works if there are multiple audio tracks. Use either a language code, 'original' for the original audio track, or 'default' for YouTube's preference. Or just leave it blank" + /> +
+

Thumbnail Options

diff --git a/test/pinchflat/downloading/quality_option_builder_test.exs b/test/pinchflat/downloading/quality_option_builder_test.exs index cdf482b..84624f0 100644 --- a/test/pinchflat/downloading/quality_option_builder_test.exs +++ b/test/pinchflat/downloading/quality_option_builder_test.exs @@ -20,7 +20,7 @@ defmodule Pinchflat.Downloading.QualityOptionBuilderTest do assert res = QualityOptionBuilder.build(media_profile) - assert {:format, "bestvideo+bestaudio[format_note*=(default)]/bestvideo*+bestaudio/best"} in res + assert {:format, "bestvideo+bestaudio[format_note*='(default)']/bestvideo*+bestaudio/best"} in res end test "includes format options if audio_track is set to a language code" do