formats selection
This commit is contained in:
@@ -44,7 +44,7 @@
|
|||||||
{#if $height > 100}
|
{#if $height > 100}
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<NewDownload />
|
<NewDownload />
|
||||||
<Settings />
|
<!-- <Settings /> -->
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
63
ui/src/lib/FormatsList.svelte
Normal file
63
ui/src/lib/FormatsList.svelte
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { DLFormat } from './types';
|
||||||
|
|
||||||
|
let group = '';
|
||||||
|
export let formats: DLFormat[];
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="flex w-full flex-col items-center justify-center">
|
||||||
|
<div class="w-full px-4 py-16">
|
||||||
|
<div class="mx-auto w-full max-w-md">
|
||||||
|
<fieldset class="flex flex-col space-y-2">
|
||||||
|
{#each formats as format}
|
||||||
|
<div class="relative">
|
||||||
|
<input
|
||||||
|
id="startup"
|
||||||
|
class="absolute opacity-0 w-0 h-0 peer"
|
||||||
|
type="radio"
|
||||||
|
bind:group
|
||||||
|
name="type"
|
||||||
|
value="startup"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
for="startup"
|
||||||
|
class="[&_p]:text-gray-900 [&_span]:text-gray-500 peer-checked:[&_p]:text-white peer-checked:[&_span]:text-sky-100 peer-focus:ring-2 peer-focus:ring-white peer-focus:ring-opacity-60 peer-focus:ring-offset-2 peer-focus:ring-offset-sky-300 bg-white relative flex cursor-pointer rounded-lg px-5 py-4 shadow-md focus:outline-none peer-checked:bg-sky-900/75 peer-checked:text-white"
|
||||||
|
>
|
||||||
|
<div class="flex w-full items-center justify-between">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<div class="text-sm">
|
||||||
|
<p class="font-medium" id="headlessui-label-:R5mm:">
|
||||||
|
{format.resolution}
|
||||||
|
</p>
|
||||||
|
<span class="inline" id="headlessui-description-:R9mm:">
|
||||||
|
<span>{format.vcodec}</span>
|
||||||
|
<span aria-hidden="true">·</span>
|
||||||
|
<span>{format.vcodec}</span></span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="shrink-0 text-white">
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" class="h-6 w-6">
|
||||||
|
<circle
|
||||||
|
cx="12"
|
||||||
|
cy="12"
|
||||||
|
r="12"
|
||||||
|
fill="#fff"
|
||||||
|
opacity="0.2"
|
||||||
|
/><path
|
||||||
|
d="M7 13l3 3 7-7"
|
||||||
|
stroke="#fff"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -3,28 +3,47 @@
|
|||||||
import Button from './Button.svelte';
|
import Button from './Button.svelte';
|
||||||
import TextField from './TextField.svelte';
|
import TextField from './TextField.svelte';
|
||||||
import { downloadTemplates, rpcClient } from './store';
|
import { downloadTemplates, rpcClient } from './store';
|
||||||
|
import Select from './Select.svelte';
|
||||||
|
import type { DLMetadata } from './types';
|
||||||
|
import FormatsList from './FormatsList.svelte';
|
||||||
|
|
||||||
let url: string = '';
|
let url: string = '';
|
||||||
let args: string = '';
|
let args: string = '';
|
||||||
|
let metadata: DLMetadata;
|
||||||
$: console.log(args);
|
|
||||||
|
|
||||||
const download = () =>
|
const download = () =>
|
||||||
get(rpcClient).download({
|
get(rpcClient).download({
|
||||||
url,
|
url,
|
||||||
args,
|
args,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getFormats = () =>
|
||||||
|
get(rpcClient)
|
||||||
|
.formats(url)
|
||||||
|
?.then((f) => (metadata = f.result));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="w-full">
|
<div class="w-full px-8">
|
||||||
<div class="flex gap-2 w-full mb-2">
|
<div class="my-4 font-semibold text-xl">New download</div>
|
||||||
<TextField label="url" class="w-96" bind:value={url} />
|
<div class="grid grid-cols-2 gap-2 w-full mb-2">
|
||||||
<TextField label="args" class="w-96" bind:value={args} />
|
<TextField placeholder="https://..." label="URL" bind:value={url} />
|
||||||
</div>
|
<TextField
|
||||||
<Button on:click={download}>Download</Button>
|
placeholder="arguments separated by space"
|
||||||
<select bind:value={args}>
|
label="yt-dlp arguments"
|
||||||
|
bind:value={args}
|
||||||
|
/>
|
||||||
|
<Select bind:value={args}>
|
||||||
|
<option selected disabled value=""> Select download template </option>
|
||||||
{#each $downloadTemplates as template}
|
{#each $downloadTemplates as template}
|
||||||
<option id={template.id} value={template.content}>{template.name}</option>
|
<option id={template.id} value={template.content}>
|
||||||
|
{template.name}
|
||||||
|
</option>
|
||||||
{/each}
|
{/each}
|
||||||
</select>
|
</Select>
|
||||||
|
</div>
|
||||||
|
<Button class="mt-2" on:click={download}>Download</Button>
|
||||||
|
<Button class="mt-2" on:click={getFormats}>Select format</Button>
|
||||||
|
{#if metadata}
|
||||||
|
<FormatsList formats={metadata.formats} />
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
16
ui/src/lib/Select.svelte
Normal file
16
ui/src/lib/Select.svelte
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export let value: any;
|
||||||
|
|
||||||
|
export let disabled: boolean = false;
|
||||||
|
export let placeholder: string = '';
|
||||||
|
export { clazz as class };
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<select
|
||||||
|
class="p-2 bg-neutral-50 border rounded-lg appearance-none text-sm font-semibold"
|
||||||
|
bind:value
|
||||||
|
{disabled}
|
||||||
|
{placeholder}
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</select>
|
||||||
@@ -4,16 +4,18 @@
|
|||||||
export let value: any;
|
export let value: any;
|
||||||
|
|
||||||
export let disabled: boolean = false;
|
export let disabled: boolean = false;
|
||||||
|
export let placeholder: string = '';
|
||||||
export { clazz as class };
|
export { clazz as class };
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col gap-0.5 text-sm">
|
<div class="flex flex-col gap-0.5 text-sm font-semibold">
|
||||||
<label for=""> {label} </label>
|
<label for=""> {label} </label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
class={`p-2 bg-neutral-50 border rounded-lg ${clazz}`}
|
class={`p-2 bg-neutral-50 border rounded-lg ${clazz}`}
|
||||||
on:keyup
|
on:keyup
|
||||||
bind:value
|
bind:value
|
||||||
|
{placeholder}
|
||||||
{disabled}
|
{disabled}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user