Adds media container to media_profiles and updates option builder
This commit is contained in:
parent
5cd82f9dd5
commit
78040a1815
5 changed files with 31 additions and 3 deletions
|
|
@ -127,11 +127,12 @@ defmodule Pinchflat.Downloading.DownloadOptionBuilder do
|
|||
defp quality_options(media_profile) do
|
||||
vcodec = Settings.get!(:video_codec_preference)
|
||||
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}"]
|
||||
[:extract_audio, format_sort: "+acodec:#{acodec}", audio_format: container || "best"]
|
||||
|
||||
resolution_atom ->
|
||||
{resolution_string, _} =
|
||||
|
|
@ -141,7 +142,7 @@ defmodule Pinchflat.Downloading.DownloadOptionBuilder do
|
|||
|
||||
[
|
||||
# Since Plex doesn't support reading metadata from MKV
|
||||
remux_video: "mp4",
|
||||
remux_video: container || "mp4",
|
||||
format_sort: "res:#{resolution_string},+codec:#{vcodec}:#{acodec}"
|
||||
]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ defmodule Pinchflat.Profiles.MediaProfile do
|
|||
shorts_behaviour
|
||||
livestream_behaviour
|
||||
preferred_resolution
|
||||
media_container
|
||||
redownload_delay_days
|
||||
marked_for_deletion_at
|
||||
)a
|
||||
|
|
@ -65,6 +66,7 @@ defmodule Pinchflat.Profiles.MediaProfile do
|
|||
field :shorts_behaviour, Ecto.Enum, values: ~w(include exclude only)a, default: :include
|
||||
field :livestream_behaviour, Ecto.Enum, values: ~w(include exclude only)a, default: :include
|
||||
field :preferred_resolution, Ecto.Enum, values: ~w(4320p 2160p 1080p 720p 480p 360p audio)a, default: :"1080p"
|
||||
field :media_container, :string, default: nil
|
||||
|
||||
field :marked_for_deletion_at, :utc_datetime
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 428 KiB After Width: | Height: | Size: 433 KiB |
|
|
@ -0,0 +1,9 @@
|
|||
defmodule Pinchflat.Repo.Migrations.AddMediaContainerToMediaProfiles do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table(:media_profiles) do
|
||||
add :media_container, :string
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -252,7 +252,7 @@ defmodule Pinchflat.Downloading.DownloadOptionBuilderTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "build/1 when testing quality options" do
|
||||
describe "build/1 when testing format options" do
|
||||
test "includes quality options" do
|
||||
resolutions = ["360", "480", "720", "1080", "2160", "4320"]
|
||||
|
||||
|
|
@ -291,6 +291,22 @@ defmodule Pinchflat.Downloading.DownloadOptionBuilderTest do
|
|||
|
||||
assert {:format_sort, "res:1080,+codec:av01:aac"} in res
|
||||
end
|
||||
|
||||
test "includes custom remux target for videos if specified", %{media_item: media_item} do
|
||||
media_item = update_media_profile_attribute(media_item, %{media_container: "mkv"})
|
||||
|
||||
assert {:ok, res} = DownloadOptionBuilder.build(media_item)
|
||||
|
||||
assert {:remux_video, "mkv"} in res
|
||||
end
|
||||
|
||||
test "includes custom format target for audio if specified", %{media_item: media_item} do
|
||||
media_item = update_media_profile_attribute(media_item, %{media_container: "flac", preferred_resolution: :audio})
|
||||
|
||||
assert {:ok, res} = DownloadOptionBuilder.build(media_item)
|
||||
|
||||
assert {:audio_format, "flac"} in res
|
||||
end
|
||||
end
|
||||
|
||||
describe "build/1 when testing sponsorblock options" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue