diff --git a/web/src/lib/components/download-movie-dialog.svelte b/web/src/lib/components/download-movie-dialog.svelte index bd90290..8b8d182 100644 --- a/web/src/lib/components/download-movie-dialog.svelte +++ b/web/src/lib/components/download-movie-dialog.svelte @@ -5,15 +5,13 @@ import { toast } from 'svelte-sonner'; import { Badge } from '$lib/components/ui/badge/index.js'; - import { getFullyQualifiedMediaName } from '$lib/utils'; import { LoaderCircle } from 'lucide-svelte'; import * as Dialog from '$lib/components/ui/dialog/index.js'; import * as Tabs from '$lib/components/ui/tabs/index.js'; - import * as Select from '$lib/components/ui/select/index.js'; import * as Table from '$lib/components/ui/table/index.js'; import client from '$lib/api'; import type { components } from '$lib/api/api'; - + import SelectFilePathSuffixDialog from '$lib/components/select-file-path-suffix-dialog.svelte'; let { movie } = $props(); let dialogueState = $state(false); let torrents: components['schemas']['IndexerQueryResult'][] = $state([]); @@ -103,11 +101,6 @@ }); -{#snippet saveDirectoryPreview(movie: components['schemas']['Movie'], filePathSuffix: string)} - /{getFullyQualifiedMediaName(movie)} [{movie.metadata_provider}id-{movie.external_id} - ]/{movie.name}{filePathSuffix === '' ? '' : ' - ' + filePathSuffix}.mkv -{/snippet} - Download Movie @@ -124,28 +117,24 @@
- - - {filePathSuffix} - - None - 2160p - 1080p - 720p - 480p - 360p - - -

- This is necessary to differentiate between versions of the same movie, for example a - 1080p and a 4K version. -

- { + isLoadingTorrents = true; + torrentsError = null; + torrents = []; + try { + torrents = await getTorrents(); + } catch (error) { + console.log(error); + } finally { + isLoadingTorrents = false; + } + }} > -

- {@render saveDirectoryPreview(movie, filePathSuffix)} -

+ Search for Torrents +
@@ -175,25 +164,6 @@ The custom query will override the default search string like "A Minecraft Movie (2025)".

- - -

- This is necessary to differentiate between versions of the same movie, for example a - 1080p and a 4K version. -

- - -

- {@render saveDirectoryPreview(movie, filePathSuffix)} -

