Communitygithub.com

EyalZameret/Dudu-Director-Video-kit

用來驅動 Gemini(Nano Banana 圖片、Veo 影片)、ChatGPT(GPT Image)和 Kling(圖片轉影片)的 Playwright 自動化套件,包含完整的點擊路徑、上傳下載流程以及失敗修復方案。

Dudu-Director-Video-kit 是什麼?

這個技能為 AI 影片導演助理「Dudu」提供 Playwright 瀏覽器自動化能力,使其能夠操控 Gemini、ChatGPT 與 Kling 三個平台的影像生成功能。 核心用途是讓開發者或 AI 代理(如 Claude、Codex)能透過 Playwright MCP 伺服器,自動執行圖片生成(Nano Banana、GPT Image)、影片生成(Veo)及圖片轉影片(Kling)的完整流程,包括上傳參考圖片、輸入提示詞、等待結果、下載成品,以及後續編輯(如移除標誌、修正眼睛)。 支援平台包括 Google Gemini(支援希伯來文與英文介面)、ChatGPT 和 Kling.ai。技能內建詳細的選取器(selector)、解決常見失敗情境(如檔案選擇器衝突、下載超時、UI 語言變更)的應對策略,以及專用的審閱工具(contact sheet、motion report)。 使用者需先自行登入各平台,技能不會儲存或操作任何憑證。

相容平台~Claude Code✓Codex CLI~Cursor✓Gemini CLI
npx skills add https://github.com/EyalZameret/Dudu-Director-Video-kit/tree/HEAD/.claude/skills/dudu-browser

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Dudu:使用 Playwright 驅動 Gemini、ChatGPT 與 Kling

透過 .mcp.json 中的 Playwright MCP 伺服器運作。以下的選取器已於 2026-10 在希伯來文版 Gemini 和英文版 Kling 上驗證過。ChatGPT 的配方(第 1b 節)尚未驗證。Gemini 的標籤寫成正則表達式,可同時接受希伯來文與英文;英文用詞未經驗證,因此首次在不同語言的 UI 上執行時,請先執行 browser_snapshot 檢查實際按鈕名稱,再修正此處的正則表達式。網頁 UI 會變動:當選取器失效時,請擷取快照(browser_snapshot 或 browser_find),找出新的選取器並更新此檔案。

0. 基本規則

  • 所有者自行登入。開啟網站後,告訴所有者「請在 Playwright 視窗中登入,完成後告訴我」,然後等待。切勿輸入任何憑證。
  • 自動化操作消費級網頁 UI 可能違反該網站的服務條款。告知所有者一次,將操作量維持在人類操作規模,並提供官方 API 作為替代方案。
  • 檔案必須位於工作區內(Playwright MCP 拒絕其他根目錄)。先將所有者貼上的任何參考檔案複製到 project/frames/ 資料夾中。
  • 每個步驟都要檢查結果(讀取圖片;為影片片段建立聯絡表)。

1. Gemini:圖片(Nano Banana)

順序很重要。 如果未先選擇圖片工具就直接發送提示詞,Gemini 可能會以文字回覆(「我無法在此生成圖片」),且下次嘗試會卡住超過 5 分鐘。每次都應:新對話 → 選工具 → 放參考圖 → 再下提示詞。

以下使用的標籤(希伯來文 UI 已驗證,英文未驗證):

正則表達式希伯來文 UI英文 UI(請檢查)
TOOLSהעלאה וכליםUpload and tools
CREATE_IMAGEיצירת תמונהCreate image
DOWNLOAD_IMAGEהורדת תמונה בגודל מלאDownload full size image

步驟 A,一次 browser_run_code_unsafe 呼叫(開啟作業系統的檔案選擇器):

async (page) => {
  const TOOLS = /העלאה וכלים|Upload and tools/i,   // 子字串比對,如同純字串名稱
  const CREATE_IMAGE = /^(יצירת תמונה|Create images?)$/i;
  await page.goto('https://gemini.google.com/app'); await page.waitForTimeout(3000);
  await page.getByRole('button', { name: TOOLS }).first().click(); await page.waitForTimeout(1000);
  await page.getByText(CREATE_IMAGE).first().click(); await page.waitForTimeout(1500);
  await page.getByRole('button', { name: TOOLS }).first().click(); await page.waitForTimeout(1000);
  await page.locator('[data-test-id="local-images-files-uploader-button"]').click();
  return 'chooser';
}

步驟 B:使用 browser_file_upload 上傳參考圖片的絕對路徑(1-4 個檔案)。 步驟 C,下達提示詞並下載:

