improve UX of downloading torrents by splitting the dialogs into two steps; deduplicate code; fix bug which causes the directory preview to be incorrect

This commit is contained in:
maxDorninger
2025-10-29 15:56:00 +01:00
parent 49f8886db1
commit 82700abeb6
5 changed files with 221 additions and 187 deletions

View File

@@ -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;
}