movetdarr.sh v2: FileFlows-Leichen-Handling + Fehler-Reporting (SAB PostProcessing Fix 05.09.2026)
This commit is contained in:
parent
0ae625d00a
commit
9373aef95e
1 changed files with 55 additions and 0 deletions
55
usenet-scripts/movetdarr.sh
Normal file
55
usenet-scripts/movetdarr.sh
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
# movetdarr.sh v2 — SABnzbd PostProcessing: Download -> FileFlows-Eingang (/tdarr/complete)
|
||||
# Fixes 05.09.2026:
|
||||
# - Vor dem mv: bestehendes Zielverzeichnis ohne Video-Datei (FileFlows-Leichen) wird entfernt
|
||||
# - Fehler beim mv werden GEMELDET (exit 1) statt still zu scheitern
|
||||
# - Ziel mit existierender Video-Datei: Download behalten + WARNUNG (kein Datenverlust)
|
||||
DIR="$1"
|
||||
CATEGORY="$5"
|
||||
STATUS="$7"
|
||||
|
||||
LOGFILE="/usenet/scripts/postprocess.log"
|
||||
log() { echo "$(date '+%d.%m.%Y %H:%M:%S'): $1" >> "$LOGFILE"; }
|
||||
|
||||
log "Start - Kategorie=$CATEGORY Status=$STATUS Dir=$DIR"
|
||||
|
||||
if [ "$STATUS" != "0" ]; then
|
||||
log "Download fehlgeschlagen, ueberspringe"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$DIR" ]; then
|
||||
log "Quellverzeichnis existiert nicht: $DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DEST="/tdarr/complete/${CATEGORY}"
|
||||
BASENAME="$(basename "$DIR")"
|
||||
TARGET="$DEST/$BASENAME"
|
||||
|
||||
mkdir -p "$DEST"
|
||||
|
||||
# Leichen-Handling: existiert das Ziel schon?
|
||||
if [ -d "$TARGET" ]; then
|
||||
# Enthaelt es Video-Dateien?
|
||||
if ls "$TARGET"/*.mkv "$TARGET"/*.mp4 "$TARGET"/*.avi >/dev/null 2>&1; then
|
||||
log "WARNUNG: Ziel $TARGET enthaelt bereits Video-Dateien - NICHT ueberschrieben, Download bleibt in $DIR"
|
||||
exit 2
|
||||
fi
|
||||
log "Entferne FileFlows-Restverzeichnis (keine Videos enthalten): $TARGET"
|
||||
rm -rf "$TARGET"
|
||||
if [ $? -ne 0 ]; then
|
||||
log "FEHLER: konnte Restverzeichnis $TARGET nicht entfernen"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mv "$DIR" "$DEST/"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
log "Erfolgreich verschoben nach $TARGET"
|
||||
exit 0
|
||||
else
|
||||
log "FEHLER beim Verschieben nach $TARGET (Quelle bleibt: $DIR)"
|
||||
exit 1
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue