Add resolution to download option builder
This commit is contained in:
parent
4c5ae5dc4d
commit
748e512c40
2 changed files with 22 additions and 0 deletions
|
|
@ -26,6 +26,7 @@ defmodule Pinchflat.Profiles.Options.YtDlp.DownloadOptionBuilder do
|
||||||
subtitle_options(media_profile) ++
|
subtitle_options(media_profile) ++
|
||||||
thumbnail_options(media_profile) ++
|
thumbnail_options(media_profile) ++
|
||||||
metadata_options(media_profile) ++
|
metadata_options(media_profile) ++
|
||||||
|
quality_options(media_profile) ++
|
||||||
output_options(media_profile)
|
output_options(media_profile)
|
||||||
|
|
||||||
{:ok, built_options}
|
{:ok, built_options}
|
||||||
|
|
@ -87,6 +88,19 @@ defmodule Pinchflat.Profiles.Options.YtDlp.DownloadOptionBuilder do
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp quality_options(media_profile) do
|
||||||
|
codec_options = "+codec:avc:m4a"
|
||||||
|
|
||||||
|
case media_profile.preferred_resolution do
|
||||||
|
:"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}"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp output_options(media_profile) do
|
defp output_options(media_profile) do
|
||||||
{:ok, output_path} = OutputPathBuilder.build(media_profile.output_path_template)
|
{:ok, output_path} = OutputPathBuilder.build(media_profile.output_path_template)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -158,4 +158,12 @@ defmodule Pinchflat.Profiles.Options.YtDlp.DownloadOptionBuilderTest do
|
||||||
refute :embed_metadata in res
|
refute :embed_metadata in res
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "build/1 when testing quality options" do
|
||||||
|
test "it includes quality options" do
|
||||||
|
assert {:ok, res} = DownloadOptionBuilder.build(@media_profile)
|
||||||
|
|
||||||
|
assert {:format_sort, "res:1080,+codec:avc:m4a"} in res
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue