N
n8n Store
Workflow Market
YouTube Subtitles Report Generator

YouTube Subtitles Report Generator

by rckflr0 views

描述

分类

⚙️ Automation

使用的节点

n8n-nodes-base.coden8n-nodes-base.webhookn8n-nodes-base.stickyNoten8n-nodes-base.httpRequestn8n-nodes-base.httpRequestn8n-nodes-base.respondToWebhook@n8n/n8n-nodes-langchain.chainLlm@n8n/n8n-nodes-langchain.lmChatGoogleGemini
价格免费
浏览量0
最后更新11/28/2025
workflow.json
{
  "id": "nP0jpScffi653CjX",
  "meta": {
    "instanceId": "92786e96ce436aecd3a1d62d818a74e51ca684bb36c805928bef93a3b46549ad"
  },
  "name": "YouTube Subtitles Report Generator",
  "tags": [],
  "nodes": [
    {
      "id": "60e90a8d-d97a-4e9b-91f4-cc24af3bf22d",
      "name": "Trigger Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -280,
        0
      ],
      "webhookId": "97aa1730-20ba-425c-852d-d08710a7f895",
      "parameters": {
        "path": "c18956b9-f9b7-4fc8-b01c-67d5c9eeddd9",
        "options": {},
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "8c51d64f-e380-4bee-9ce6-d0417a833167",
      "name": "Extract Subtitles URLs",
      "type": "n8n-nodes-base.code",
      "position": [
        320,
        0
      ],
      "parameters": {
        "jsCode": "// Get the HTML content\nconst html = items[0].json.data;\n\n// Search for the subtitles block in the HTML\nconst match = html.match(/\\\"captions\\\":\\\\{.*?\\\\}/);\n\nif (!match) {\n    throw new Error(\"No subtitles information found in the HTML.\");\n}\n\n// Extract the subtitles block\nconst captionsBlock = match[0];\n\n// Search for all base URLs of subtitles\nconst baseUrlMatches = [...captionsBlock.matchAll(/\\\"baseUrl\\\":\\\"(.*?)\\\"/g)];\n\nif (!baseUrlMatches.length) {\n    throw new Error(\"No subtitle URLs found.\");\n}\n\n// Decode and clean all base URLs\nconst baseUrls = baseUrlMatches.map(match => \n    decodeURIComponent(match[1]).replace(/\\\\\\u0026/g, \"&\")\n);\n\n// Return all URLs as the node's output\nreturn baseUrls.map(url => ({ json: { baseUrl: url } }));\n"
      },
      "typeVersion": 2
    },
    {
      "id": "87193be8-889e-464c-b4b6-08486b5f187c",
      "name": "Fetch Video HTML",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -20,
        0
      ],
      "parameters": {
        "url": "https://www.youtube.com/watch",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "v",
              "value": "={{ $json.query.id }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "User-Agent",
              "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
            },
            {
              "name": "Accept",
              "value": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
            },
            {
              "name": "Accept-Language",
              "value": "en-US,en;q=0.5"
            },
            {
              "name": "Connection",
              "value": "keep-alive"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "73db26d3-7934-4dfe-af79-4827c64a9872",
      "name": "Fetch Subtitles Content",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        660,
        0
      ],
      "parameters": {
        "url": "={{ $json.baseUrl }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "fb7aa63c-9664-4311-ba29-8e46eb3b02e2",
      "name": "Generate Analytical Report",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        900,
        0
      ],
      "parameters": {
        "text": "={{ $json.data }}",
        "messages": {
          "messageValues": [
            {
              "message": "**Prompt:**  \nYour task is to process subtitles in XML format and generate an **analytical report** focusing on the main theme of the transcript. The report should focus solely on the theme and must not explicitly refer to the source of the content (e.g., avoid phrases like \"this video\" or \"this dialogue\").  \n\n**Instructions:**  \n1. **Input:**  \n   - You will receive subtitles in XML format. This format will include tags such as <text>, <cue>, or similar that structure the data.  \n2. **Extraction:**  \n   - Ignore the XML tags and extract only the textual content.  \n   - Maintain consistency and logical flow of the content during extraction.  \n3. **Analysis:**  \n   - Identify the main ideas, key concepts, recurring themes, and connections between them.  \n   - Focus on the themes discussed and their overall relevance.  \n4. **Report:**  \n   - Write a direct and analytical report that synthesizes the central theme.  \n   - Use formal and objective language without referencing the format or source of the subtitles.  \n   - Ensure the report is clear, well-structured, and centered on the theme.  \n\n**Report Format:**  \n- **Title:** A brief phrase capturing the essence of the main theme.  \n- **Body of the report:** An analytical description of the main theme in **a maximum of 3 paragraphs**, with concise and coherent explanations.  \n\n**Example Output:**  \n\n**Title:** The Ethical Challenges of Artificial Intelligence  \n\n**Report:**  \nArtificial intelligence presents significant challenges in areas such as privacy, fairness, and automated decision-making. Its implementation in critical sectors such as healthcare, justice, and security has sparked debates about inherent biases and lack of transparency. Additionally, there is growing concern over the ethical implications of automation, including its impact on employment and the global economy. Finally, the importance of establishing strong regulatory frameworks is highlighted to balance technological innovation with the protection of human rights.  \n\nApply this structure to any XML subtitle to transform it into a clear and professional thematic report."
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.5
    },
    {
      "id": "64604d71-c0ef-465d-a2f2-9dabd8456a89",
      "name": "AI Model Configuration",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        980,
        200
      ],
      "parameters": {
        "options": {
          "temperature": 0.4
        },
        "modelName": "models/gemini-1.5-flash-002"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "ll8OrIkHyNF0nCKT",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fabb904d-b27d-4202-9b2d-8b1d76c6a597",
      "name": "Return Analytical Report",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1260,
        0
      ],
      "parameters": {
        "options": {},
        "respondWith": "text",
        "responseBody": "={{ $json.text }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "c7345678-9abc-4ef0-8bdf-1234567890ab",
      "name": "Workflow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        0
      ],
      "parameters": {
        "height": 200,
        "content": "This workflow processes YouTube video subtitles to generate a thematic analytical report.\n\nSteps:\n1. Trigger the workflow using the Webhook node with a YouTube video ID.\n2. Fetch HTML content and extract subtitle data.\n3. Process the subtitles and generate an AI-powered analytical report.\n4. Return the report as the response to the webhook.\n\nNotes:\n- This workflow extracts data directly from YouTube's public HTML, requiring no API key.\n- Execution costs depend on the language model used and the length of the video (token count).\n- Using the free tier of models like Google Gemini is recommended to minimize costs."
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "01e378ed-fb29-4826-9d43-5ed5cf8579de",
  "connections": {
    "Trigger Webhook": {
      "main": [
        [
          {
            "node": "Fetch Video HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Video HTML": {
      "main": [
        [
          {
            "node": "Extract Subtitles URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Model Configuration": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Analytical Report",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Extract Subtitles URLs": {
      "main": [
        [
          {
            "node": "Fetch Subtitles Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Subtitles Content": {
      "main": [
        [
          {
            "node": "Generate Analytical Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Analytical Report": {
      "main": [
        [
          {
            "node": "Return Analytical Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

相关工作流