Kapitel 13/Tutorial.md aktualisiert
This commit is contained in:
@@ -429,33 +429,83 @@ Im Ergebnis findest du im Feld `data[0].id` deine **User-ID** (z. B. `123456789`
|
||||
|
||||
8. Pfad 1 - CREATE_AND_DOWNLOAD
|
||||
|
||||
Verkabelung (mehrere VODs – einfach & klar):
|
||||
- **HTTP Request: VODs abrufen** → **Split Out** (Field to Split Out: `data`)
|
||||
- **Split Out** → **Switch (Regeln aus Punkt 7)**
|
||||
- **Switch → Output CREATE_AND_DOWNLOAD** → **SSH: State-Datei anlegen** → **SSH: VOD herunterladen (yt-dlp)**
|
||||
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 (nur wenn State-Datei nicht existiert):
|
||||
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; mkdir -p /srv/clipper/state; printf "%s
|
||||
" "${$json.vodId ?? $json.id ?? $json.data?.id ?? $json.data?.[0]?.id}" > /srv/clipper/state/vod_seen.list`}}
|
||||
{{`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`}}
|
||||
```
|
||||
|
||||
SSH – VOD herunterladen (yt-dlp):
|
||||
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
|
||||
```
|
||||
Hinweis: Passwort aus Nextcloud **App-Passwort** (haben wir bereits erstellt). `rclone config` kann das auch interaktiv einrichten.
|
||||
|
||||
|
||||
SSH – VOD herunterladen nach temp und nach Nextcloud verschieben (yt-dlp + rclone):
|
||||
- Typ: SSH • Credentials: SSH Clipper • Operation: Execute Command • Command is an Expression: ON
|
||||
Command (Expression):
|
||||
```
|
||||
{{`set -euo pipefail; mkdir -p /srv/clipper/watch; URL="https://www.twitch.tv/videos/${$json.vodId ?? $json.id ?? $json.data?.id ?? $json.data?.[0]?.id}"; yt-dlp --no-progress --remux-video mp4 -o "/srv/clipper/watch/%(id)s.%(ext)s" "$URL"`}}
|
||||
{{`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}/" --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-video mp4 -o "$TMP/%(id)s.%(ext)s" "$URL"; \
|
||||
FILE="$TMP/${$json.id}.mp4"; \
|
||||
rclone move "$FILE" "nc:Clipper/VODs/${$json.id}/" --create-empty-src-dirs -v`}}
|
||||
```
|
||||
|
||||
|
||||
Ergebnis:
|
||||
- `/srv/clipper/state/vod_seen.list` existiert und enthält die **erste** VOD-ID (bei Regel 1).
|
||||
- Für **jedes VOD** entsteht unter `/srv/clipper/watch/<VOD_ID>.mp4` eine MP4.
|
||||
- Keine zusätzlichen Code-/Merge-Nodes nötig; der Pfad läuft **pro VOD** einmal über den Switch-Branch.
|
||||
|
||||
- Durch den **Merge (Combine → All Possible Combinations)** liegen **Switch-GO** und **VOD-Daten** zusammen vor; die SSH-Nodes haben alles, was sie brauchen.
|
||||
Reference in New Issue
Block a user