Moved quality options to their own module
This commit is contained in:
parent
bfb27427ce
commit
edae3174b0
2 changed files with 24 additions and 22 deletions
|
|
@ -4,10 +4,10 @@ defmodule Pinchflat.Downloading.DownloadOptionBuilder do
|
||||||
"""
|
"""
|
||||||
|
|
||||||
alias Pinchflat.Sources
|
alias Pinchflat.Sources
|
||||||
alias Pinchflat.Settings
|
|
||||||
alias Pinchflat.Sources.Source
|
alias Pinchflat.Sources.Source
|
||||||
alias Pinchflat.Media.MediaItem
|
alias Pinchflat.Media.MediaItem
|
||||||
alias Pinchflat.Downloading.OutputPathBuilder
|
alias Pinchflat.Downloading.OutputPathBuilder
|
||||||
|
alias Pinchflat.Downloading.QualityOptionBuilder
|
||||||
|
|
||||||
alias Pinchflat.Utils.FilesystemUtils, as: FSUtils
|
alias Pinchflat.Utils.FilesystemUtils, as: FSUtils
|
||||||
|
|
||||||
|
|
@ -142,27 +142,7 @@ defmodule Pinchflat.Downloading.DownloadOptionBuilder do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp quality_options(media_profile) do
|
defp quality_options(media_profile) do
|
||||||
vcodec = Settings.get!(:video_codec_preference)
|
QualityOptionBuilder.build(media_profile)
|
||||||
acodec = Settings.get!(:audio_codec_preference)
|
|
||||||
container = media_profile.media_container
|
|
||||||
|
|
||||||
case media_profile.preferred_resolution do
|
|
||||||
# Also be aware that :audio disabled all embedding options for subtitles
|
|
||||||
:audio ->
|
|
||||||
[:extract_audio, format_sort: "+acodec:#{acodec}", audio_format: container || "best"]
|
|
||||||
|
|
||||||
resolution_atom ->
|
|
||||||
{resolution_string, _} =
|
|
||||||
resolution_atom
|
|
||||||
|> Atom.to_string()
|
|
||||||
|> Integer.parse()
|
|
||||||
|
|
||||||
[
|
|
||||||
# Since Plex doesn't support reading metadata from MKV
|
|
||||||
remux_video: container || "mp4",
|
|
||||||
format_sort: "res:#{resolution_string},+codec:#{vcodec}:#{acodec}"
|
|
||||||
]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
defp sponsorblock_options(media_profile) do
|
defp sponsorblock_options(media_profile) do
|
||||||
|
|
|
||||||
22
lib/pinchflat/downloading/quality_option_builder.ex
Normal file
22
lib/pinchflat/downloading/quality_option_builder.ex
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
defmodule Pinchflat.Downloading.QualityOptionBuilder do
|
||||||
|
alias Pinchflat.Settings
|
||||||
|
alias Pinchflat.Profiles.MediaProfile
|
||||||
|
|
||||||
|
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"]
|
||||||
|
end
|
||||||
|
|
||||||
|
def build(%MediaProfile{preferred_resolution: resolution_atom, media_container: container}) do
|
||||||
|
vcodec = Settings.get!(:video_codec_preference)
|
||||||
|
acodec = Settings.get!(:audio_codec_preference)
|
||||||
|
{resolution_string, _} = resolution_atom |> Atom.to_string() |> Integer.parse()
|
||||||
|
|
||||||
|
[
|
||||||
|
# Since Plex doesn't support reading metadata from MKV
|
||||||
|
remux_video: container || "mp4",
|
||||||
|
format_sort: "res:#{resolution_string},+codec:#{vcodec}:#{acodec}"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue