Kapitel 13/Tutorial.md aktualisiert
This commit is contained in:
@@ -344,7 +344,7 @@ Im Ergebnis findest du im Feld `data[0].id` deine **User-ID** (z. B. `123456789`
|
||||
2. **HTTP Request (Get Videos):**
|
||||
|
||||
```
|
||||
https://api.twitch.tv/helix/videos?user_id=<DEINE_TWITCH_USER_ID>&type=archive&first=1
|
||||
https://api.twitch.tv/helix/videos?user_id=<DEINE_TWITCH_USER_ID>&type=archive
|
||||
```
|
||||
|
||||
3. **SSH Credentials in n8n anlegen**
|
||||
@@ -427,36 +427,60 @@ Im Ergebnis findest du im Feld `data[0].id` deine **User-ID** (z. B. `123456789`
|
||||
```
|
||||
Damit hat der Switch-Node drei klar benannte Ausgänge, die die weitere Logik steuern.
|
||||
|
||||
8. Pfad CREATE_AND_DOWNLOAD
|
||||
8. Regel 1: CREATE_AND_DOWNLOAD
|
||||
|
||||
Verkabelung:
|
||||
Switch-Node (Output: CREATE_AND_DOWNLOAD)
|
||||
→ SSH: State-Datei anlegen
|
||||
→ SSH: VOD herunterladen (yt-dlp)
|
||||
Verkabelung (ein einzelnes VOD):
|
||||
- Switch-Output **CREATE_AND_DOWNLOAD** → **Merge (Combine → All Possible Combinations)** (Eingang 1)
|
||||
- **HTTP Request: VOD-Daten abrufen** → **Item Lists: Split Out Items (Input = data)** → **Merge (Combine → All Possible Combinations)** (Eingang 2)
|
||||
- **Merge (Combine → All Possible Combinations)** → **SSH: State-Datei anlegen** → **SSH: VOD herunterladen (yt-dlp)**
|
||||
|
||||
|
||||
Node 1: SSH – State-Datei anlegen
|
||||
Typ: SSH
|
||||
Credentials: SSH Clipper
|
||||
Operation: Execute Command
|
||||
Command is an Expression: ON
|
||||
> [!NOTE]
|
||||
> Durch **Split Out Items** wird aus jedem Eintrag in `data[]` genau **ein Item**. Wenn Twitch nur ein aktuelles VOD liefert, ergibt sich 1×1 = 1 Item. > Wenn mehrere VODs geliefert werden, laufen die folgenden Nodes **pro VOD** einmal.
|
||||
|
||||
Item Lists – Einstellungen (nach dem HTTP Request):
|
||||
- Typ: Item Lists
|
||||
- Operation: **Split Out Items**
|
||||
- Field to Split Out: **data**
|
||||
|
||||
|
||||
Merge – Einstellungen:
|
||||
- Typ: Merge
|
||||
- Mode: **Combine**
|
||||
- Combine Mode: **All Possible Combinations**
|
||||
- Eingang 1: vom Switch-Branch (liefert 1 Item)
|
||||
- Eingang 2: vom **Split Out Items** (liefert N Items)
|
||||
- Ergebnis: **1×N** Kombination → ein Item **pro VOD**, VOD-Felder sind im JSON verfügbar (z. B. `id`, `title`, …).
|
||||
|
||||
|
||||
Set (optional, empfehlenswert):
|
||||
- `vodId` → `{{ $json.id ?? $json.data?.id ?? $json.data?.[0]?.id }}`
|
||||
|
||||
|
||||
SSH – State-Datei anlegen (nur wenn State-Datei **nicht existiert**):
|
||||
- Typ: SSH
|
||||
- Credentials: SSH Clipper
|
||||
- Operation: Execute Command
|
||||
- Command is an Expression: ON
|
||||
Command (Expression):
|
||||
```git
|
||||
```
|
||||
{{`set -euo pipefail; mkdir -p /srv/clipper/state; printf "%s
|
||||
" "${$json.data[0].id}" > /srv/clipper/state/vod_seen.list`}}
|
||||
" "${$json.vodId ?? $json.id}" > /srv/clipper/state/vod_seen.list`}}
|
||||
```
|
||||
|
||||
Node 2: SSH – VOD herunterladen (yt-dlp)
|
||||
Typ: SSH
|
||||
Credentials: SSH Clipper
|
||||
Operation: Execute Command
|
||||
Command is an Expression: ON
|
||||
|
||||
SSH – VOD herunterladen (yt-dlp):
|
||||
- Typ: SSH
|
||||
- Credentials: SSH Clipper
|
||||
- Operation: Execute Command
|
||||
- Command is an Expression: ON
|
||||
Command (Expression):
|
||||
```git
|
||||
{{`set -euo pipefail; mkdir -p /srv/clipper/watch; URL="https://www.twitch.tv/videos/${$json.data[0].id}"; yt-dlp --no-progress --remux-video mp4 -o "/srv/clipper/watch/%(id)s.%(ext)s" "$URL"`}}
|
||||
```
|
||||
{{`set -euo pipefail; mkdir -p /srv/clipper/watch; URL="https://www.twitch.tv/videos/${$json.vodId ?? $json.id}"; yt-dlp --no-progress --remux-video mp4 -o "/srv/clipper/watch/%(id)s.%(ext)s" "$URL"`}}
|
||||
```
|
||||
|
||||
|
||||
Ergebnis:
|
||||
- /srv/clipper/state/vod_seen.list existiert und enthält die aktuelle VOD-ID (eine Zeile).
|
||||
- Das VOD liegt als MP4 unter /srv/clipper/watch/<VOD_ID>.mp4 bereit.
|
||||
- `/srv/clipper/state/vod_seen.list` existiert und enthält die **erste** VOD-ID.
|
||||
- Für **jedes VOD** wird eine MP4 unter `/srv/clipper/watch/<VOD_ID>.mp4` gespeichert.
|
||||
- Durch **Split Out Items + Combine (All Possible Combinations)** werden **alle VODs** zuverlässig durch den Pfad geführt.
|
||||
|
||||
Reference in New Issue
Block a user