async (page) => {
  await page.waitForTimeout(4000);
  const box = page.getByRole('textbox').first();
  await box.fill(PROMPT); await page.waitForTimeout(800); await box.press('Enter');
  const btn = page.getByRole('button', { name: /הורדת תמונה בגודל מלא|Download full[- ]size image/i });
  await btn.first().waitFor({ state: 'attached', timeout: 180000 }); await page.waitForTimeout(3000);
  const [d] = await Promise.all([page.waitForEvent('download', { timeout: 60000 }), btn.last().click({ force: true })]);
  await d.saveAs(OUT_PATH); return 'ok';
}

在同一個對話中編輯(移除標誌、修正眼睛、交換額外內容):導航至該對話的 URL,計算下載按鈕的數量,發送編輯提示詞,然後等待數量增加:

await page.waitForFunction(n => document.querySelectorAll('button[aria-label="הורדת תמונה בגודל מלא"], button[aria-label="Download full size image"]').length > n, before, { timeout: 180000 });

典型時間:每張圖片 20-40 秒。

常見陷阱:

  • browser_run_code_unsafe 無法在檔案選擇器開啟時執行。請按上述 A / B / C 分開執行。
  • 先前的對話會保留上下文:使用新的對話可避免「它回傳了同一張圖片」的問題。

1b. ChatGPT:圖片(GPT Image),適用於沒有 Gemini 的所有者

狀態:未驗證。 此配方是根據 chatgpt.com 的通用結構撰寫,而非實際錄製的執行過程。首次執行時:請在每一步都執行 browser_snapshot,使用實際的選取器,並將下方的猜測替換為實際可行的內容(以及日期)。在此之前,請使用多次分開的小型 browser_* 呼叫,而非單一長腳本。

開始前,告知所有者一次:OpenAI 的服務條款限制以自動化方式擷取輸出;請將操作量維持在人類操作規模,或改用他們自己的 API 金鑰來使用 OpenAI Images API。

