Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c0885cfaf2 | |||
| b2f39a7b7f | |||
| bada14625b | |||
| 7e4f1a8412 | |||
| 0e537d8f57 | |||
| afe41d2e36 |
+3
-6
@@ -9,18 +9,15 @@
|
|||||||
fix: true,
|
fix: true,
|
||||||
|
|
||||||
## don't retry automatically even if last run resulted in failures
|
## don't retry automatically even if last run resulted in failures
|
||||||
# retry: false,
|
retry: false,
|
||||||
|
|
||||||
## list of tools (see `mix check` docs for a list of default curated tools)
|
## list of tools (see `mix check` docs for a list of default curated tools)
|
||||||
tools: [
|
tools: [
|
||||||
{:compiler, env: %{"MIX_ENV" => "test"}},
|
{:compiler, env: %{"MIX_ENV" => "test"}},
|
||||||
{:formatter, env: %{"MIX_ENV" => "test"}},
|
{:formatter, env: %{"MIX_ENV" => "test"}},
|
||||||
{:sobelow, "mix sobelow --config"},
|
{:sobelow, "mix sobelow --config"},
|
||||||
# TODO: delete these and replace them with builtin ex_unit and formatter tools
|
{:prettier_formatting, "yarn run prettier . --check", fix: "yarn run prettier . --write"},
|
||||||
# once Elixir 1.16.2 is released (see: https://github.com/karolsluszniak/ex_check/issues/41#issuecomment-1921390413)
|
{:npm_test, false}
|
||||||
{:elixir_tests, "mix test"},
|
|
||||||
{:elixir_formatting, "mix format --check-formatted", fix: "mix format"},
|
|
||||||
{:prettier_formatting, "yarn run prettier . --check", fix: "yarn run prettier . --write"}
|
|
||||||
|
|
||||||
## curated tools may be disabled (e.g. the check for compilation warnings)
|
## curated tools may be disabled (e.g. the check for compilation warnings)
|
||||||
# {:compiler, false},
|
# {:compiler, false},
|
||||||
|
|||||||
+13
-3
@@ -1,9 +1,18 @@
|
|||||||
# Extend from the official Elixir image.
|
ARG ELIXIR_VERSION=1.16.2
|
||||||
FROM elixir:latest
|
ARG OTP_VERSION=26.2.2
|
||||||
|
ARG DEBIAN_VERSION=bookworm-20240130
|
||||||
|
ARG DEV_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
|
||||||
|
|
||||||
|
FROM ${DEV_IMAGE}
|
||||||
|
|
||||||
|
# Set the locale deets
|
||||||
|
ENV LANG en_US.UTF-8
|
||||||
|
ENV LANGUAGE en_US:en
|
||||||
|
ENV LC_ALL en_US.UTF-8
|
||||||
|
|
||||||
# Install debian packages
|
# Install debian packages
|
||||||
RUN apt-get update -qq
|
RUN apt-get update -qq
|
||||||
RUN apt-get install -y inotify-tools ffmpeg \
|
RUN apt-get install -y inotify-tools ffmpeg curl git openssh-client \
|
||||||
python3 python3-pip python3-setuptools python3-wheel python3-dev
|
python3 python3-pip python3-setuptools python3-wheel python3-dev
|
||||||
|
|
||||||
# Install nodejs
|
# Install nodejs
|
||||||
@@ -28,6 +37,7 @@ COPY . ./
|
|||||||
RUN chmod +x ./docker-run.dev.sh
|
RUN chmod +x ./docker-run.dev.sh
|
||||||
|
|
||||||
# Install Elixir deps
|
# Install Elixir deps
|
||||||
|
# RUN mix archive.install github hexpm/hex branch latest
|
||||||
RUN mix deps.get
|
RUN mix deps.get
|
||||||
# Gives us iex shell history
|
# Gives us iex shell history
|
||||||
ENV ERL_AFLAGS="-kernel shell_history enabled"
|
ENV ERL_AFLAGS="-kernel shell_history enabled"
|
||||||
|
|||||||
@@ -2,5 +2,3 @@
|
|||||||
- Use a UUID for the media database ID (or at least alongside it)
|
- Use a UUID for the media database ID (or at least alongside it)
|
||||||
- Look into this and its recommended plugins https://hexdocs.pm/ex_check/readme.html
|
- Look into this and its recommended plugins https://hexdocs.pm/ex_check/readme.html
|
||||||
- Add output template option for the source's friendly name
|
- Add output template option for the source's friendly name
|
||||||
- TODO: Install Elixir 1.16.2 when available to fix bug with `ex_check` https://github.com/karolsluszniak/ex_check/issues/41#issuecomment-1921390413
|
|
||||||
- delete `{:elixir_tests, "mix test"}` and formatting check
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ defmodule Pinchflat.Profiles.MediaProfile do
|
|||||||
field :name, :string
|
field :name, :string
|
||||||
|
|
||||||
field :output_path_template, :string,
|
field :output_path_template, :string,
|
||||||
default: "/{{ source_custom_name }}/{{ title }}/{{ title }} [{{ id }}].{{ ext }}"
|
default: "/{{ source_custom_name }}/{{ upload_yyyy_mm_dd }} {{ title }}/{{ title }} [{{ id }}].{{ ext }}"
|
||||||
|
|
||||||
field :download_subs, :boolean, default: true
|
field :download_subs, :boolean, default: true
|
||||||
field :download_auto_subs, :boolean, default: true
|
field :download_auto_subs, :boolean, default: true
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ defmodule Pinchflat.Profiles.OutputPathBuilder do
|
|||||||
# Individual parts of the upload date
|
# Individual parts of the upload date
|
||||||
"upload_year" => "%(upload_date>%Y)S",
|
"upload_year" => "%(upload_date>%Y)S",
|
||||||
"upload_month" => "%(upload_date>%m)S",
|
"upload_month" => "%(upload_date>%m)S",
|
||||||
"upload_day" => "%(upload_date>%d)S"
|
"upload_day" => "%(upload_date>%d)S",
|
||||||
|
"upload_yyyy_mm_dd" => "%(upload_date>%Y)S-%(upload_date>%m)S-%(upload_date>%d)S"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -61,11 +61,11 @@ defmodule Pinchflat.YtDlp.DownloadOptionBuilder do
|
|||||||
mapped_struct = Map.from_struct(media_profile)
|
mapped_struct = Map.from_struct(media_profile)
|
||||||
|
|
||||||
Enum.reduce(mapped_struct, [], fn attr, acc ->
|
Enum.reduce(mapped_struct, [], fn attr, acc ->
|
||||||
case {attr, media_profile} do
|
case attr do
|
||||||
{{:download_thumbnail, true}, _} ->
|
{:download_thumbnail, true} ->
|
||||||
acc ++ [:write_thumbnail]
|
acc ++ [:write_thumbnail, convert_thumbnail: "jpg"]
|
||||||
|
|
||||||
{{:embed_thumbnail, true}, %{preferred_resolution: pr}} when pr != :audio ->
|
{:embed_thumbnail, true} ->
|
||||||
acc ++ [:embed_thumbnail]
|
acc ++ [:embed_thumbnail]
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
@@ -78,31 +78,26 @@ defmodule Pinchflat.YtDlp.DownloadOptionBuilder do
|
|||||||
mapped_struct = Map.from_struct(media_profile)
|
mapped_struct = Map.from_struct(media_profile)
|
||||||
|
|
||||||
Enum.reduce(mapped_struct, [], fn attr, acc ->
|
Enum.reduce(mapped_struct, [], fn attr, acc ->
|
||||||
case {attr, media_profile} do
|
case attr do
|
||||||
{{:download_metadata, true}, _} ->
|
{:download_metadata, true} -> acc ++ [:write_info_json, :clean_info_json]
|
||||||
acc ++ [:write_info_json, :clean_info_json]
|
{:embed_metadata, true} -> acc ++ [:embed_metadata]
|
||||||
|
_ -> acc
|
||||||
{{:embed_metadata, true}, %{preferred_resolution: pr}} when pr != :audio ->
|
|
||||||
acc ++ [:embed_metadata]
|
|
||||||
|
|
||||||
_ ->
|
|
||||||
acc
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp quality_options(media_profile) do
|
defp quality_options(media_profile) do
|
||||||
codec_options = "+codec:avc:m4a"
|
video_codec_options = "+codec:avc:m4a"
|
||||||
|
|
||||||
case media_profile.preferred_resolution do
|
case media_profile.preferred_resolution do
|
||||||
# Also be aware that :audio disabled all embedding options for thumbnails, subtitles, and metadata
|
# Also be aware that :audio disabled all embedding options for subtitles
|
||||||
:audio -> [format_sort: "ext", format: "bestaudio"]
|
:audio -> [:extract_audio, format: "bestaudio[ext=m4a]"]
|
||||||
:"360p" -> [format_sort: "res:360,#{codec_options}"]
|
:"360p" -> [format_sort: "res:360,#{video_codec_options}"]
|
||||||
:"480p" -> [format_sort: "res:480,#{codec_options}"]
|
:"480p" -> [format_sort: "res:480,#{video_codec_options}"]
|
||||||
:"720p" -> [format_sort: "res:720,#{codec_options}"]
|
:"720p" -> [format_sort: "res:720,#{video_codec_options}"]
|
||||||
:"1080p" -> [format_sort: "res:1080,#{codec_options}"]
|
:"1080p" -> [format_sort: "res:1080,#{video_codec_options}"]
|
||||||
:"1440p" -> [format_sort: "res:1440,#{codec_options}"]
|
:"1440p" -> [format_sort: "res:1440,#{video_codec_options}"]
|
||||||
:"2160p" -> [format_sort: "res:2160,#{codec_options}"]
|
:"2160p" -> [format_sort: "res:2160,#{video_codec_options}"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -13,13 +13,17 @@
|
|||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body
|
<body
|
||||||
x-data={"{ sidebarVisible: false, proEnabled: #{Settings.get!(:pro_enabled)} }"}
|
x-data={"{
|
||||||
|
sidebarVisible: false,
|
||||||
|
proEnabled: #{Settings.get!(:pro_enabled)},
|
||||||
|
onboarding: #{Settings.get!(:onboarding)}
|
||||||
|
}"}
|
||||||
class="dark text-bodydark bg-boxdark-2"
|
class="dark text-bodydark bg-boxdark-2"
|
||||||
>
|
>
|
||||||
<%= @inner_content %>
|
<%= @inner_content %>
|
||||||
|
|
||||||
<.donate_modal conn={@conn} />
|
<.donate_modal conn={@conn} />
|
||||||
<template x-if="!proEnabled">
|
<template x-if="!proEnabled && !onboarding">
|
||||||
<.upgrade_modal conn={@conn} />
|
<.upgrade_modal conn={@conn} />
|
||||||
</template>
|
</template>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ defmodule PinchflatWeb.MediaProfiles.MediaProfileHTML do
|
|||||||
upload_day: nil,
|
upload_day: nil,
|
||||||
upload_month: nil,
|
upload_month: nil,
|
||||||
upload_year: nil,
|
upload_year: nil,
|
||||||
|
upload_yyyy_mm_dd: "the upload date in the format YYYY-MM-DD",
|
||||||
source_custom_name: "the name of the sources that use this profile",
|
source_custom_name: "the name of the sources that use this profile",
|
||||||
source_collection_type: "the collection type of the sources that use this profile. Either 'channel' or 'playlist'"
|
source_collection_type: "the collection type of the sources that use this profile. Either 'channel' or 'playlist'"
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -19,7 +19,7 @@
|
|||||||
type="text"
|
type="text"
|
||||||
inputclass="font-mono"
|
inputclass="font-mono"
|
||||||
label="Output path template"
|
label="Output path template"
|
||||||
help="Must end with .{{ ext }}. See below for more details. I promise the default is good for most cases (required)"
|
help="Must end with .{{ ext }}. See below for more details. The default is good for most cases (required)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<h3 class="mt-8 text-2xl text-black dark:text-white">
|
<h3 class="mt-8 text-2xl text-black dark:text-white">
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
options={friendly_resolution_options()}
|
options={friendly_resolution_options()}
|
||||||
type="select"
|
type="select"
|
||||||
label="Preferred Resolution"
|
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>
|
<.button class="my-10 sm:mb-7.5 w-full sm:w-auto">Save Media profile</.button>
|
||||||
|
|||||||
@@ -8,38 +8,34 @@ defmodule PinchflatWeb.Pages.PageController do
|
|||||||
alias Pinchflat.Profiles.MediaProfile
|
alias Pinchflat.Profiles.MediaProfile
|
||||||
|
|
||||||
def home(conn, params) do
|
def home(conn, params) do
|
||||||
force_onboarding = params["onboarding"]
|
done_onboarding = params["onboarding"] == "0"
|
||||||
media_profiles_exist = Repo.exists?(MediaProfile)
|
force_onboarding = params["onboarding"] == "1"
|
||||||
sources_exist = Repo.exists?(Source)
|
|
||||||
|
|
||||||
if !force_onboarding && media_profiles_exist && sources_exist do
|
if done_onboarding, do: Settings.set!(:onboarding, false)
|
||||||
render_home_page(conn)
|
|
||||||
|
if force_onboarding || Settings.get!(:onboarding) do
|
||||||
|
render_onboarding_page(conn)
|
||||||
else
|
else
|
||||||
render_onboarding_page(conn, media_profiles_exist, sources_exist)
|
render_home_page(conn)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp render_home_page(conn) do
|
defp render_home_page(conn) do
|
||||||
Settings.set!(:onboarding, false)
|
|
||||||
media_profile_count = Repo.aggregate(MediaProfile, :count, :id)
|
|
||||||
source_count = Repo.aggregate(Source, :count, :id)
|
|
||||||
media_item_count = Repo.aggregate(MediaItem, :count, :id)
|
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> render(:home,
|
|> render(:home,
|
||||||
media_profile_count: media_profile_count,
|
media_profile_count: Repo.aggregate(MediaProfile, :count, :id),
|
||||||
source_count: source_count,
|
source_count: Repo.aggregate(Source, :count, :id),
|
||||||
media_item_count: media_item_count
|
media_item_count: Repo.aggregate(MediaItem, :count, :id)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp render_onboarding_page(conn, media_profiles_exist, sources_exist) do
|
defp render_onboarding_page(conn) do
|
||||||
Settings.set!(:onboarding, true)
|
Settings.set!(:onboarding, true)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> render(:onboarding_checklist,
|
|> render(:onboarding_checklist,
|
||||||
media_profiles_exist: media_profiles_exist,
|
media_profiles_exist: Repo.exists?(MediaProfile),
|
||||||
sources_exist: sources_exist,
|
sources_exist: Repo.exists?(Source),
|
||||||
layout: {Layouts, :onboarding}
|
layout: {Layouts, :onboarding}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<p class="text-md text-bodydark">Feel free to add more Media Profiles or Sources in the meantime!</p>
|
<p class="text-md text-bodydark">Feel free to add more Media Profiles or Sources in the meantime!</p>
|
||||||
<div class="mt-8">
|
<div class="mt-8">
|
||||||
<.link href={~p"/"}>
|
<.link href={~p"/?onboarding=0"}>
|
||||||
<.button color="bg-primary" rounding="rounded-full" disabled={not @sources_exist}>
|
<.button color="bg-primary" rounding="rounded-full" disabled={not @sources_exist}>
|
||||||
Let's Go <span class="font-bold mx-2">🚀</span>
|
Let's Go <span class="font-bold mx-2">🚀</span>
|
||||||
</.button>
|
</.button>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ defmodule Pinchflat.MixProject do
|
|||||||
def project do
|
def project do
|
||||||
[
|
[
|
||||||
app: :pinchflat,
|
app: :pinchflat,
|
||||||
version: "0.1.0-alpha.1",
|
version: "0.1.0-alpha.2",
|
||||||
elixir: "~> 1.16",
|
elixir: "~> 1.16",
|
||||||
elixirc_paths: elixirc_paths(Mix.env()),
|
elixirc_paths: elixirc_paths(Mix.env()),
|
||||||
start_permanent: Mix.env() == :prod,
|
start_permanent: Mix.env() == :prod,
|
||||||
|
|||||||
+19
-7
@@ -11,9 +11,9 @@
|
|||||||
# - https://pkgs.org/ - resource for finding needed packages
|
# - https://pkgs.org/ - resource for finding needed packages
|
||||||
# - Ex: hexpm/elixir:1.16.0-erlang-26.2.1-debian-bullseye-20231009-slim
|
# - Ex: hexpm/elixir:1.16.0-erlang-26.2.1-debian-bullseye-20231009-slim
|
||||||
#
|
#
|
||||||
ARG ELIXIR_VERSION=1.16.0
|
ARG ELIXIR_VERSION=1.16.2
|
||||||
ARG OTP_VERSION=26.2.1
|
ARG OTP_VERSION=26.2.2
|
||||||
ARG DEBIAN_VERSION=bullseye-20231009-slim
|
ARG DEBIAN_VERSION=bookworm-20240130-slim
|
||||||
|
|
||||||
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
|
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
|
||||||
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
|
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
|
||||||
@@ -76,12 +76,13 @@ FROM ${RUNNER_IMAGE}
|
|||||||
|
|
||||||
RUN apt-get update -y
|
RUN apt-get update -y
|
||||||
RUN apt-get install -y libstdc++6 openssl libncurses5 locales ca-certificates \
|
RUN apt-get install -y libstdc++6 openssl libncurses5 locales ca-certificates \
|
||||||
python3 python3-pip ffmpeg
|
ffmpeg curl git openssh-client
|
||||||
RUN apt-get clean && rm -f /var/lib/apt/lists/*_*
|
RUN apt-get clean && rm -f /var/lib/apt/lists/*_*
|
||||||
|
|
||||||
# Download YT-DLP
|
# Download and update YT-DLP
|
||||||
# NOTE: If you're seeing weird issues, consider using the FFMPEG released by yt-dlp
|
RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp
|
||||||
RUN python3 -m pip install -U --pre yt-dlp
|
RUN chmod a+rx /usr/local/bin/yt-dlp
|
||||||
|
RUN yt-dlp -U
|
||||||
|
|
||||||
# Set the locale
|
# Set the locale
|
||||||
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
|
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
|
||||||
@@ -106,6 +107,17 @@ ENV RUN_CONTEXT="selfhosted"
|
|||||||
# Only copy the final release from the build stage
|
# Only copy the final release from the build stage
|
||||||
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/pinchflat ./
|
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/pinchflat ./
|
||||||
|
|
||||||
|
# NEVER do this if you're running in an environment where you don't trust the user
|
||||||
|
# (ie: most environments). This is only acceptable in a self-hosted environment.
|
||||||
|
# The user could just run the whole container as root and bypass this anyway so
|
||||||
|
# it's not a huge deal.
|
||||||
|
# This removes the root password to allow users to assume root if needed. This is
|
||||||
|
# preferrable to running the whole container as root so that the files/directories
|
||||||
|
# created by the app aren't owned by root and are therefore easier for other users
|
||||||
|
# and processes to interact with. If you want to just run the whole container as
|
||||||
|
# root, use --user 0:0 or something.
|
||||||
|
RUN passwd -d root
|
||||||
|
|
||||||
USER nobody
|
USER nobody
|
||||||
|
|
||||||
# If using an environment that doesn't automatically reap zombie processes, it is
|
# If using an environment that doesn't automatically reap zombie processes, it is
|
||||||
|
|||||||
@@ -125,6 +125,14 @@ defmodule Pinchflat.YtDlp.DownloadOptionBuilderTest do
|
|||||||
assert :write_thumbnail in res
|
assert :write_thumbnail in res
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "convertes thumbnail to jpg when download_thumbnail is true", %{media_item: media_item} do
|
||||||
|
media_item = update_media_profile_attribute(media_item, %{download_thumbnail: true})
|
||||||
|
|
||||||
|
assert {:ok, res} = DownloadOptionBuilder.build(media_item)
|
||||||
|
|
||||||
|
assert {:convert_thumbnail, "jpg"} in res
|
||||||
|
end
|
||||||
|
|
||||||
test "includes :embed_thumbnail option when specified", %{media_item: media_item} do
|
test "includes :embed_thumbnail option when specified", %{media_item: media_item} do
|
||||||
media_item = update_media_profile_attribute(media_item, %{embed_thumbnail: true})
|
media_item = update_media_profile_attribute(media_item, %{embed_thumbnail: true})
|
||||||
|
|
||||||
@@ -133,14 +141,6 @@ defmodule Pinchflat.YtDlp.DownloadOptionBuilderTest do
|
|||||||
assert :embed_thumbnail in res
|
assert :embed_thumbnail in res
|
||||||
end
|
end
|
||||||
|
|
||||||
test "doesn't include :embed_thumbnail option when preferred_resolution is :audio", %{media_item: media_item} do
|
|
||||||
media_item = update_media_profile_attribute(media_item, %{embed_thumbnail: true, preferred_resolution: :audio})
|
|
||||||
|
|
||||||
assert {:ok, res} = DownloadOptionBuilder.build(media_item)
|
|
||||||
|
|
||||||
refute :embed_thumbnail in res
|
|
||||||
end
|
|
||||||
|
|
||||||
test "doesn't include these options when not specified", %{media_item: media_item} do
|
test "doesn't include these options when not specified", %{media_item: media_item} do
|
||||||
media_item = update_media_profile_attribute(media_item, %{embed_thumbnail: false, download_thumbnail: false})
|
media_item = update_media_profile_attribute(media_item, %{embed_thumbnail: false, download_thumbnail: false})
|
||||||
|
|
||||||
@@ -169,14 +169,6 @@ defmodule Pinchflat.YtDlp.DownloadOptionBuilderTest do
|
|||||||
assert :embed_metadata in res
|
assert :embed_metadata in res
|
||||||
end
|
end
|
||||||
|
|
||||||
test "doesn't include :embed_metadata option when preferred_resolution is :audio", %{media_item: media_item} do
|
|
||||||
media_item = update_media_profile_attribute(media_item, %{embed_metadata: true, preferred_resolution: :audio})
|
|
||||||
|
|
||||||
assert {:ok, res} = DownloadOptionBuilder.build(media_item)
|
|
||||||
|
|
||||||
refute :embed_metadata in res
|
|
||||||
end
|
|
||||||
|
|
||||||
test "doesn't include these options when not specified", %{media_item: media_item} do
|
test "doesn't include these options when not specified", %{media_item: media_item} do
|
||||||
media_item = update_media_profile_attribute(media_item, %{embed_metadata: false, download_metadata: false})
|
media_item = update_media_profile_attribute(media_item, %{embed_metadata: false, download_metadata: false})
|
||||||
|
|
||||||
@@ -202,8 +194,8 @@ defmodule Pinchflat.YtDlp.DownloadOptionBuilderTest do
|
|||||||
|
|
||||||
assert {:ok, res} = DownloadOptionBuilder.build(media_item)
|
assert {:ok, res} = DownloadOptionBuilder.build(media_item)
|
||||||
|
|
||||||
assert {:format, "bestaudio"} in res
|
assert :extract_audio in res
|
||||||
assert {:format_sort, "ext"} in res
|
assert {:format, "bestaudio[ext=m4a]"} in res
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,51 +1,31 @@
|
|||||||
defmodule PinchflatWeb.PageControllerTest do
|
defmodule PinchflatWeb.PageControllerTest do
|
||||||
use PinchflatWeb.ConnCase
|
use PinchflatWeb.ConnCase
|
||||||
|
|
||||||
import Pinchflat.ProfilesFixtures
|
|
||||||
import Pinchflat.SourcesFixtures
|
|
||||||
|
|
||||||
alias Pinchflat.Settings
|
alias Pinchflat.Settings
|
||||||
|
|
||||||
describe "GET / when testing onboarding" do
|
describe "GET / when testing onboarding" do
|
||||||
test "sets the onboarding session to true when onboarding", %{conn: conn} do
|
test "sets the onboarding setting to true when onboarding", %{conn: conn} do
|
||||||
_conn = get(conn, ~p"/")
|
_conn = get(conn, ~p"/")
|
||||||
assert Settings.get!(:onboarding)
|
assert Settings.get!(:onboarding)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "displays the onboarding page when no media profiles exist", %{conn: conn} do
|
|
||||||
conn = get(conn, ~p"/")
|
|
||||||
assert html_response(conn, 200) =~ "Welcome to Pinchflat"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "displays the onboarding page when no sources exist", %{conn: conn} do
|
|
||||||
_ = media_profile_fixture()
|
|
||||||
|
|
||||||
conn = get(conn, ~p"/")
|
|
||||||
assert html_response(conn, 200) =~ "Welcome to Pinchflat"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "displays the onboarding page when onboarding is forced", %{conn: conn} do
|
test "displays the onboarding page when onboarding is forced", %{conn: conn} do
|
||||||
_ = media_profile_fixture()
|
Settings.set!(:onboarding, false)
|
||||||
_ = source_fixture()
|
|
||||||
|
|
||||||
conn = get(conn, ~p"/?onboarding=1")
|
conn = get(conn, ~p"/?onboarding=1")
|
||||||
assert html_response(conn, 200) =~ "Welcome to Pinchflat"
|
assert html_response(conn, 200) =~ "Welcome to Pinchflat"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "sets the onboarding session to false when not onboarding", %{conn: conn} do
|
test "sets the onboarding setting to false if you pass the corrent query param", %{conn: conn} do
|
||||||
conn = get(conn, ~p"/")
|
conn = get(conn, ~p"/")
|
||||||
assert Settings.get!(:onboarding)
|
assert Settings.get!(:onboarding)
|
||||||
|
|
||||||
_ = media_profile_fixture()
|
_conn = get(conn, ~p"/?onboarding=0")
|
||||||
_ = source_fixture()
|
|
||||||
|
|
||||||
_conn = get(conn, ~p"/")
|
|
||||||
refute Settings.get!(:onboarding)
|
refute Settings.get!(:onboarding)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "displays the home page when not onboarding", %{conn: conn} do
|
test "displays the home page when not onboarding", %{conn: conn} do
|
||||||
_ = media_profile_fixture()
|
Settings.set!(:onboarding, false)
|
||||||
_ = source_fixture()
|
|
||||||
|
|
||||||
conn = get(conn, ~p"/")
|
conn = get(conn, ~p"/")
|
||||||
assert html_response(conn, 200) =~ "MENU"
|
assert html_response(conn, 200) =~ "MENU"
|
||||||
|
|||||||
Reference in New Issue
Block a user