Added presets for output templates

This commit is contained in:
Kieran Eglin 2024-03-13 14:19:31 -07:00
parent 25eb772896
commit 1b41b0e0c7
No known key found for this signature in database
GPG key ID: 193984967FCF432D
4 changed files with 64 additions and 25 deletions

View file

@ -40,7 +40,9 @@ defmodule Pinchflat.Downloading.OutputPathBuilder do
"upload_year" => "%(upload_date>%Y)S",
"upload_month" => "%(upload_date>%m)S",
"upload_day" => "%(upload_date>%d)S",
"upload_yyyy_mm_dd" => "%(upload_date>%Y-%m-%d)S"
"upload_yyyy_mm_dd" => "%(upload_date>%Y-%m-%d)S",
"season_from_date" => "%(upload_date>%Y)S",
"season_episode_from_date" => "s%(upload_date>%Y)Se%(upload_date>%m%d)S"
}
end
end

View file

@ -317,17 +317,7 @@ defmodule PinchflatWeb.CoreComponents do
<span :if={@label_suffix} class="text-xs text-bodydark"><%= @label_suffix %></span>
</.label>
<div class="relative">
<input type="hidden" name={@name} value="false" />
<input
type="checkbox"
id={@id}
name={@name}
value="true"
x-bind:checked="enabled"
class="sr-only"
@change="enabled = !enabled"
{@rest}
/>
<input type="hidden" id={@id} name={@name} x-bind:value="enabled" />
<div class="inline-block cursor-pointer" @click="enabled = !enabled">
<div x-bind:class="enabled && '!bg-primary'" class="block h-8 w-14 rounded-full bg-black"></div>
<div

View file

@ -1,6 +1,8 @@
defmodule PinchflatWeb.MediaProfiles.MediaProfileHTML do
use PinchflatWeb, :html
alias Pinchflat.Profiles.MediaProfile
embed_templates "media_profile_html/*"
@doc """
@ -53,4 +55,24 @@ defmodule PinchflatWeb.MediaProfiles.MediaProfileHTML do
duration_string
)a
end
def output_template_preset_options do
[
{"Default", default_output_template()},
{"Media Center (Plex, Jellyfin, Kodi, etc.)", media_center_output_template()},
{"Audio", audio_output_template()}
]
end
defp default_output_template do
%MediaProfile{}.output_path_template
end
defp media_center_output_template do
"/shows/{{ source_custom_name }}/{{ season_from_date }}/{{ season_episode_from_date }} - {{ title }}.{{ ext }}"
end
defp audio_output_template do
"/music/{{ source_custom_name }}/{{ title }}.{{ ext }}"
end
end

View file

@ -3,7 +3,7 @@
Oops, something went wrong! Please check the errors below.
</.error>
<h3 class="my-4 text-2xl text-black dark:text-white">
<h3 class="mt-4 text-2xl text-black dark:text-white">
General Options
</h3>
<.input
@ -14,15 +14,40 @@
help="Something descriptive. Does not impact indexing or downloading (required)"
/>
<.input
field={f[:output_path_template]}
type="text"
inputclass="font-mono"
label="Output path template"
help="Must end with .{{ ext }}. See below for more details. The default is good for most cases (required)"
/>
<h3 class="mt-10 text-2xl text-black dark:text-white">
Output Path Options
</h3>
<h3 class="mt-8 text-2xl text-black dark:text-white">
<section
class="flex flex-col lg:flex-row lg:justify-between"
x-data={"{ template: '#{f[:output_path_template].value}' }"}
>
<div class="w-full lg:w-9/12">
<.input
field={f[:output_path_template]}
type="text"
inputclass="font-mono"
label="Output path template"
help="Must end with .{{ ext }}. See below for more details. The default is good for most cases (required)"
x-model="template"
/>
</div>
<div class="flex justify-center">
<span class="text-bodydark mt-6 lg:mt-15 text-2xl lg:text-lg">- or -</span>
</div>
<div class="w-full lg:w-2/12">
<.input
name="output_path_presets"
value="default"
options={output_template_preset_options()}
type="select"
label="Select preset"
x-on:change="template = event.target.value"
/>
</div>
</section>
<h3 class="mt-10 text-2xl text-black dark:text-white">
Subtitle Options
</h3>
<.input
@ -50,7 +75,7 @@
help="Use commas for multiple languages (eg: en,de)"
/>
<h3 class="mt-8 text-2xl text-black dark:text-white">
<h3 class="mt-10 text-2xl text-black dark:text-white">
Thumbnail Options
</h3>
<.input
@ -66,7 +91,7 @@
help="Downloads and embeds thumbnail in the media file itself, if supported. Uneffected by 'Download Thumbnail' (recommended)"
/>
<h3 class="mt-8 text-2xl text-black dark:text-white">
<h3 class="mt-10 text-2xl text-black dark:text-white">
Metadata Options
</h3>
<.input
@ -88,7 +113,7 @@
help="Downloads NFO data alongside media file for use with Jellyfin, Kodi, etc."
/>
<h3 class="mt-8 text-2xl text-black dark:text-white">
<h3 class="mt-10 text-2xl text-black dark:text-white">
Release Format Options
</h3>
@ -107,7 +132,7 @@
help="Excludes media that comes from a past livestream"
/>
<h3 class="mt-8 text-2xl text-black dark:text-white">
<h3 class="mt-10 text-2xl text-black dark:text-white">
Quality Options
</h3>