Improve audio-only download (#74)
* Improved quality from auto-only download; enables thumbnail and data embedding for audio * Updated UI to reflect new audio behaviour
This commit is contained in:
@@ -61,11 +61,11 @@ defmodule Pinchflat.YtDlp.DownloadOptionBuilder do
|
||||
mapped_struct = Map.from_struct(media_profile)
|
||||
|
||||
Enum.reduce(mapped_struct, [], fn attr, acc ->
|
||||
case {attr, media_profile} do
|
||||
{{:download_thumbnail, true}, _} ->
|
||||
case attr do
|
||||
{:download_thumbnail, true} ->
|
||||
acc ++ [:write_thumbnail, convert_thumbnail: "jpg"]
|
||||
|
||||
{{:embed_thumbnail, true}, %{preferred_resolution: pr}} when pr != :audio ->
|
||||
{:embed_thumbnail, true} ->
|
||||
acc ++ [:embed_thumbnail]
|
||||
|
||||
_ ->
|
||||
@@ -78,31 +78,26 @@ defmodule Pinchflat.YtDlp.DownloadOptionBuilder do
|
||||
mapped_struct = Map.from_struct(media_profile)
|
||||
|
||||
Enum.reduce(mapped_struct, [], fn attr, acc ->
|
||||
case {attr, media_profile} do
|
||||
{{:download_metadata, true}, _} ->
|
||||
acc ++ [:write_info_json, :clean_info_json]
|
||||
|
||||
{{:embed_metadata, true}, %{preferred_resolution: pr}} when pr != :audio ->
|
||||
acc ++ [:embed_metadata]
|
||||
|
||||
_ ->
|
||||
acc
|
||||
case attr do
|
||||
{:download_metadata, true} -> acc ++ [:write_info_json, :clean_info_json]
|
||||
{:embed_metadata, true} -> acc ++ [:embed_metadata]
|
||||
_ -> acc
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
defp quality_options(media_profile) do
|
||||
codec_options = "+codec:avc:m4a"
|
||||
video_codec_options = "+codec:avc:m4a"
|
||||
|
||||
case media_profile.preferred_resolution do
|
||||
# Also be aware that :audio disabled all embedding options for thumbnails, subtitles, and metadata
|
||||
:audio -> [format_sort: "ext", format: "bestaudio"]
|
||||
:"360p" -> [format_sort: "res:360,#{codec_options}"]
|
||||
:"480p" -> [format_sort: "res:480,#{codec_options}"]
|
||||
:"720p" -> [format_sort: "res:720,#{codec_options}"]
|
||||
:"1080p" -> [format_sort: "res:1080,#{codec_options}"]
|
||||
:"1440p" -> [format_sort: "res:1440,#{codec_options}"]
|
||||
:"2160p" -> [format_sort: "res:2160,#{codec_options}"]
|
||||
# Also be aware that :audio disabled all embedding options for subtitles
|
||||
:audio -> [:extract_audio, format: "bestaudio[ext=m4a]"]
|
||||
:"360p" -> [format_sort: "res:360,#{video_codec_options}"]
|
||||
:"480p" -> [format_sort: "res:480,#{video_codec_options}"]
|
||||
:"720p" -> [format_sort: "res:720,#{video_codec_options}"]
|
||||
:"1080p" -> [format_sort: "res:1080,#{video_codec_options}"]
|
||||
:"1440p" -> [format_sort: "res:1440,#{video_codec_options}"]
|
||||
:"2160p" -> [format_sort: "res:2160,#{video_codec_options}"]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@
|
||||
options={friendly_resolution_options()}
|
||||
type="select"
|
||||
label="Preferred Resolution"
|
||||
help="Will grab the closest available resolution if your preferred is not available. Setting to 'Audio Only' negates embedding options."
|
||||
help="Will grab the closest available resolution if your preferred is not available"
|
||||
/>
|
||||
|
||||
<.button class="my-10 sm:mb-7.5 w-full sm:w-auto">Save Media profile</.button>
|
||||
|
||||
Reference in New Issue
Block a user