{
  "name": "Auto Clip & Publish to TikTok/YouTube",
  "nodes": [
    {
      "parameters": {
        "url": "https://www.googleapis.com/youtube/v3/search?channelId=<YOUR_CHANNEL_ID>&part=snippet,id&order=date&key=<YOUR_YOUTUBE_API_KEY>",
        "options": {}
      },
      "name": "YouTube Trigger",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        200,
        300
      ]
    },
    {
      "parameters": {
        "command": "yt-dlp -f best -o '/tmp/{{ $json['id']['videoId'] }}.mp4' {{ $json['id']['videoId'] }}"
      },
      "name": "Download Video",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        400,
        300
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://api.gemini-ai.com/extract-clips",
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "{ \"video_path\": \"/tmp/{{ $json['id']['videoId'] }}.mp4\", \"format\": \"vertical\", \"clips_count\": 3 }"
      },
      "name": "AI Clip Extraction",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        600,
        300
      ]
    },
    {
      "parameters": {
        "command": "ffmpeg -i /tmp/{{ $json['clip_name'] }}.mp4 -vf \"scale=1080:1920\" /tmp/final_{{ $json['clip_name'] }}.mp4"
      },
      "name": "FFmpeg Resize",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        800,
        300
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://api.tiktok.com/upload/video",
        "jsonParameters": true,
        "bodyParametersJson": "{ \"video_path\": \"/tmp/final_{{ $json['clip_name'] }}.mp4\", \"caption\": \"#shorts #viral\", \"tags\": [\"gaming\", \"fun\"] }"
      },
      "name": "Upload to TikTok",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1000,
        300
      ]
    },
    {
      "parameters": {
        "resource": "video",
        "operation": "upload",
        "additionalFields": {},
        "title": "{{$json['title']}}",
        "description": "{{$json['description']}}",
        "tags": [
          "shorts",
          "viral"
        ],
        "filePath": "/tmp/final_{{$json['clip_name']}}.mp4"
      },
      "name": "Upload to YouTube Shorts",
      "type": "n8n-nodes-base.youtube",
      "typeVersion": 1,
      "position": [
        1000,
        500
      ]
    }
  ],
  "connections": {
    "YouTube Trigger": {
      "main": [
        [
          {
            "node": "Download Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Video": {
      "main": [
        [
          {
            "node": "AI Clip Extraction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Clip Extraction": {
      "main": [
        [
          {
            "node": "FFmpeg Resize",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FFmpeg Resize": {
      "main": [
        [
          {
            "node": "Upload to TikTok",
            "type": "main",
            "index": 0
          },
          {
            "node": "Upload to YouTube Shorts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}