Added language and format selection to quality option builder
This commit is contained in:
parent
edae3174b0
commit
0579694203
1 changed files with 25 additions and 2 deletions
|
|
@ -2,10 +2,15 @@ defmodule Pinchflat.Downloading.QualityOptionBuilder do
|
|||
alias Pinchflat.Settings
|
||||
alias Pinchflat.Profiles.MediaProfile
|
||||
|
||||
# TODO: test
|
||||
def build(%MediaProfile{preferred_resolution: :audio, media_container: container}) do
|
||||
acodec = Settings.get!(:audio_codec_preference)
|
||||
|
||||
[:extract_audio, format_sort: "+acodec:#{acodec}", audio_format: container || "best"]
|
||||
[
|
||||
:extract_audio,
|
||||
format_sort: "+acodec:#{acodec}",
|
||||
audio_format: container || "best"
|
||||
] ++ build_format_string(nil)
|
||||
end
|
||||
|
||||
def build(%MediaProfile{preferred_resolution: resolution_atom, media_container: container}) do
|
||||
|
|
@ -17,6 +22,24 @@ defmodule Pinchflat.Downloading.QualityOptionBuilder do
|
|||
# Since Plex doesn't support reading metadata from MKV
|
||||
remux_video: container || "mp4",
|
||||
format_sort: "res:#{resolution_string},+codec:#{vcodec}:#{acodec}"
|
||||
]
|
||||
] ++ build_format_string(nil)
|
||||
end
|
||||
|
||||
# TODO: pass in the entire media profile once we have the language preference column
|
||||
# TODO: test
|
||||
defp build_format_string(language_preference) do
|
||||
if language_preference do
|
||||
"bestvideo*+bestaudio[#{build_format_modifier(language_preference)}]/bestvideo*+bestaudio/best"
|
||||
else
|
||||
"bestvideo*+bestaudio/best"
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: test
|
||||
defp build_format_modifier("original"), do: "format_note*=original"
|
||||
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.
|
||||
defp build_format_modifier(language_code), do: "language^=#{language_code}"
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue