fix: wrong file copy
This commit is contained in:
1 parent
d6f4433541
commit
7f0e363cfe
2 files changed
+260
-212
No files matched your search
@@ -1,246 +1,287 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col gap-6">
|
<div class="flex flex-col gap-6 px-4 md:px-8 py-6 max-w-4xl">
|
||||||
|
|
||||||
<div>
|
|
||||||
<h2 class="text-base font-semibold text-primary">Media Management</h2>
|
|
||||||
<p class="text-sm text-muted mt-1">Configuration des dossiers et du comportement d'import.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Dossiers -->
|
|
||||||
<div class="settings-card flex flex-col gap-5">
|
|
||||||
|
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
<div>
|
<div>
|
||||||
<div class="flex items-center gap-2 mb-1.5">
|
<h2 class="text-base font-semibold text-primary">Gestion des imports</h2>
|
||||||
<label class="settings-label">Dossier téléchargements</label>
|
<p class="text-xs text-muted mt-0.5">
|
||||||
<span v-if="isDocker" class="text-[10px] text-accent border border-accent/40 px-1.5 py-0.5 rounded">Docker</span>
|
Visualisez et renommez vos fichiers importés selon le mode actuel
|
||||||
</div>
|
<span class="ml-1 px-1.5 py-0.5 rounded text-[10px]"
|
||||||
<button @click="openPicker('completePath')" class="settings-input text-left font-mono truncate w-full"
|
:class="nfoSupport ? 'bg-accent/10 text-accent' : 'bg-hover text-muted'">
|
||||||
:class="isRootPath(form.completePath) ? 'text-yellow-500 border-yellow-500/40' : form.completePath ? 'text-primary' : 'text-muted'">
|
{{ nfoSupport ? 'Mode NFO' : 'Mode Formaté' }}
|
||||||
{{ form.completePath || '/' }}
|
</span>
|
||||||
</button>
|
|
||||||
<p v-if="isRootPath(form.completePath)" class="text-xs text-yellow-500 mt-1.5 flex items-center gap-1">
|
|
||||||
<span>⚠</span> Chemin non configuré — cliquez pour sélectionner un dossier
|
|
||||||
</p>
|
</p>
|
||||||
<p v-else class="text-xs text-muted mt-1.5">Dossier où sont déposés les fichiers téléchargés</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
<div>
|
<button @click="load" :disabled="loading" class="btn-secondary">
|
||||||
<div class="flex items-center gap-2 mb-1.5">
|
<svg width="13" height="13" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" fill="none"
|
||||||
<label class="settings-label">Médiathèque Fankai</label>
|
:class="loading ? 'animate-spin' : ''">
|
||||||
<span v-if="isDocker" class="text-[10px] text-accent border border-accent/40 px-1.5 py-0.5 rounded">Docker</span>
|
<path d="M21 12a9 9 0 0 1-9 9 9 9 0 0 1-6.36-2.64M3 12a9 9 0 0 1 9-9 9 9 0 0 1 6.36 2.64"/>
|
||||||
</div>
|
<polyline points="16 5 21 5 21 10"/>
|
||||||
<button @click="openPicker('mediaPath')" class="settings-input text-left font-mono truncate w-full"
|
</svg>
|
||||||
:class="isRootPath(form.mediaPath) ? 'text-yellow-500 border-yellow-500/40' : form.mediaPath ? 'text-primary' : 'text-muted'">
|
Actualiser
|
||||||
{{ form.mediaPath || '/' }}
|
</button>
|
||||||
|
<button
|
||||||
|
v-if="totalNeedsRename > 0"
|
||||||
|
@click="renameAll()"
|
||||||
|
:disabled="renamingAll"
|
||||||
|
class="btn-primary"
|
||||||
|
>
|
||||||
|
{{ renamingAll ? 'Renommage…' : `Tout renommer (${totalNeedsRename})` }}
|
||||||
</button>
|
</button>
|
||||||
<p v-if="isRootPath(form.mediaPath)" class="text-xs text-yellow-500 mt-1.5 flex items-center gap-1">
|
|
||||||
<span>⚠</span> Chemin non configuré — cliquez pour sélectionner un dossier
|
|
||||||
</p>
|
|
||||||
<p v-else class="text-xs text-muted mt-1.5">Dossier racine de votre médiathèque (Jellyfin, Kodi, Plex…)</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Alerte globale si un des deux paths est sur / -->
|
|
||||||
<div v-if="hasUnconfiguredPaths" class="flex items-start gap-3 px-4 py-3 rounded-lg border border-yellow-500/40 bg-yellow-500/5">
|
|
||||||
<span class="text-yellow-500 text-sm mt-0.5">⚠</span>
|
|
||||||
<div class="flex flex-col gap-0.5">
|
|
||||||
<p class="text-sm text-yellow-500 font-medium">Chemins non configurés</p>
|
|
||||||
<p class="text-xs text-muted">
|
|
||||||
L'import automatique est désactivé tant que les dossiers ne sont pas configurés.
|
|
||||||
Configurez-les ci-dessus avant de sauvegarder.
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Mode import -->
|
<!-- Loading -->
|
||||||
<div class="settings-card flex flex-col gap-2">
|
<div v-if="loading" class="flex items-center justify-center gap-2 py-16 text-muted text-sm">
|
||||||
<label class="settings-label">Mode d'import</label>
|
<div class="w-4 h-4 border border-border border-t-accent rounded-full animate-spin" />
|
||||||
<div class="flex gap-2">
|
Chargement…
|
||||||
<button
|
</div>
|
||||||
@click="form.organizeMode = 'hardlink'"
|
|
||||||
class="px-4 py-2 text-xs rounded-lg border transition-colors"
|
<!-- Vide -->
|
||||||
:class="form.organizeMode === 'hardlink'
|
<div v-else-if="series.length === 0" class="settings-card flex flex-col items-center gap-2 py-16 text-center">
|
||||||
? 'border-accent text-accent bg-accent-muted'
|
<p class="text-sm text-muted">Aucune série importée</p>
|
||||||
: 'border-border text-muted hover:border-secondary'"
|
<p class="text-xs text-muted">Importez des séries depuis la page Activité ou via l'import manuel.</p>
|
||||||
>
|
</div>
|
||||||
Hardlink
|
|
||||||
</button>
|
<!-- Résultat rename all -->
|
||||||
<button
|
<div v-if="renameResult" class="settings-card flex items-center justify-between gap-3">
|
||||||
@click="form.organizeMode = 'copy'"
|
<p class="text-xs" :class="renameResult.errors.length > 0 ? 'text-yellow-500' : 'text-green-400'">
|
||||||
class="px-4 py-2 text-xs rounded-lg border transition-colors"
|
{{ renameResult.done }} fichier{{ renameResult.done > 1 ? 's' : '' }} renommé{{ renameResult.done > 1 ? 's' : '' }}
|
||||||
:class="form.organizeMode === 'copy'
|
<span v-if="renameResult.errors.length > 0"> · {{ renameResult.errors.length }} erreur{{ renameResult.errors.length > 1 ? 's' : '' }}</span>
|
||||||
? 'border-accent text-accent bg-accent-muted'
|
|
||||||
: 'border-border text-muted hover:border-secondary'"
|
|
||||||
>
|
|
||||||
Copier
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
@click="form.organizeMode = 'move'"
|
|
||||||
class="px-4 py-2 text-xs rounded-lg border transition-colors"
|
|
||||||
:class="form.organizeMode === 'move'
|
|
||||||
? 'border-accent text-accent bg-accent-muted'
|
|
||||||
: 'border-border text-muted hover:border-secondary'"
|
|
||||||
>
|
|
||||||
Déplacer
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<p class="text-xs text-muted">
|
|
||||||
<span class="text-primary">Hardlink recommandé</span> — le fichier reste dans le client torrent pour le ratio
|
|
||||||
</p>
|
</p>
|
||||||
|
<button @click="renameResult = null" class="text-xs text-muted hover:text-primary">✕</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Toggles -->
|
<!-- Liste séries -->
|
||||||
<div class="settings-card flex flex-col gap-5">
|
<div v-else class="flex flex-col gap-3">
|
||||||
|
<div
|
||||||
<SettingsToggle
|
v-for="serie in filteredSeries"
|
||||||
v-model="form.autoImport"
|
:key="serie.serie_id"
|
||||||
label="Import automatique"
|
class="settings-card flex flex-col gap-0"
|
||||||
description="Importer automatiquement dès qu'un téléchargement est terminé. Vérifie toutes les 5 minutes."
|
|
||||||
/>
|
|
||||||
|
|
||||||
<SettingsToggle
|
|
||||||
v-model="form.nfoSupport"
|
|
||||||
label="NFO / Métadonnées"
|
|
||||||
description="Télécharge les NFO et images depuis GitLab lors de l'import (Kodi, Infuse, etc.)."
|
|
||||||
/>
|
|
||||||
|
|
||||||
<SettingsToggle
|
|
||||||
v-if="form.organizeMode === 'move'"
|
|
||||||
v-model="form.deleteTorrentOnMove"
|
|
||||||
label="Supprimer le torrent après déplacement"
|
|
||||||
description="Supprime automatiquement le torrent du client après un import en mode Déplacer."
|
|
||||||
/>
|
|
||||||
|
|
||||||
<SettingsToggle
|
|
||||||
v-model="form.autoUnimportMissing"
|
|
||||||
label="Désimporter si fichier manquant"
|
|
||||||
description="Si un fichier importé n'est plus trouvé sur le disque lors du scan, il est automatiquement retiré de la bibliothèque."
|
|
||||||
/>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Actions -->
|
|
||||||
<div class="flex items-center gap-3">
|
|
||||||
<button @click="save" :disabled="saving" class="btn-primary">
|
|
||||||
{{ saving ? '...' : 'Sauvegarder' }}
|
|
||||||
</button>
|
|
||||||
<button @click="scan" :disabled="scanning" class="btn-secondary">
|
|
||||||
{{ scanning ? 'Scan...' : 'Analyser médiathèque' }}
|
|
||||||
</button>
|
|
||||||
<span
|
|
||||||
v-if="scanResult"
|
|
||||||
class="text-xs"
|
|
||||||
:class="scanResult.added > 0 ? 'text-green-400' : 'text-muted'"
|
|
||||||
>
|
>
|
||||||
{{ scanResult.found }} fichiers · {{ scanResult.added }} ajoutés
|
<!-- Header série -->
|
||||||
</span>
|
<div class="flex items-center justify-between py-1">
|
||||||
|
<div class="flex items-center gap-2.5">
|
||||||
|
<button @click="toggleSerie(serie.serie_id)" class="text-muted hover:text-primary transition-colors">
|
||||||
|
<svg width="13" height="13" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" fill="none"
|
||||||
|
class="transition-transform" :class="collapsed.has(serie.serie_id) ? '' : 'rotate-180'">
|
||||||
|
<polyline points="18 15 12 9 6 15"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<p class="text-sm font-medium text-primary">{{ serie.serie_title }}</p>
|
||||||
|
<span class="text-xs text-muted">{{ serie.total }} épisode{{ serie.total > 1 ? 's' : '' }}</span>
|
||||||
|
<span v-if="serie.needs_rename > 0"
|
||||||
|
class="text-[10px] px-1.5 py-0.5 rounded bg-yellow-500/10 text-yellow-400 border border-yellow-500/20">
|
||||||
|
{{ serie.needs_rename }} à renommer
|
||||||
|
</span>
|
||||||
|
<span v-if="serie.episodes.filter((e: any) => !e.file_exists).length > 0"
|
||||||
|
class="text-[10px] px-1.5 py-0.5 rounded bg-red-500/10 text-red-400 border border-red-500/20">
|
||||||
|
{{ serie.episodes.filter((e: any) => !e.file_exists).length }} introuvable{{ serie.episodes.filter((e: any) => !e.file_exists).length > 1 ? 's' : '' }}
|
||||||
|
</span>
|
||||||
|
<span v-else-if="serie.needs_rename === 0" class="text-[10px] px-1.5 py-0.5 rounded bg-green-500/10 text-green-400 border border-green-500/20">
|
||||||
|
✓ À jour
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<button v-if="serie.needs_rename > 0" @click="renameAll(serie.serie_id)" :disabled="renamingAll" class="text-xs text-accent hover:underline">
|
||||||
|
Tout renommer
|
||||||
|
</button>
|
||||||
|
<button @click="unimportSerie(serie, false)" :disabled="renamingAll" class="text-xs text-muted hover:text-primary transition-colors">
|
||||||
|
Désimporter
|
||||||
|
</button>
|
||||||
|
<button @click="unimportSerie(serie, true)" :disabled="renamingAll" class="text-xs text-red-400 hover:text-red-300 transition-colors">
|
||||||
|
Supprimer fichiers
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Liste épisodes -->
|
||||||
|
<div v-if="!collapsed.has(serie.serie_id)" class="flex flex-col divide-y divide-border/50 mt-2 -mx-4 px-4">
|
||||||
|
<div
|
||||||
|
v-for="ep in serie.episodes"
|
||||||
|
:key="ep.episode_id"
|
||||||
|
class="flex items-center gap-3 py-2.5"
|
||||||
|
>
|
||||||
|
<!-- Numéro -->
|
||||||
|
<span class="text-xs text-muted font-mono shrink-0 w-14">
|
||||||
|
S{{ String(ep.season_number).padStart(2,'0') }}E{{ String(ep.episode_number).padStart(2,'0') }}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<!-- Noms -->
|
||||||
|
<div class="flex-1 min-w-0">
|
||||||
|
<p class="text-xs text-primary truncate">{{ ep.title }}</p>
|
||||||
|
<div class="flex items-center gap-1.5 mt-0.5">
|
||||||
|
<span class="text-[11px] font-mono text-muted truncate max-w-xs">{{ ep.current_name }}</span>
|
||||||
|
<template v-if="ep.needs_rename">
|
||||||
|
<svg width="10" height="10" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" fill="none" class="shrink-0 text-yellow-400">
|
||||||
|
<line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/>
|
||||||
|
</svg>
|
||||||
|
<span class="text-[11px] font-mono text-yellow-400 truncate max-w-xs">{{ ep.expected_name }}</span>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Actions -->
|
||||||
|
<div class="flex items-center gap-2 shrink-0">
|
||||||
|
<span v-if="!ep.file_exists" class="text-[10px] px-1.5 py-0.5 rounded bg-red-500/10 text-red-400 border border-red-500/20">Introuvable</span>
|
||||||
|
<span v-else-if="!ep.needs_rename" class="text-[10px] text-green-400">✓</span>
|
||||||
|
<button
|
||||||
|
v-else
|
||||||
|
@click="renameSingle(ep)"
|
||||||
|
:disabled="renamingEp[ep.episode_id]"
|
||||||
|
class="text-xs px-2 py-1 rounded-lg border border-yellow-500/30 text-yellow-400 hover:bg-yellow-500/10 transition-colors"
|
||||||
|
>
|
||||||
|
{{ renamingEp[ep.episode_id] ? '…' : 'Renommer' }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
@click="unimportEp(ep, false)"
|
||||||
|
:disabled="renamingEp[ep.episode_id]"
|
||||||
|
class="text-xs px-2 py-1 rounded-lg border border-border text-muted hover:text-primary transition-colors"
|
||||||
|
>
|
||||||
|
Désimporter
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
@click="unimportEp(ep, true)"
|
||||||
|
:disabled="renamingEp[ep.episode_id]"
|
||||||
|
class="text-xs px-2 py-1 rounded-lg border border-red-500/20 text-red-400 hover:bg-red-500/10 transition-colors"
|
||||||
|
>
|
||||||
|
Supprimer
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Folder Picker -->
|
|
||||||
<FolderPicker
|
|
||||||
v-if="picker.open"
|
|
||||||
:initial-path="picker.currentPath"
|
|
||||||
@select="onPickerSelect"
|
|
||||||
@cancel="picker.open = false"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, onMounted } from 'vue'
|
import { ref, computed, onMounted } from 'vue'
|
||||||
import { useToast } from '@/composables/useToast'
|
import { useToast } from '@/composables/useToast'
|
||||||
import FolderPicker from '@/components/FolderPicker.vue'
|
|
||||||
import SettingsToggle from '@/components/settings/SettingsToggle.vue'
|
|
||||||
|
|
||||||
const { add: toast } = useToast()
|
const { add: toast } = useToast()
|
||||||
|
|
||||||
const saving = ref(false)
|
// ─── State ────────────────────────────────────────────────────
|
||||||
const scanning = ref(false)
|
const loading = ref(true)
|
||||||
const isDocker = ref(false)
|
const renamingAll = ref(false)
|
||||||
const scanResult = ref<{ found: number; added: number } | null>(null)
|
const series = ref<any[]>([])
|
||||||
|
const nfoSupport = ref(false)
|
||||||
|
const collapsed = ref<Set<number>>(new Set())
|
||||||
|
const renamingEp = ref<Record<number, boolean>>({})
|
||||||
|
const renameResult = ref<{ done: number; errors: any[] } | null>(null)
|
||||||
|
const showOnlyNeedsRename = ref(false)
|
||||||
|
|
||||||
const form = ref({
|
// ─── Computed ──────────────────────────────────────────────────
|
||||||
mediaPath : '',
|
const totalNeedsRename = computed(() => series.value.reduce((acc, s) => acc + s.needs_rename, 0))
|
||||||
completePath : '',
|
|
||||||
organizeMode : 'hardlink' as 'hardlink' | 'copy' | 'move',
|
|
||||||
nfoSupport : false,
|
|
||||||
autoImport : true,
|
|
||||||
deleteTorrentOnMove : false,
|
|
||||||
autoUnimportMissing : false,
|
|
||||||
})
|
|
||||||
|
|
||||||
const picker = ref<{ open: boolean; field: 'completePath' | 'mediaPath'; currentPath: string }>({
|
const filteredSeries = computed(() =>
|
||||||
open: false,
|
showOnlyNeedsRename.value ? series.value.filter(s => s.needs_rename > 0) : series.value
|
||||||
field: 'completePath',
|
|
||||||
currentPath: '/',
|
|
||||||
})
|
|
||||||
|
|
||||||
// FIX : détection path non configuré (vide ou racine /)
|
|
||||||
function isRootPath(p: string): boolean {
|
|
||||||
return !p || p === '/'
|
|
||||||
}
|
|
||||||
|
|
||||||
const hasUnconfiguredPaths = computed(() =>
|
|
||||||
isRootPath(form.value.completePath) || isRootPath(form.value.mediaPath)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
function openPicker(field: 'completePath' | 'mediaPath') {
|
// ─── Actions ──────────────────────────────────────────────────
|
||||||
picker.value = { open: true, field, currentPath: form.value[field] || picker.value.currentPath || '/' }
|
async function load() {
|
||||||
}
|
loading.value = true
|
||||||
|
|
||||||
function onPickerSelect(path: string) {
|
|
||||||
form.value[picker.value.field] = path
|
|
||||||
picker.value.open = false
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
const [settingsRes, systemRes, infoRes] = await Promise.all([
|
|
||||||
fetch('/api/settings', { credentials: 'include' }),
|
|
||||||
fetch('/api/system', { credentials: 'include' }),
|
|
||||||
fetch('/api/system/info', { credentials: 'include' }),
|
|
||||||
])
|
|
||||||
if (settingsRes.ok) Object.assign(form.value, await settingsRes.json())
|
|
||||||
if (systemRes.ok) isDocker.value = (await systemRes.json()).isDocker
|
|
||||||
if (infoRes.ok) picker.value.currentPath = (await infoRes.json()).defaultPath ?? '/'
|
|
||||||
})
|
|
||||||
|
|
||||||
async function save() {
|
|
||||||
saving.value = true
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/api/settings', {
|
const res = await fetch('/api/organized-summary', { credentials: 'include' })
|
||||||
method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include',
|
if (!res.ok) { toast('Erreur chargement', 'error'); return }
|
||||||
body: JSON.stringify(form.value),
|
const data = await res.json()
|
||||||
})
|
series.value = data.series ?? []
|
||||||
if (res.ok) toast('Configuration sauvegardée', 'success')
|
nfoSupport.value = data.nfo_support ?? false
|
||||||
else toast('Erreur lors de la sauvegarde', 'error')
|
// Replier les séries sans rename par défaut
|
||||||
|
collapsed.value = new Set(series.value.filter(s => s.needs_rename === 0).map((s: any) => s.serie_id))
|
||||||
} finally {
|
} finally {
|
||||||
saving.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function scan() {
|
function toggleSerie(id: number) {
|
||||||
scanning.value = true
|
if (collapsed.value.has(id)) collapsed.value.delete(id)
|
||||||
scanResult.value = null
|
else collapsed.value.add(id)
|
||||||
|
// Forcer la réactivité
|
||||||
|
collapsed.value = new Set(collapsed.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function renameAll(serieId?: number) {
|
||||||
|
renamingAll.value = true
|
||||||
|
renameResult.value = null
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/api/scan', { method: 'POST', credentials: 'include' })
|
const res = await fetch('/api/rename-all', {
|
||||||
if (res.ok) {
|
method : 'POST',
|
||||||
const data = await res.json()
|
headers : { 'Content-Type': 'application/json' },
|
||||||
scanResult.value = { found: data.found, added: data.added }
|
credentials: 'include',
|
||||||
toast(
|
body : JSON.stringify(serieId ? { serie_id: serieId } : {}),
|
||||||
data.added > 0
|
})
|
||||||
? `${data.found} fichiers analysés — ${data.added} ajoutés`
|
const data = await res.json()
|
||||||
: `${data.found} fichiers analysés — rien de nouveau`,
|
renameResult.value = { done: data.done, errors: data.errors ?? [] }
|
||||||
'success'
|
if (data.done > 0) await load()
|
||||||
)
|
|
||||||
} else {
|
|
||||||
toast("Erreur lors de l'analyse", 'error')
|
|
||||||
}
|
|
||||||
} catch {
|
} catch {
|
||||||
toast('Impossible de contacter le serveur', 'error')
|
toast('Impossible de contacter le serveur', 'error')
|
||||||
} finally {
|
} finally {
|
||||||
scanning.value = false
|
renamingAll.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function renameSingle(ep: any) {
|
||||||
|
renamingEp.value[ep.episode_id] = true
|
||||||
|
try {
|
||||||
|
const res = await fetch('/api/rename-episode', {
|
||||||
|
method : 'POST',
|
||||||
|
headers : { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
|
body : JSON.stringify({ episode_id: ep.episode_id, torrent_hash: ep.torrent_hash }),
|
||||||
|
})
|
||||||
|
const data = await res.json()
|
||||||
|
if (!res.ok) { toast(data.error ?? 'Erreur', 'error'); return }
|
||||||
|
toast(`Renommé : ${data.new_name}`, 'success')
|
||||||
|
await load()
|
||||||
|
} catch {
|
||||||
|
toast('Impossible de contacter le serveur', 'error')
|
||||||
|
} finally {
|
||||||
|
renamingEp.value[ep.episode_id] = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function unimportSerie(serie: any, deleteFile: boolean) {
|
||||||
|
if (!confirm(`Désimporter "${serie.serie_title}"${deleteFile ? ' et supprimer les fichiers' : ''} ?`)) return
|
||||||
|
renamingAll.value = true
|
||||||
|
try {
|
||||||
|
const res = await fetch(`/api/organized/${serie.serie_id}?deleteFile=${deleteFile}`, {
|
||||||
|
method: 'DELETE', credentials: 'include',
|
||||||
|
})
|
||||||
|
if (!res.ok) { const d = await res.json(); toast(d.error ?? 'Erreur', 'error'); return }
|
||||||
|
const data = await res.json()
|
||||||
|
toast(`${data.removed} épisode(s) désimporté(s) ✓`, 'success')
|
||||||
|
await load()
|
||||||
|
} catch {
|
||||||
|
toast('Impossible de contacter le serveur', 'error')
|
||||||
|
} finally {
|
||||||
|
renamingAll.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function unimportEp(ep: any, deleteFile: boolean) {
|
||||||
|
renamingEp.value[ep.episode_id] = true
|
||||||
|
try {
|
||||||
|
// On cherche le serie_id depuis la liste
|
||||||
|
const serie = series.value.find(s => s.episodes.some((e: any) => e.episode_id === ep.episode_id))
|
||||||
|
if (!serie) return
|
||||||
|
const res = await fetch(`/api/organized/${serie.serie_id}/${ep.episode_id}?deleteFile=${deleteFile}`, {
|
||||||
|
method : 'DELETE',
|
||||||
|
credentials: 'include',
|
||||||
|
})
|
||||||
|
if (!res.ok) { const d = await res.json(); toast(d.error ?? 'Erreur', 'error'); return }
|
||||||
|
toast(deleteFile ? 'Fichier supprimé ✓' : 'Désimporté ✓', 'success')
|
||||||
|
await load()
|
||||||
|
} catch {
|
||||||
|
toast('Impossible de contacter le serveur', 'error')
|
||||||
|
} finally {
|
||||||
|
renamingEp.value[ep.episode_id] = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(load)
|
||||||
</script>
|
</script>
|
||||||
@@ -112,6 +112,12 @@
|
|||||||
description="Supprime automatiquement le torrent du client après un import en mode Déplacer."
|
description="Supprime automatiquement le torrent du client après un import en mode Déplacer."
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<SettingsToggle
|
||||||
|
v-model="form.autoUnimportMissing"
|
||||||
|
label="Désimporter si fichier manquant"
|
||||||
|
description="Si un fichier importé n'est plus trouvé sur le disque lors du scan, il est automatiquement retiré de la bibliothèque."
|
||||||
|
/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Actions -->
|
<!-- Actions -->
|
||||||
@@ -156,12 +162,13 @@ const isDocker = ref(false)
|
|||||||
const scanResult = ref<{ found: number; added: number } | null>(null)
|
const scanResult = ref<{ found: number; added: number } | null>(null)
|
||||||
|
|
||||||
const form = ref({
|
const form = ref({
|
||||||
mediaPath : '',
|
mediaPath : '',
|
||||||
completePath : '',
|
completePath : '',
|
||||||
organizeMode : 'hardlink' as 'hardlink' | 'copy' | 'move',
|
organizeMode : 'hardlink' as 'hardlink' | 'copy' | 'move',
|
||||||
nfoSupport : false,
|
nfoSupport : false,
|
||||||
autoImport : true,
|
autoImport : true,
|
||||||
deleteTorrentOnMove: false,
|
deleteTorrentOnMove : false,
|
||||||
|
autoUnimportMissing : false,
|
||||||
})
|
})
|
||||||
|
|
||||||
const picker = ref<{ open: boolean; field: 'completePath' | 'mediaPath'; currentPath: string }>({
|
const picker = ref<{ open: boolean; field: 'completePath' | 'mediaPath'; currentPath: string }>({
|
||||||
|
|||||||
Reference in new issue
Block a user