流程(與 Gemini 相同順序:新對話、參考圖、提示詞、等待、下載):

  1. 使用 browser_navigate 導航至 https://chatgpt.com/(每次使用新的對話可避免「它回傳了同一張圖片」)。所有者登入。
  2. 參考圖: 尋找隱藏的 input[type=file] 並使用 setInputFiles 設定絕對路徑(1-4 個檔案)。若無此元素,則點擊附加按鈕(「+」或迴紋針圖示;請檢查快照),然後使用 browser_file_upload 操作選擇器。等待所有縮圖上傳完成。
  3. 提示詞: 撰寫區域通常是 contenteditable 的方塊(通常是 #prompt-textarea)。在提示詞開頭加上 Create an image: 以避免它以文字回覆,或者如果快照顯示有圖片工具,從「+」選單中選取。然後輸入一般的提示詞(參考圖、鏡頭描述、風格、負面提示)。
  4. 比例: ChatGPT 提供正方形、直式和橫式 3:2(1536x1024),沒有 16:9。請要求 landscape 3:2 並加上 keep all important content inside the central 16:9 band。tools/build_cut.py 會在編輯時裁切為 16:9。
  5. 等待: 通常 30-120 秒。等待新的 img 出現在最後一個回覆中(其替代文字通常為「Generated image」),且進度指示器消失。
  6. 下載: 優先使用圖片自身的下載按鈕(將滑鼠懸停在圖片上;檢查快照)。否則讀取新 img 的 src 屬性,並使用瀏覽器的 cookies 儲存:
    async (page) => {
      const src = await page.locator('img[alt*="Generated"]').last().getAttribute('src');
      const res = await page.request.get(src);
      require('fs').writeFileSync(OUT_PATH, await res.body()); return res.status();
    }
    
    如果 require 在 browser_run_code_unsafe 中不可用,請使用下載按鈕或 browser_take_screenshot 對圖片元素截圖作為最後手段(品質較低;請告知所有者)。
  7. 編輯(移除標誌、修正眼睛):停留在同一個對話中,輸入 Edit only ...: ... Change nothing else.。ChatGPT 也可能提供「選取區域」編輯器;兩者皆可。

我們用 GPT Image 看到的結果(2026-10,角色表):

  • 它在角色和表情方面表現最佳(年齡、緊張感、狂野的頭髮),面板非常一致。
  • 解析度較低,光線較平滑、「太乾淨」;在一張特寫中,雙眼看向不同方向。請加上 natural skin texture, visible pores, unretouched, sharp focus, both eyes looking at the camera 並檢查每個臉部的眼睛。
  • 配額規劃:聊天方案的圖片生成有會變動的限制。如果它要求等待,請停止並告知所有者,不要重試。

2. Gemini:影片(Veo)

與圖片相同,但選擇 יצירת סרטון(英文 UI:「Create video」)並附加關鍵影格。使用 הורדת הסרטון 按鈕(英文 UI:「Download video」)下載。每個片段需時數分鐘,720p,長度約 8-10 秒。

3. Kling:圖片轉影片

Kling 有真正的 input[type=file],因此不需要檔案選擇器。每個鏡頭一次呼叫(每個約 70-80 秒):

async (page) => {
  const seen = () => page.evaluate(() => performance.getEntriesByType('resource')
                       .map(e => e.name).filter(n => /-output\.mp4\?/.test(n)));
  const gen = () => page.locator('button').filter({ hasText: /Generate/ }).filter({ hasNotText: /Generated/ }).last();
  await page.goto('https://kling.ai/app/video/new?ac=7'); await page.waitForTimeout(5000);
  const before = new Set(await seen());
  await page.locator('input[type=file]').first().setInputFiles(KEYFRAME); await page.waitForTimeout(5000);
  await page.locator('[contenteditable="true"], textarea').first().click();
  await page.keyboard.type(PROMPT, { delay: 1 });
  let label = await gen().innerText();
  if (/60/.test(label)) { await page.getByText('Native Audio', { exact: true }).click(); label = await gen().innerText(); }
  if (!/40/.test(label)) return 'unexpected cost: ' + label;          // 停止並詢問所有者
  await gen().click();
  const t0 = Date.now(); let url = null;
  while (Date.now() - t0 < 300000) { await page.waitForTimeout(8000); url = (await seen()).find(u => !before.has(u)); if (url) break; }
  return url;
}

然後在瀏覽器外部下載:python tools/download.py "<url>" project/clips/shotNN.mp4。

常見陷阱:

  • getByText('Generate') 也會比對到「1/1 Generated」標籤。請使用上述的按鈕過濾器。
  • <video> 元素使用 blob URL,fetch 會失敗;請改從 performance entries 中取得 CDN 網址。
  • 每次都要檢查 Generate 按鈕上的價格;Native Audio 會增加成本。

4. 審閱片段

請勿在瀏覽器中審閱:<video> 的 seek 操作會回傳過時的影格。請使用 python tools/contact_sheet.py 和 python tools/motion_report.py。

Individual skills in this repo

This repo contains 8 individual skills — each has its own dedicated page.

EyalZameret/Dudu-Director-Video-kit

Used by Dudu (AI promo video director) for stage 7. Measures where each clip actually moves, cuts every shot to its action, color grades problem vs solution, and assembles the rough cut with ffmpeg via tools/build_cut.py.

EyalZameret/Dudu-Director-Video-kit

Used by Dudu (AI promo video director) for stage 6. Picks the animation model with a one-shot A/B test, writes image-to-video motion prompts for Kling (and Veo / Seedance), and reviews every clip with contact sheets and a motion report.

EyalZameret/Dudu-Director-Video-kit

Used by Dudu (AI promo video director) at every gate. Checks script claims against project/product.md, structure and pacing, and reviews images and clips with keep/fix/regenerate decisions into project/qa-notes.md.

EyalZameret/Dudu-Director-Video-kit

Used by Dudu (AI promo video director) for stages 1-2. Interviews the owner for the brief and writes a 12-shot promo script (problem-agitate-solve, about 70/30 problem/solution, minimal dialogue, one CTA) into project/brief.md and project/script.md.

EyalZameret/Dudu-Director-Video-kit

Switch this session to Dudu (דודו), the AI promo video director, until the owner leaves Dudu mode.

EyalZameret/Dudu-Director-Video-kit

Used by Dudu (AI promo video director) after the picture cut. Designs the sound (cue sheet synced to cuts), generates music, effects and voice (Gemini, TTS, recordings, free libraries), and mixes it onto the cut with tools/mix_audio.py into a finished film.

EyalZameret/Dudu-Director-Video-kit

Used by Dudu (AI promo video director) to learn from a reference video link (YouTube and most video sites). Downloads it for private analysis, detects every cut, reviews one frame per shot, writes a structured analysis into library/study/<id>/analysis.md and updates library/INDEX.md, then deletes the video. Use when the owner shares a link and says "learn from this", "study this", "do it like this", or asks for a style taken from an ad.

EyalZameret/Dudu-Director-Video-kit

Used by Dudu (AI promo video director) for stages 3-5. Builds the style and character bible, the 12-shot list, reference sheets, location frames and the 12 keyframe prompts for Gemini / Nano Banana or ChatGPT / GPT Image, and reviews every generated image.

相關技能