@@ -234,15 +204,11 @@ {/each} - + downloadTorrent(torrent.id!)} + /> {/each} diff --git a/web/src/lib/components/download-season-dialog.svelte b/web/src/lib/components/download-season-dialog.svelte index 888e823..7d21bf7 100644 --- a/web/src/lib/components/download-season-dialog.svelte +++ b/web/src/lib/components/download-season-dialog.svelte @@ -3,19 +3,15 @@ import { Input } from '$lib/components/ui/input/index.js'; import { Label } from '$lib/components/ui/label/index.js'; import { toast } from 'svelte-sonner'; - import { - convertTorrentSeasonRangeToIntegerRange, - formatSecondsToOptimalUnit, - getFullyQualifiedMediaName - } from '$lib/utils'; + import { convertTorrentSeasonRangeToIntegerRange, formatSecondsToOptimalUnit } from '$lib/utils'; import { LoaderCircle } from 'lucide-svelte'; import * as Dialog from '$lib/components/ui/dialog/index.js'; import * as Tabs from '$lib/components/ui/tabs/index.js'; - import * as Select from '$lib/components/ui/select/index.js'; import * as Table from '$lib/components/ui/table/index.js'; import { Badge } from '$lib/components/ui/badge/index.js'; import client from '$lib/api'; import type { components } from '$lib/api/api'; + import SelectFilePathSuffixDialog from '$lib/components/select-file-path-suffix-dialog.svelte'; let { show }: { show: components['schemas']['Show'] } = $props(); let dialogueState = $state(false); @@ -90,13 +86,19 @@ } return data; } + $effect(() => { + if (show?.id) { + getTorrents(selectedSeasonNumber).then((fetchedTorrents) => { + if (!isLoadingTorrents) { + torrents = fetchedTorrents; + } else if (fetchedTorrents.length > 0 || torrentsError) { + torrents = fetchedTorrents; + } + }); + } + }); -{#snippet saveDirectoryPreview(show: components['schemas']['Show'], filePathSuffix: string)} - /{getFullyQualifiedMediaName(show)} [{show.metadata_provider}id-{show.external_id}]/ Season XX/{show.name} - SXXEXX {filePathSuffix === '' ? '' : ' - ' + filePathSuffix}.mkv -{/snippet} - Download Seasons @@ -113,122 +115,68 @@
- {#if show?.seasons?.length > 0} - + Enter a season number from 1 to {show.seasons.at(-1)?.number} + +
+ + -
-

- Enter the season's number you want to search for. The first, usually 1, or the last - season number usually yield the most season packs. Note that only Seasons which are - listed in the "Seasons" cell will be imported! -

- - - {filePathSuffix} - - None - 2160p - 1080p - 720p - 480p - 360p - - -

- This is necessary to differentiate between versions of the same season/show, for - example a 1080p and a 4K version of a season. -

- -

- {@render saveDirectoryPreview(show, filePathSuffix)} -

- {:else} -

- No season information available for this show. -

- {/if} + Search + +
+

+ Enter the season's number you want to search for. The first, usually 1, or the last + season number usually yield the most season packs. Note that only Seasons which are + listed in the "Seasons" cell will be imported! +

- {#if show?.seasons?.length > 0} - -
- - -
-

- The custom query will override the default search string like "The Simpsons Season 3". - Note that only Seasons which are listed in the "Seasons" cell will be imported! -

- - -

- This is necessary to differentiate between versions of the same season/show, for - example a 1080p and a 4K version of a season. -

- - Enter a custom query +
+ + +
+

+ The custom query will override the default search string like "The Simpsons Season 3". + Note that only Seasons which are listed in the "Seasons" cell will be imported! +

@@ -287,15 +235,11 @@ {/if} - + downloadTorrent(torrent.id!)} + /> {/each} diff --git a/web/src/lib/components/file-path-suffix-selector.svelte b/web/src/lib/components/file-path-suffix-selector.svelte new file mode 100644 index 0000000..c0d71d3 --- /dev/null +++ b/web/src/lib/components/file-path-suffix-selector.svelte @@ -0,0 +1,62 @@ + + +{#snippet filePathPreview()} +

+ This is necessary to differentiate between versions of the same movie or show, for example a + 1080p and a 4K version. +

+ +

+ {saveDirectoryPreview(media, filePathSuffix)} +

+{/snippet} + + + + Standard Mode + Advanced Mode + + +
+ + + {filePathSuffix} + + None + 2160p + 1080p + 720p + 480p + 360p + + + {@render filePathPreview()} +
+
+ + + + {@render filePathPreview()} + +
diff --git a/web/src/lib/components/select-file-path-suffix-dialog.svelte b/web/src/lib/components/select-file-path-suffix-dialog.svelte new file mode 100644 index 0000000..98b06a7 --- /dev/null +++ b/web/src/lib/components/select-file-path-suffix-dialog.svelte @@ -0,0 +1,41 @@ + + + + + + + + + Set File Path Suffix + + Set the filepath suffix for downloaded files of the torrent. + + + +
+ + +
+
+
diff --git a/web/src/lib/utils.ts b/web/src/lib/utils.ts index 5dca443..0011f9b 100644 --- a/web/src/lib/utils.ts +++ b/web/src/lib/utils.ts @@ -4,6 +4,7 @@ import { goto } from '$app/navigation'; import { resolve } from '$app/paths'; import { toast } from 'svelte-sonner'; import client from '$lib/api'; +import type { components } from '$lib/api/api'; export const qualityMap: { [key: number]: string } = { 1: '4K/UHD', @@ -97,3 +98,23 @@ export function handleQueryNotificationToast(count: number = 0, query: string = toast.success(`Found ${count} ${count > 1 ? 'result' : 'results'} for search term "${query}".`); else if (count == 0) toast.info(`No results found for "${query}".`); } + +export function saveDirectoryPreview( + media: components['schemas']['Show'] | components['schemas']['Movie'], + filePathSuffix: string = '' +) { + let path = + '/' + + getFullyQualifiedMediaName(media) + + ' [' + + media.metadata_provider + + 'id-' + + media.external_id + + ']/'; + if ('seasons' in media) { + path += ' Season XX/SXXEXX' + (filePathSuffix === '' ? '' : ' - ' + filePathSuffix) + '.mkv'; + } else { + path += media.name + (filePathSuffix === '' ? '' : ' - ' + filePathSuffix) + '.mkv'; + } + return path; +}