{
  "version": "1.0.0",
  "exported_at": "2026-06-03T09:05:00.000Z",
  "project": {
    "name": "YouTube Comments Scraper Short Video",
    "description": "Best-effort YouTube comments scraper equivalent to the Octoparse short-video comments template. It processes multiple YouTube video URLs via navigate.urls, uses an infinite-scroll JavaScript routine to lazy-load YouTube comments, normalizes each comment row into clean data attributes, then exports username, comment text, likes/vote count, reply count text, comment time, video title, video URL, and author channel URL. Uses fileMode append across the multi-URL loop. YouTube may require login, CAPTCHA, or bot verification; use a persistent browser profile and solve challenges manually if shown.",
    "color": "bg-[#ff0000]",
    "template_id": "ai-generated"
  },
  "blocks": [
    {
      "block_id": "set-window-size-1",
      "block_type": "process",
      "title": "Set Window Size",
      "description": "Set browser window dimensions",
      "position_x": 120,
      "position_y": 260,
      "config": {
        "width": 1920,
        "height": 1080,
        "color": "bg-[#4589ff]"
      }
    },
    {
      "block_id": "navigate-1",
      "block_type": "process",
      "title": "Navigate",
      "description": "Go to a URL",
      "position_x": 480,
      "position_y": 260,
      "config": {
        "urls": [
          "https://www.youtube.com/watch?v=xBBAD407zzU&t=30s",
          "https://www.youtube.com/watch?v=s6pirJKtVk0&t=7s"
        ],
        "color": "bg-[#4589ff]"
      }
    },
    {
      "block_id": "wait-for-page-load-1",
      "block_type": "process",
      "title": "Wait for Page Load",
      "description": "Wait for page to finish loading",
      "position_x": 840,
      "position_y": 260,
      "config": {
        "timeout": 45,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "sleep-1",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 1200,
      "position_y": 260,
      "config": {
        "duration": 4,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "inject-javascript-1",
      "block_type": "process",
      "title": "Inject JavaScript",
      "description": "Run custom JavaScript",
      "position_x": 1560,
      "position_y": 260,
      "config": {
        "jsCode": "return (async () => {\n  const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));\n  const clean = (value) => String(value || '').replace(/\\s+/g, ' ').trim();\n  const absUrl = (href) => {\n    try { return href ? new URL(href, location.origin).href : ''; } catch (e) { return href || ''; }\n  };\n  const getVideoTitle = () => {\n    const selectors = [\n      'ytd-watch-metadata h1 yt-formatted-string',\n      'h1.ytd-watch-metadata yt-formatted-string',\n      '#title h1 yt-formatted-string',\n      'h1 yt-formatted-string',\n      'h1'\n    ];\n    for (const selector of selectors) {\n      const el = document.querySelector(selector);\n      const text = clean(el && el.textContent);\n      if (text) return text;\n    }\n    return clean(document.title).replace(/ - YouTube$/i, '');\n  };\n  const parseExpectedCommentCount = () => {\n    const texts = Array.from(document.querySelectorAll('#count .count-text, ytd-comments-header-renderer h2, h2, yt-formatted-string'))\n      .map((el) => clean(el.textContent))\n      .filter(Boolean);\n    for (const text of texts) {\n      const match = text.match(/Comments\\s+([\\d,]+)/i) || text.match(/^([\\d,]+)\\s+Comments/i);\n      if (match) return parseInt(match[1].replace(/,/g, ''), 10) || 0;\n    }\n    return 0;\n  };\n\n  const commentsRoot = document.querySelector('#comments, ytd-comments');\n  if (commentsRoot) {\n    commentsRoot.scrollIntoView({ behavior: 'instant', block: 'start' });\n  } else {\n    window.scrollTo(0, Math.max(700, window.innerHeight));\n  }\n  await delay(3000);\n\n  const expectedCount = parseExpectedCommentCount();\n  let lastCount = -1;\n  let lastHeight = -1;\n  let stableRounds = 0;\n\n  for (let i = 0; i < 90; i++) {\n    const continuation = document.querySelector('ytd-continuation-item-renderer:not([hidden]), ytd-continuation-item-renderer');\n    if (continuation) {\n      continuation.scrollIntoView({ behavior: 'instant', block: 'center' });\n    } else {\n      window.scrollTo(0, document.documentElement.scrollHeight || document.body.scrollHeight);\n    }\n    window.scrollBy(0, Math.max(1200, Math.floor(window.innerHeight * 1.4)));\n    await delay(1300);\n\n    const count = document.querySelectorAll('ytd-comment-thread-renderer').length;\n    const height = document.documentElement.scrollHeight || document.body.scrollHeight || 0;\n\n    if (count === lastCount && height === lastHeight) {\n      stableRounds += 1;\n    } else {\n      stableRounds = 0;\n    }\n\n    lastCount = count;\n    lastHeight = height;\n\n    if (expectedCount > 0 && count >= expectedCount && stableRounds >= 2) break;\n    if (expectedCount === 0 && count > 0 && stableRounds >= 8) break;\n    if (count > 0 && stableRounds >= 14) break;\n  }\n\n  const videoTitle = getVideoTitle();\n  const videoUrl = location.href;\n  const rows = Array.from(document.querySelectorAll('ytd-comment-thread-renderer'));\n\n  for (const row of rows) {\n    const authorEl = row.querySelector('#author-text span, #author-text');\n    const authorLinkEl = row.querySelector('#author-text');\n    const commentEl = row.querySelector('#content-text');\n    const voteEl = row.querySelector('#vote-count-middle');\n    const timeEl = row.querySelector('#published-time-text a, .published-time-text a');\n\n    const replyCandidates = Array.from(row.querySelectorAll('ytd-comment-replies-renderer #more-replies, ytd-comment-replies-renderer yt-formatted-string, ytd-comment-replies-renderer button, ytd-button-renderer button, button'));\n    const replyTexts = replyCandidates\n      .map((el) => clean(el.getAttribute('aria-label') || el.textContent))\n      .filter(Boolean);\n    const replyText = replyTexts.find((text) => /\\b\\d+[\\d,.KMBkmb]*\\s*(reply|replies)\\b/i.test(text) || /\\b(view|show)\\s+\\d+[\\d,.KMBkmb]*\\s*(reply|replies)\\b/i.test(text)) || '';\n\n    row.setAttribute('data-yt-video-url', videoUrl);\n    row.setAttribute('data-yt-video-title', videoTitle);\n    row.setAttribute('data-yt-comment-user-name', clean(authorEl && authorEl.textContent));\n    row.setAttribute('data-yt-comment', clean(commentEl && (commentEl.innerText || commentEl.textContent)));\n    row.setAttribute('data-yt-vote-counts', clean(voteEl && voteEl.textContent));\n    row.setAttribute('data-yt-sub-reply-amounts', replyText);\n    row.setAttribute('data-yt-comment-time', clean(timeEl && timeEl.textContent));\n    row.setAttribute('data-yt-comment-author-channel-url', absUrl(authorLinkEl && authorLinkEl.getAttribute('href')));\n  }\n\n  const finalRoot = document.querySelector('#comments, ytd-comments');\n  if (finalRoot) finalRoot.scrollIntoView({ behavior: 'instant', block: 'start' });\n\n  return {\n    expectedCommentCount,\n    normalizedRows: rows.length,\n    videoTitle,\n    url: videoUrl\n  };\n})();",
        "waitForCompletion": true,
        "timeout": 240,
        "color": "bg-[#a56eff]"
      }
    },
    {
      "block_id": "wait-for-element-1",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 1920,
      "position_y": 260,
      "config": {
        "selector": "ytd-comment-thread-renderer[data-yt-comment]",
        "timeout": 60,
        "visible": false,
        "color": "bg-[#a56eff]"
      }
    },
    {
      "block_id": "structured-export-1",
      "block_type": "process",
      "title": "Structured Export",
      "description": "Export data with custom columns",
      "position_x": 2280,
      "position_y": 260,
      "config": {
        "rowSelector": "ytd-comment-thread-renderer[data-yt-comment]",
        "fileName": "youtube_comments_scraper_shortvideo.csv",
        "saveLocation": "C:\\Users\\theskd\\Documents\\UScraper\\templates",
        "includeHeaders": true,
        "fileMode": "append",
        "color": "bg-[#42be65]",
        "columns": [
          {
            "name": "video_url",
            "selector": "",
            "attribute": "data-yt-video-url"
          },
          {
            "name": "video_title",
            "selector": "",
            "attribute": "data-yt-video-title"
          },
          {
            "name": "comment_user_name",
            "selector": "",
            "attribute": "data-yt-comment-user-name"
          },
          {
            "name": "comment",
            "selector": "",
            "attribute": "data-yt-comment"
          },
          {
            "name": "vote_counts",
            "selector": "",
            "attribute": "data-yt-vote-counts"
          },
          {
            "name": "sub_reply_amounts",
            "selector": "",
            "attribute": "data-yt-sub-reply-amounts"
          },
          {
            "name": "comment_time",
            "selector": "",
            "attribute": "data-yt-comment-time"
          },
          {
            "name": "comment_author_channel_url",
            "selector": "",
            "attribute": "data-yt-comment-author-channel-url"
          }
        ]
      }
    },
    {
      "block_id": "loop-continue-1",
      "block_type": "process",
      "title": "Loop Continue",
      "description": "Continue multi-input loop",
      "position_x": 2640,
      "position_y": 260,
      "config": {
        "color": "bg-[#8d8d8d]"
      }
    }
  ],
  "connections": [
    {
      "from_block_id": "set-window-size-1",
      "from_connector_id": "right",
      "to_block_id": "navigate-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "navigate-1",
      "from_connector_id": "right",
      "to_block_id": "wait-for-page-load-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "wait-for-page-load-1",
      "from_connector_id": "right",
      "to_block_id": "sleep-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "sleep-1",
      "from_connector_id": "right",
      "to_block_id": "inject-javascript-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "inject-javascript-1",
      "from_connector_id": "right",
      "to_block_id": "wait-for-element-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "wait-for-element-1",
      "from_connector_id": "right",
      "to_block_id": "structured-export-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "structured-export-1",
      "from_connector_id": "right",
      "to_block_id": "loop-continue-1",
      "to_connector_id": "left"
    }
  ],
  "canvas_elements": [
    {
      "id": "group-entry",
      "element_type": "group",
      "title": "Entry & Setup",
      "color": "#4589ff",
      "position_x": 48,
      "position_y": 156,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "set-window-size-1"
        ]
      }
    },
    {
      "id": "group-load",
      "element_type": "group",
      "title": "Page Load",
      "color": "#08bdba",
      "position_x": 408,
      "position_y": 156,
      "width": 1760,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "navigate-1",
          "wait-for-page-load-1",
          "sleep-1",
          "wait-for-element-1"
        ]
      }
    },
    {
      "id": "group-interaction",
      "element_type": "group",
      "title": "Interaction",
      "color": "#a56eff",
      "position_x": 1488,
      "position_y": 156,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "inject-javascript-1"
        ]
      }
    },
    {
      "id": "group-extract",
      "element_type": "group",
      "title": "Data Extraction",
      "color": "#42be65",
      "position_x": 2208,
      "position_y": 156,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "structured-export-1"
        ]
      }
    },
    {
      "id": "group-pagination",
      "element_type": "group",
      "title": "Pagination Loop",
      "color": "#ff832b",
      "position_x": 2568,
      "position_y": 156,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "loop-continue-1"
        ]
      }
    },
    {
      "id": "note-overview",
      "element_type": "note",
      "title": "Overview",
      "content": "Best-effort YouTube comments scraper equivalent to the Octoparse short-video comments template. It processes multiple YouTube video URLs via navigate.urls, uses an infinite-scroll JavaScript routine to lazy-load YouTube comments, normalizes each comment row into clean data attributes, then exports username, comment text, likes/vote count, reply count text, comment time, video title, video URL, and author channel URL. Uses fileMode append across the multi-URL loop. YouTube may require login, CAPTCHA, or bot verification; use a persistent browser profile and solve challenges manually if shown.",
      "color": "#f1c21b",
      "position_x": 80,
      "position_y": 20,
      "width": 480,
      "height": 160,
      "z_index": 22,
      "data": {}
    },
    {
      "id": "note-block-navigate-1",
      "element_type": "note",
      "title": "Note: Navigate",
      "content": "Multi-URL loop over 2 pages. Pair with loop-continue at the end of each iteration.",
      "color": "#ee5396",
      "position_x": 680,
      "position_y": 240,
      "width": 328,
      "height": 107,
      "z_index": 22,
      "data": {
        "block_id": "navigate-1"
      }
    },
    {
      "id": "note-block-inject-javascript-1",
      "element_type": "note",
      "title": "Note: Inject JavaScript",
      "content": "Runs custom JavaScript in the page: `return (async () => {\n  const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));\n  c...` Verify in browser if results are empty.",
      "color": "#ee5396",
      "position_x": 1760,
      "position_y": 240,
      "width": 340,
      "height": 140,
      "z_index": 22,
      "data": {
        "block_id": "inject-javascript-1"
      }
    },
    {
      "id": "note-block-structured-export-1",
      "element_type": "note",
      "title": "Note: Structured Export",
      "content": "Extracts rows matching `ytd-comment-thread-renderer[data-yt-comment]`. Confirm row count > 0 before running at scale.",
      "color": "#ee5396",
      "position_x": 2480,
      "position_y": 240,
      "width": 340,
      "height": 119,
      "z_index": 22,
      "data": {
        "block_id": "structured-export-1"
      }
    },
    {
      "id": "note-block-loop-continue-1",
      "element_type": "note",
      "title": "Note: Loop Continue",
      "content": "Loop Continue advances a multi-URL or multi-text loop. Place at the end of the loop body with a clear back-edge to the loop start.",
      "color": "#ee5396",
      "position_x": 2840,
      "position_y": 240,
      "width": 340,
      "height": 123,
      "z_index": 22,
      "data": {
        "block_id": "loop-continue-1"
      }
    }
  ]
}