mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-19 22:54:22 +02:00
Merge pull request #43 from maxdorninger/add-usenet-support
Add usenet support and fix jackett using magnet link
This commit is contained in:
@@ -6,7 +6,11 @@
|
||||
import { toast } from 'svelte-sonner';
|
||||
|
||||
import type { PublicIndexerQueryResult } from '$lib/types.js';
|
||||
import { convertTorrentSeasonRangeToIntegerRange, getFullyQualifiedMediaName } from '$lib/utils';
|
||||
import {
|
||||
convertTorrentSeasonRangeToIntegerRange,
|
||||
formatSecondsToOptimalUnit,
|
||||
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';
|
||||
@@ -269,7 +273,9 @@
|
||||
<Table.Row>
|
||||
<Table.Head>Title</Table.Head>
|
||||
<Table.Head>Size</Table.Head>
|
||||
<Table.Head>Usenet</Table.Head>
|
||||
<Table.Head>Seeders</Table.Head>
|
||||
<Table.Head>Age</Table.Head>
|
||||
<Table.Head>Indexer Flags</Table.Head>
|
||||
<Table.Head>Seasons</Table.Head>
|
||||
<Table.Head class="text-right">Actions</Table.Head>
|
||||
@@ -280,7 +286,11 @@
|
||||
<Table.Row>
|
||||
<Table.Cell class="max-w-[300px] font-medium">{torrent.title}</Table.Cell>
|
||||
<Table.Cell>{(torrent.size / 1024 / 1024 / 1024).toFixed(2)}GB</Table.Cell>
|
||||
<Table.Cell>{torrent.seeders}</Table.Cell>
|
||||
<Table.Cell>{torrent.usenet}</Table.Cell>
|
||||
<Table.Cell>{torrent.usenet ? 'N/A' : torrent.seeders}</Table.Cell>
|
||||
<Table.Cell
|
||||
>{torrent.usenet ? formatSecondsToOptimalUnit(torrent.age) : 'N/A'}</Table.Cell
|
||||
>
|
||||
<Table.Cell>
|
||||
{#each torrent.flags as flag}
|
||||
<Badge variant="outline">{flag}</Badge>
|
||||
|
||||
@@ -73,6 +73,8 @@ export interface PublicIndexerQueryResult {
|
||||
flags: string[]; // items: { type: string }, type: array
|
||||
season: number[]; // items: { type: integer }, type: array
|
||||
size: number;
|
||||
usenet: boolean;
|
||||
age: number;
|
||||
}
|
||||
|
||||
export interface Season {
|
||||
@@ -152,6 +154,7 @@ export interface Torrent {
|
||||
imported: boolean;
|
||||
hash: string;
|
||||
id?: string; // type: string, format: uuid
|
||||
usenet: boolean;
|
||||
}
|
||||
|
||||
export interface UserCreate {
|
||||
@@ -186,6 +189,7 @@ export interface RichSeasonTorrent {
|
||||
status: TorrentStatus;
|
||||
quality: Quality;
|
||||
imported: boolean;
|
||||
usenet: boolean;
|
||||
|
||||
file_path_suffix: string;
|
||||
seasons: number[];
|
||||
|
||||
@@ -74,3 +74,25 @@ export async function handleLogout() {
|
||||
toast.error('Logout failed: ' + response.status);
|
||||
}
|
||||
}
|
||||
|
||||
export function formatSecondsToOptimalUnit(seconds: number): string {
|
||||
if (seconds < 0) return '0s';
|
||||
|
||||
const units = [
|
||||
{ name: 'y', seconds: 365.25 * 24 * 60 * 60 }, // year (accounting for leap years)
|
||||
{ name: 'mo', seconds: 30.44 * 24 * 60 * 60 }, // month (average)
|
||||
{ name: 'd', seconds: 24 * 60 * 60 }, // day
|
||||
{ name: 'h', seconds: 60 * 60 }, // hour
|
||||
{ name: 'm', seconds: 60 }, // minute
|
||||
{ name: 's', seconds: 1 } // second
|
||||
];
|
||||
|
||||
for (const unit of units) {
|
||||
const value = seconds / unit.seconds;
|
||||
if (value >= 1) {
|
||||
return `${Math.floor(value)}${unit.name}`;
|
||||
}
|
||||
}
|
||||
|
||||
return '0s';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user