From 7ee98f776c8ee6d4a6514d0adb9424007e32cc2f Mon Sep 17 00:00:00 2001 From: Thomas Dannenberg Date: Thu, 28 Aug 2025 18:54:35 +0000 Subject: [PATCH] Kapitel 13/Tutorial.md aktualisiert --- Kapitel 13/Tutorial.md | 93 +++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 52 deletions(-) diff --git a/Kapitel 13/Tutorial.md b/Kapitel 13/Tutorial.md index 8ab74fa..bf6da7d 100644 --- a/Kapitel 13/Tutorial.md +++ b/Kapitel 13/Tutorial.md @@ -374,67 +374,56 @@ Im Ergebnis findest du im Feld `data[0].id` deine **User-ID** (z. B. `123456789` {"file_exists":true,"non_empty":false,"vods":[]} {"file_exists":true,"non_empty":true,"vods":["123456789","987654321"]} ``` -### 5. Set Node – Felder übernehmen +5. Set Node – Felder übernehmen -# Set Node – Felder übernehmen + # Set Node – Felder übernehmen -file_exists → -```json -{{ JSON.parse($json.stdout).file_exists }} -``` -non_empty → -```json -{{ JSON.parse($json.stdout).non_empty }} -``` -vods → -```json -{{ JSON.parse($json.stdout).vods }} -``` + file_exists → ```json {{ JSON.parse($json.stdout).file_exists }} ``` + non_empty → ```json {{ JSON.parse($json.stdout).non_empty }} ``` + vods → ```json {{ JSON.parse($json.stdout).vods }} ``` + # WICHTIG + - Stelle die Felder auf den Typ Array bzw. Boolean um. + - Aktiviere die Option: Add Option → Ignore Type Conversion Errors → einschalten. -# WICHTIG -- Stelle die Felder auf den Typ Array bzw. Boolean um. -- Aktiviere die Option: Add Option → Ignore Type Conversion Errors → einschalten. - - - -### 6. State ermitteln (Set-Node – EIN Feld) -# State ermitteln -state → -```json -{{ $json.file_exists === false -? 'CREATE_AND_DOWNLOAD' -: ($json.non_empty === false -? 'APPEND_AND_DOWNLOAD' -: 'NEED_CHECK') }} -``` -# WICHTIG -- Aktiviere die Option: Include Other Input Fields → ALL. +6. State ermitteln (Set-Node – EIN Feld) + + # State ermitteln + state → + ```json + {{ $json.file_exists === false + ? 'CREATE_AND_DOWNLOAD' + : ($json.non_empty === false + ? 'APPEND_AND_DOWNLOAD' + : 'NEED_CHECK') }} + ``` + # WICHTIG + - Aktiviere die Option: Include Other Input Fields → ALL. 7. Switch-Node – drei klare Wege -Switch → Property Name: ```json {{ $json.state }} ``` + In diesem Schritt legen wir die Entscheidungspfade in einem **Switch-Node** an. Dafür werden drei Regeln hinzugefügt, die jeweils einen klar benannten Output erzeugen. -Cases: -CREATE_AND_DOWNLOAD → Datei anlegen und VOD sofort downloaden. + ```git + # Switch-Node Einstellungen + Mode: Rules + Property: {{ $json.state_expression }} -APPEND_AND_DOWNLOAD → Datei ist leer → VOD-ID direkt eintragen und downloaden. + # Regeln + 1. Regel: + - Bedingung: {{ $json.state_expression }} is equal to CREATE_AND_DOWNLOAD + - Rename Output: ON + - Output Name: CREATE_AND_DOWNLOAD -NEED_CHECK → Datei existiert und ist nicht leer → hier prüfen, ob die aktuelle VOD-ID schon enthalten ist. + 2. Regel: + - Bedingung: {{ $json.state_expression }} is equal to APPEND_AND_DOWNLOAD + - Rename Output: ON + - Output Name: APPEND_AND_DOWNLOAD -Branch NEED_CHECK - -Set (kurz) - -currentVod → ```json {{ $json.vodId ?? $json.data[0].id }} ``` - -contains_vod → ```json {{ Array.isArray($json.vods) && $json.vods.includes($json.currentVod) }} ``` - -IF Node (einmalig in diesem Branch) - -Bedingung: ```json {{ $json.contains_vod === true }} ``` - -True: Pfad beenden (VOD bereits verarbeitet) - -False: Download & Analyse starten, danach ID anhängen \ No newline at end of file + 3. Regel: + - Bedingung: {{ $json.state_expression }} is equal to NEED_CHECK + - Rename Output: ON + - Output Name: NEED_CHECK + ``` + Damit hat der Switch-Node drei klar benannte Ausgänge, die die weitere Logik steuern. \ No newline at end of file