Sous-processus - Recherche YouTube

Intermédiaire

Ceci est unAIworkflow d'automatisation du domainecontenant 10 nœuds.Utilise principalement des nœuds comme If, Set, Code, YouTube, HttpRequest, combinant la technologie d'intelligence artificielle pour une automatisation intelligente. Explorateur de tendances YouTube par IA - Flux de travail automatisé n8n basé sur Gemini/ChatGPT

Prérequis
  • Peut nécessiter les informations d'identification d'authentification de l'API cible
Aperçu du workflow
Visualisation des connexions entre les nœuds, avec support du zoom et du déplacement
Exporter le workflow
Copiez la configuration JSON suivante dans n8n pour importer et utiliser ce workflow
{
  "id": "IktojxaOHrdHkURm",
  "meta": {
    "instanceId": "ed6d846a2fce1f660ede2e7da800724cca01dc3d0685524a3c917881b7cfcfe9",
    "templateCredsSetupCompleted": true
  },
  "name": "Sub - Youtube Search",
  "tags": [
    {
      "id": "CEVEeZJa4qgPvdpK",
      "name": "youtube",
      "createdAt": "2025-05-27T02:29:43.874Z",
      "updatedAt": "2025-05-27T02:29:43.874Z"
    }
  ],
  "nodes": [
    {
      "id": "5d4d8d36-8f39-4e3c-9527-9d5604e58adc",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -660,
        280
      ],
      "parameters": {
        "inputSource": "passthrough"
      },
      "typeVersion": 1.1
    },
    {
      "id": "09b1a19d-4fb3-4d78-a41b-90da9ab49409",
      "name": "Youtube - Get Video",
      "type": "n8n-nodes-base.youTube",
      "position": [
        -440,
        280
      ],
      "parameters": {
        "limit": 3,
        "filters": {
          "q": "={{ $json.query.search_term }}",
          "regionCode": "US",
          "publishedAfter": "={{ new Date(Date.now() - 2 * 24 * 60 * 60 * 1000).toISOString() }}"
        },
        "options": {
          "order": "relevance",
          "safeSearch": "moderate"
        },
        "resource": "video"
      },
      "credentials": {
        "youTubeOAuth2Api": {
          "id": "KhD0GLQGWl8MtqCs",
          "name": "YouTube - toan.ngo"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d166a037-d601-438d-b493-c443ab552b40",
      "name": "Boucler sur les éléments",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -220,
        280
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "803e7b42-8dd4-48f6-a3c6-247d8235faa7",
      "name": "HTTP - Find Video Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        0,
        200
      ],
      "parameters": {
        "url": "https://www.googleapis.com/youtube/v3/videos?",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "id",
              "value": "={{ $json.id.videoId }}"
            },
            {
              "name": "part",
              "value": "contentDetails,snippet,statistics"
            }
          ]
        },
        "nodeCredentialType": "youTubeOAuth2Api"
      },
      "credentials": {
        "youTubeOAuth2Api": {
          "id": "KhD0GLQGWl8MtqCs",
          "name": "YouTube - toan.ngo"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "771aebee-d468-4352-ad25-7d13b09836b8",
      "name": "Code - Retrieve Data From Mémoire",
      "type": "n8n-nodes-base.code",
      "position": [
        0,
        0
      ],
      "parameters": {
        "jsCode": "const workflowStaticData = $getWorkflowStaticData('global');\n\nconst lastExecution = workflowStaticData.lastExecution;\n\nreturn lastExecution;"
      },
      "typeVersion": 2,
      "alwaysOutputData": false
    },
    {
      "id": "c1afc8ff-6c26-433b-8b2c-6debda964ae1",
      "name": "Field - Response",
      "type": "n8n-nodes-base.set",
      "position": [
        220,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b9b9117b-ea14-482e-a13b-e68b8e6b441d",
              "name": "response",
              "type": "string",
              "value": "={{ $input.all() }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fd80746e-6a72-46e3-aefc-d7404cd3b50a",
      "name": "If - Longer Than 3",
      "type": "n8n-nodes-base.if",
      "position": [
        220,
        280
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "08ba3db9-6bcf-47f8-a74d-9e26f28cb08f",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ \n  (() => {\n    const duration = $json.items[0].contentDetails.duration;\n\n    // Helper function to convert ISO 8601 duration to seconds\n    const iso8601ToSeconds = iso8601 => {\n      const match = iso8601.match(/PT(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?/);\n      const hours = parseInt(match[1] || 0, 10);\n      const minutes = parseInt(match[2] || 0, 10);\n      const seconds = parseInt(match[3] || 0, 10);\n      return hours * 3600 + minutes * 60 + seconds;\n    };\n\n    // Convert duration to seconds\n    const durationInSeconds = iso8601ToSeconds(duration);\n\n    // Check if greater than 210 seconds (3 minutes 30 seconds)\n    return durationInSeconds > 210;\n  })() \n}}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "bd86dca7-fdcc-4722-9247-1d5d5f16bb86",
      "name": "Field - Group Data",
      "type": "n8n-nodes-base.set",
      "position": [
        440,
        280
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "47c172ad-90c8-4cf6-a9f5-50607e04cc90",
              "name": "id",
              "type": "string",
              "value": "={{ $json.items[0].id }}"
            },
            {
              "id": "9e639efa-0714-4b06-9847-f7b4b2fbef59",
              "name": "viewCount",
              "type": "string",
              "value": "={{ $json.items[0].statistics.viewCount }}"
            },
            {
              "id": "93328f00-91b8-425b-ad0f-a330b2f95242",
              "name": "likeCount",
              "type": "string",
              "value": "={{ $json.items[0].statistics.likeCount }}"
            },
            {
              "id": "015b0fb2-2a98-464c-a21b-51100616f26a",
              "name": "commentCount",
              "type": "string",
              "value": "={{ $json.items[0].statistics.commentCount }}"
            },
            {
              "id": "cf1e1ec3-a138-42b8-8747-d249afa58dd3",
              "name": "description",
              "type": "string",
              "value": "={{ $json.items[0].snippet.description }}"
            },
            {
              "id": "c5c9a3a2-b820-4932-a38a-e21102992215",
              "name": "title",
              "type": "string",
              "value": "={{ $json.items[0].snippet.title }}"
            },
            {
              "id": "38216ead-1f8d-4f93-b6ad-5ef709a1ad2a",
              "name": "channelTitle",
              "type": "string",
              "value": "={{ $json.items[0].snippet.channelTitle }}"
            },
            {
              "id": "ff34194d-3d46-43a8-9127-84708987f536",
              "name": "tags",
              "type": "string",
              "value": "={{ $json.items[0].snippet.tags.join(', ') }}"
            },
            {
              "id": "e50b0f7b-3e37-4557-8863-d68d4fa505c8",
              "name": "channelId",
              "type": "string",
              "value": "={{ $json.items[0].snippet.channelId }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f9326f4d-16e5-4078-9273-7ee3fb1c70a3",
      "name": "Code - Save Data To Mémoire",
      "type": "n8n-nodes-base.code",
      "position": [
        660,
        360
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const workflowStaticData = $getWorkflowStaticData('global');\n\nif (!workflowStaticData.lastExecution || typeof workflowStaticData.lastExecution.response !== 'string') {\n  workflowStaticData.lastExecution = { response: '' };\n}\n\nconst regexes = [\n  { pattern: /https?:\\/\\/\\S+|www\\.\\S+/g, replace: '' },\n  { pattern: /[\\u{1F600}-\\u{1F64F}\\u{1F300}-\\u{1F5FF}\\u{1F680}-\\u{1F6FF}\\u{2600}-\\u{26FF}\\u{2700}-\\u{27BF}]/gu, replace: '' },\n  { pattern: /[\\r\\n\\\\]+/g, replace: ' ' },\n  { pattern: / {2,}/g, replace: ' ' } \n];\n\nfunction sanitize(text) {\n  return regexes.reduce((str, { pattern, replace }) => str.replace(pattern, replace), text).trim();\n}\n\nconst item = { ...$input.item };\nif (item.description) {\n  item.description = sanitize(item.description);\n}\n\nconst sanitizedItem = sanitize(JSON.stringify(item));\n\nif (workflowStaticData.lastExecution.response) {\n  workflowStaticData.lastExecution.response += ' ### NEXT VIDEO FOUND: ### ';\n}\nworkflowStaticData.lastExecution.response += sanitizedItem;\n\nreturn workflowStaticData.lastExecution;"
      },
      "typeVersion": 2
    },
    {
      "id": "49187d4e-5258-48a2-ae9a-fe82a82b75b9",
      "name": "Note adhésive",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -900,
        -140
      ],
      "parameters": {
        "width": 580,
        "height": 260,
        "content": "## Sub - Youtube Search\nWebsite\thttps://www.agentcircle.ai/\nDiscord Global\thttps://discord.com/invite/jySQ2PNm\nFB Page Global\thttps://www.facebook.com/agentcircle/\nFB Group Global\thttps://www.facebook.com/groups/aiagentcircle/\nGumroad\thttp://agentcircle.gumroad.com/\nX\thttps://x.com/agent_circle\nYouTube\thttps://www.youtube.com/@agentcircle\nLinkedin\thttps://www.linkedin.com/company/agentcircle"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {
    "When Executed by Another Workflow": [
      {
        "json": {
          "query": {
            "search_term": "cat games gameplay"
          }
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "252a4d1e-eb32-4f40-b61a-c80ba62d1d57",
  "connections": {
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Code - Retrieve Data From Memory",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "803e7b42-8dd4-48f6-a3c6-247d8235faa7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "bd86dca7-fdcc-4722-9247-1d5d5f16bb86": {
      "main": [
        [
          {
            "node": "Code - Save Data To Memory",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fd80746e-6a72-46e3-aefc-d7404cd3b50a": {
      "main": [
        [
          {
            "node": "bd86dca7-fdcc-4722-9247-1d5d5f16bb86",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "09b1a19d-4fb3-4d78-a41b-90da9ab49409": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "803e7b42-8dd4-48f6-a3c6-247d8235faa7": {
      "main": [
        [
          {
            "node": "fd80746e-6a72-46e3-aefc-d7404cd3b50a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code - Save Data To Memory": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code - Retrieve Data From Memory": {
      "main": [
        [
          {
            "node": "c1afc8ff-6c26-433b-8b2c-6debda964ae1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5d4d8d36-8f39-4e3c-9527-9d5604e58adc": {
      "main": [
        [
          {
            "node": "09b1a19d-4fb3-4d78-a41b-90da9ab49409",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Foire aux questions

Comment utiliser ce workflow ?

Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.

Dans quelles scénarios ce workflow est-il adapté ?

Intermédiaire - Intelligence Artificielle

Est-ce payant ?

Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.

Informations sur le workflow
Niveau de difficulté
Intermédiaire
Nombre de nœuds10
Catégorie1
Types de nœuds8
Description de la difficulté

Adapté aux utilisateurs expérimentés, avec des workflows de complexité moyenne contenant 6-15 nœuds

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34