Kapitel 13/Tutorial.md aktualisiert

This commit is contained in:
2025-08-29 07:55:54 +00:00
parent ffefc20f7e
commit b3de348c09

View File

@@ -454,94 +454,3 @@ Im Ergebnis findest du im Feld `data[0].id` deine **User-ID** (z. B. `123456789`
4) Verbindung testen (explizite Config-Pfadverwendung empfohlen)
```bash
rclone ls nc: --config /home/clipper/.config/rclone/rclone.conf
```
**Arbeitsverzeichnis für die folgenden Schritte:**
- In n8n ist das Working Directory der SSH-Credentials auf **/srv/clipper** gesetzt.
- Für manuelle Tests:
```bash
cd /srv/clipper
```
> **Entscheidung & Begründung**
> Wir nutzen rclone statt dauerhaften Mounts, weil es einfacher und robuster ist. rclone lädt Dateien hoch, kann Verbindungen wiederholen und löscht lokale Kopien automatisch.
---
Verkabelung (Switch-GO **und** Split-Daten zusammenführen):
- **HTTP Request: VODs abrufen** → **Split Out** (Field to Split Out: `data`) → (liefert N VOD-Items)
- **Split Out** → **Merge (Combine → All Possible Combinations)** (Eingang 2)
- **Switch (Regeln aus Punkt 7)** → **Output CREATE_AND_DOWNLOAD** → **Merge (Combine → All Possible Combinations)** (Eingang 1)
- **Merge (Combine → All Possible Combinations)** → **SSH: State-Datei anlegen** → **SSH: VOD herunterladen (yt-dlp)**
Merge Einstellungen:
- Node: **Merge**
- Mode: **Combine**
- Combine Mode: **All Possible Combinations**
- Eingang 1: **Switch → CREATE_AND_DOWNLOAD** (liefert das „GO“)
- Eingang 2: **Split Out** (liefert VOD-Daten)
- Ergebnis: **1×N** Kombination pro VOD-Item → ab hier sind **GO** und **VOD-Felder** im selben Item vorhanden.
Split Out Einstellungen:
- Node: **Split Out**
- Operation: **Split Out Items**
- **Field to Split Out:** `data`
SSH State-Datei anlegen (robust für mehrere Items):
- Typ: SSH • Credentials: SSH Clipper • Operation: Execute Command • Command is an Expression: ON
Command (Expression):
```
{{`set -euo pipefail; \
STATE="/srv/clipper/state/vod_seen.list"; \
mkdir -p "$(dirname "$STATE")"; \
if [ -s "$STATE" ]; then printf "%s
" "${$json.id}" >> "$STATE"; else printf "%s
" "${$json.id}" > "$STATE"; fi`}}
```
Vorbereitung Nextcloud-Anbindung (einmalig im Clipper-LXC, als Benutzer *clipper*):
- `sudo apt install -y rclone`
- Konfigurationsdatei: `/home/clipper/.config/rclone/rclone.conf`
```
[nc]
type = webdav
url = https://DEINE_NEXTCLOUD_DOMAIN/remote.php/dav/files/DEIN_USER/
vendor = nextcloud
user = DEIN_USER
pass = DEIN_APP_PASSWORT_OBFUSCATED
```
> [!NOTE]
> Passwort aus Nextcloud **App-Passwort** (haben wir bereits erstellt). `rclone config` kann das auch interaktiv einrichten.
SSH VOD herunterladen nach temp und in Nextcloud verschieben (yt-dlp + rclone):
- Typ: SSH • Credentials: SSH Clipper • Operation: Execute Command • Command is an Expression: ON
Command (Expression):
```
{{`set -euo pipefail; \
TMP="/srv/clipper/temp"; \
mkdir -p "$TMP"; \
URL="${$json.url || ("https://www.twitch.tv/videos/" + $json.id)}"; \
yt-dlp --no-progress --remux-video mp4 -o "$TMP/%(id)s.%(ext)s" "$URL"; \
FILE="$TMP/${$json.id}.mp4"; \
rclone move "$FILE" "nc:Clipper/VODs/${$json.id}/" \
--config /home/clipper/.config/rclone/rclone.conf \
--create-empty-src-dirs -v`}}
```
Ergebnis:
- Download läuft lokal nach `/srv/clipper/temp`.
- Upload nach Nextcloud (`nc:`) mit automatischem Löschen.
- Kein Speicherstau, auch wenn viele VODs anstehen.
- Empfehlung: **Split In Batches (Batch Size = 1)** in n8n, damit die Items nacheinander laufen und der LXC nicht überlastet wird.
{{`set -euo pipefail; \
TMP="/srv/clipper/temp"; \
mkdir -p "$TMP"; \
URL="${$json.url || ("https://www.twitch.tv/videos/" + $json.id)}"; \
yt-dlp --no-progress --remux-vi