{
  "name": "My workflow",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "e844f7d8-4f9e-4690-9675-131ce1d5afe9",
      "name": "When clicking \u2018Execute workflow\u2019"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://id.twitch.tv/oauth2/token",
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "client_id",
              "value": "70se1fwvsjoxn9weryhj19bp24lqjn"
            },
            {
              "name": "client_secret",
              "value": "dpmc0l6xl76dcelra5ga4imnukh3e8"
            },
            {
              "name": "grant_type",
              "value": "client_credentials"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        220,
        0
      ],
      "id": "47d1b112-7d85-45cd-8629-04d4ef4fcaf5",
      "name": "Get Token Twitch"
    },
    {
      "parameters": {
        "url": "https://api.twitch.tv/helix/users?login=anyme023",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$node[\"Get Token Twitch\"].json[\"access_token\"]}}"
            },
            {
              "name": "Client-Id",
              "value": "70se1fwvsjoxn9weryhj19bp24lqjn"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        400,
        0
      ],
      "id": "d6e61afa-92c1-4e8f-8158-d6bc2b0220bb",
      "name": "Get User Id"
    },
    {
      "parameters": {
        "url": "=https://api.twitch.tv/helix/clips?broadcaster_id={{$node[\"Get User Id\"].json[\"data\"][0][\"id\"]}}&first=5",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$node[\"Get Token Twitch\"].json[\"access_token\"]}}"
            },
            {
              "name": "Client-ID",
              "value": "70se1fwvsjoxn9weryhj19bp24lqjn"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        580,
        0
      ],
      "id": "29ce3380-1098-47b0-8a49-ff9973871a38",
      "name": "Get Clips"
    },
    {
      "parameters": {
        "command": "yt-dlp --ffmpeg-location /usr/bin/ffmpeg \"https://www.twitch.tv/videos/2514583130\" -o \"/data/%(title)s.%(ext)s\""
      },
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        520,
        420
      ],
      "id": "49c650c8-ac5c-442e-be6e-e98116e3f4fc",
      "name": "Download Rediff1"
    },
    {
      "parameters": {
        "command": "ffmpeg -i '/data/YA DES PTITS GANTEEEE !discord !don.mp4' -ar 16000 -ac 1 -c:a pcm_s16le /data/audio.wav"
      },
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        780,
        420
      ],
      "id": "05810b5a-0a8f-439b-824a-5960864ee919",
      "name": "Converti en fichier audio1"
    },
    {
      "parameters": {
        "executeOnce": false,
        "command": "=yt-dlp \"{{$json[\"url\"]}}\" -o \"/data/{{$json[\"id\"]}}.mp4\"\n"
      },
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        980,
        0
      ],
      "id": "54465326-9fe7-42e9-a335-2509f9e5d8c2",
      "name": "Download Clips"
    },
    {
      "parameters": {
        "executeOnce": false,
        "command": "=node /scripts/uploadTikTok.js \"/data/{{ $('clips').item.json.id }}.mp4\" \"\ud83d\udd25 {{ $('clips').item.json.title }} #Twitch #Anyme\"\n"
      },
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        1200,
        0
      ],
      "id": "19c0c7a1-5401-4ad8-9497-706bbfb5e853",
      "name": "Execute Command"
    },
    {
      "parameters": {
        "jsCode": "return items[0].json.data.map(item => {\n  return { json: item };\n});\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        780,
        0
      ],
      "id": "66e3fd92-cfb1-474b-b6d1-1798711896ec",
      "name": "clips"
    }
  ],
  "connections": {
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Get Token Twitch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Token Twitch": {
      "main": [
        [
          {
            "node": "Get User Id",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get User Id": {
      "main": [
        [
          {
            "node": "Get Clips",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Clips": {
      "main": [
        [
          {
            "node": "clips",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Clips": {
      "main": [
        [
          {
            "node": "Execute Command",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "clips": {
      "main": [
        [
          {
            "node": "Download Clips",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "63a321a8-7246-4b72-9c30-a781c7a86357",
  "id": "p5qwL2baSxzp6VPX",
  "tags": []
}