mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-20 00:53:30 +02:00
**Description** As explained on #322, MediaManager currently only matches torrents that represent full seasons or season packs. As a result, valid episode-based releases — commonly returned by indexers such as EZTV — are filtered out during scoring and never considered for download. Initial changes to the season parsing logic allow these torrents to be discovered. However, additional changes are required beyond season parsing to properly support single-episode imports. This PR is intended as a work-in-progress / RFC to discuss the required changes and align on the correct approach before completing the implementation. **Things planned to do** [X] Update Web UI to better display episode-level details [ ] Update TV show import logic to handle single episode files, instead of assuming full season files (to avoid integrity errors when episodes are missing) [ ] Create episode file tables to store episode-level data, similar to season files [ ] Implement fetching and downloading logic for single-episode torrents **Notes / current limitations** At the moment, the database and import logic assume one file per season per quality, which works for season packs but not for episode-based releases. These changes are intentionally not completed yet and are part of the discussion this PR aims to start. **Request for feedback** This represents a significant change in how TV content is handled in MediaManager. Before proceeding further, feedback from @maxdorninger on the overall direction and next steps would be greatly appreciated. Once aligned, the remaining tasks can be implemented incrementally. --------- Co-authored-by: Maximilian Dorninger <97409287+maxdorninger@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
136 lines
4.0 KiB
Svelte
136 lines
4.0 KiB
Svelte
<script lang="ts">
|
|
import {
|
|
convertTorrentSeasonRangeToIntegerRange,
|
|
convertTorrentEpisodeRangeToIntegerRange,
|
|
getTorrentQualityString,
|
|
getTorrentStatusString
|
|
} from '$lib/utils.js';
|
|
import CheckmarkX from '$lib/components/checkmark-x.svelte';
|
|
import * as Table from '$lib/components/ui/table';
|
|
import type { components } from '$lib/api/api';
|
|
import { getContext } from 'svelte';
|
|
import { Button } from '$lib/components/ui/button';
|
|
import client from '$lib/api';
|
|
import { toast } from 'svelte-sonner';
|
|
import DeleteTorrentDialog from '$lib/components/torrents/delete-torrent-dialog.svelte';
|
|
import EditTorrentDialog from '$lib/components/torrents/edit-torrent-dialog.svelte';
|
|
import { invalidateAll } from '$app/navigation';
|
|
import { resolve } from '$app/paths';
|
|
let {
|
|
torrents,
|
|
isShow = true,
|
|
showId,
|
|
movieId
|
|
}: {
|
|
torrents:
|
|
| components['schemas']['MovieTorrent'][]
|
|
| components['schemas']['RichSeasonTorrent'][];
|
|
isShow: boolean;
|
|
showId?: string;
|
|
movieId?: string;
|
|
} = $props();
|
|
|
|
let user: () => components['schemas']['UserRead'] = getContext('user');
|
|
|
|
async function retryTorrentDownload(
|
|
torrent: components['schemas']['MovieTorrent'] | components['schemas']['RichSeasonTorrent']
|
|
) {
|
|
console.log(`Retrying download for torrent ${torrent.torrent_title}`);
|
|
const { error } = await client.POST('/api/v1/torrent/{torrent_id}/retry', {
|
|
params: {
|
|
path: {
|
|
torrent_id: torrent.torrent_id!
|
|
}
|
|
}
|
|
});
|
|
if (error) {
|
|
toast.error(`Failed on retrying download: ${error}`);
|
|
} else {
|
|
console.log(`Successfully retried download for torrent ${torrent.torrent_title}`);
|
|
toast.success('Trying to download torrent...');
|
|
}
|
|
await invalidateAll();
|
|
}
|
|
</script>
|
|
|
|
<Table.Root>
|
|
<Table.Caption>A list of all torrents.</Table.Caption>
|
|
<Table.Header>
|
|
<Table.Row>
|
|
<Table.Head>Name</Table.Head>
|
|
{#if isShow}
|
|
<Table.Head>Seasons</Table.Head>
|
|
<Table.Head>Episodes</Table.Head>
|
|
{/if}
|
|
<Table.Head>Download Status</Table.Head>
|
|
<Table.Head>Quality</Table.Head>
|
|
<Table.Head>File Path Suffix</Table.Head>
|
|
<Table.Head>Imported</Table.Head>
|
|
{#if user().is_superuser}
|
|
<Table.Head>Actions</Table.Head>
|
|
{/if}
|
|
</Table.Row>
|
|
</Table.Header>
|
|
<Table.Body>
|
|
{#each torrents as torrent (torrent.torrent_id)}
|
|
<Table.Row>
|
|
<Table.Cell class="font-medium">
|
|
{#if isShow && showId}
|
|
<a
|
|
href={resolve('/dashboard/tv/[showId]', { showId })}
|
|
class="text-primary hover:underline"
|
|
>
|
|
{torrent.torrent_title}
|
|
</a>
|
|
{:else if !isShow && movieId}
|
|
<a
|
|
href={resolve('/dashboard/movies/[movieId]', { movieId })}
|
|
class="text-primary hover:underline"
|
|
>
|
|
{torrent.torrent_title}
|
|
</a>
|
|
{:else}
|
|
{torrent.torrent_title}
|
|
{/if}
|
|
</Table.Cell>
|
|
{#if isShow}
|
|
<Table.Cell>
|
|
{convertTorrentSeasonRangeToIntegerRange(
|
|
(torrent as components['schemas']['RichSeasonTorrent']).seasons!
|
|
)}
|
|
</Table.Cell>
|
|
<Table.Cell>
|
|
{convertTorrentEpisodeRangeToIntegerRange(
|
|
(torrent as components['schemas']['RichSeasonTorrent']).episodes!
|
|
)}
|
|
</Table.Cell>
|
|
{/if}
|
|
<Table.Cell>
|
|
{getTorrentStatusString(torrent.status)}
|
|
</Table.Cell>
|
|
<Table.Cell class="font-medium">
|
|
{getTorrentQualityString(torrent.quality)}
|
|
</Table.Cell>
|
|
<Table.Cell>
|
|
{torrent.file_path_suffix}
|
|
</Table.Cell>
|
|
<Table.Cell>
|
|
<CheckmarkX state={torrent.imported} />
|
|
</Table.Cell>
|
|
{#if user().is_superuser}
|
|
<Table.Cell class="flex flex-col justify-center gap-2 xl:flex-row">
|
|
{#if 'finished' !== getTorrentStatusString(torrent.status)}
|
|
<Button variant="secondary" onclick={() => retryTorrentDownload(torrent)}>
|
|
Retry Download
|
|
</Button>
|
|
{/if}
|
|
<DeleteTorrentDialog torrentName={torrent.torrent_title} torrentId={torrent.torrent_id!}
|
|
></DeleteTorrentDialog>
|
|
<EditTorrentDialog {torrent} />
|
|
</Table.Cell>
|
|
{/if}
|
|
</Table.Row>
|
|
{/each}
|
|
</Table.Body>
|
|
</Table.Root>
|