Skip to content

Latest commit

 

History

History
222 lines (155 loc) · 7.92 KB

File metadata and controls

222 lines (155 loc) · 7.92 KB

Setup — running this project on a new machine

Step-by-step. Do every step in order. Total setup time: ~10–15 min.


1. Prerequisites

Install these on the new machine before cloning.

Windows 11 — one-shot install via winget

Open PowerShell as Administrator and paste:

winget install --id OpenJS.NodeJS.LTS --silent --accept-source-agreements --accept-package-agreements
winget install --id Python.Python.3.12 --silent --accept-source-agreements --accept-package-agreements
winget install --id Google.Chrome      --silent --accept-source-agreements --accept-package-agreements
winget install --id Git.Git            --silent --accept-source-agreements --accept-package-agreements

This installs Node.js LTS, Python 3.12, Chrome, and Git. (winget ships with Windows 11.) Close and reopen the terminal after installation so the new PATH takes effect.

Manual download (any OS)

Tool Where to get it
Node.js 20+ https://nodejs.org/
Python 3.10+ https://www.python.org/downloads/check "Add Python to PATH" during install
Google Chrome https://www.google.com/chrome/
Git https://git-scm.com/

Verify

In a fresh terminal:

node --version
python --version
git --version

All three should print versions. If python doesn't work, try python3.


2. Clone the repo

git clone https://github.com/molotovgit/Creative_Automation.git
cd Creative_Automation

Or download the zip from GitHub and extract it.


3. Run setup.bat (does everything)

Double-click setup.bat (or run setup.bat from a terminal in the repo folder).

It will:

  1. Create .env from .env.example if it doesn't exist (so you only need to edit the values)
  2. Run npm install — installs puppeteer and other deps from package.json
  3. Run pip install -r requirements.txt — installs Python deps (notion-client, python-dotenv, etc.)
  4. Launch two Chrome windows:
    • Window 1 (port 9222) → opens chatgpt.com
    • Window 2 (port 9223) → opens gemini.google.com and labs.google/fx/tools/flow

If Chrome is in a non-standard location, the script may not find it. Edit the CHROME_PATHS array in scripts/setup_chrome.cjs to point at your chrome.exe.


4. Edit .env with your credentials

setup.bat already created .env for you (copied from .env.example). Open it in any text editor and fill in your real values:

NOTION_API_KEY=secret_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CHATGPT_EMAIL=your-chatgpt-email@example.com
CHATGPT_PASSWORD=your-chatgpt-password
GEMINI_EMAIL=your-gemini-email@example.com
GEMINI_PASSWORD=your-gemini-password
CDP_PORT=9222
GEMINI_CDP_PORT=9223

Leave CDP_PORT and GEMINI_CDP_PORT as-is — they must match what the scripts expect.

Where to get the NOTION_API_KEY:

  1. Go to https://www.notion.so/profile/integrations
  2. Click "+ New integration"
  3. Give it a name, pick the workspace that has your textbooks
  4. Copy the "Internal Integration Secret" (starts with secret_ or ntn_)
  5. Open your textbook root page in Notion → click "..." (top right) → "+ Add connections" → select your integration

The integration must have access to every page the pipeline will read.


5. Notion workspace structure

The fetch_chapter.py script expects this exact hierarchy in your Notion workspace:

<Grade root page>             (search-discoverable: "Grade 7", "7-sinf", etc.)
└── <Subject page>             ("Tarix", "Jahon Tarixi", "Algebra", ...)
    └── <Chapter page>         (titled "1-mavzu: ...", "Chapter 1: ...", etc.)
        └── chapter content

If your Notion doesn't follow this layout, the fetch will fail. You'll either need to:

  • Restructure your Notion to match, OR
  • Edit tools/notion/navigator.py to match your structure

6. Sign in manually inside each Chrome window

Window 1 (ChatGPT):

  • Log in to chatgpt.com with your account

Window 2 (Gemini + Flow):

  • Tab 1: log in to gemini.google.com
  • Tab 2: log in to labs.google/fx/tools/flow with an account that has Flow credits
  • Leave both tabs open

Sign-in is one-time — sessions persist in dedicated profile directories (~/chrome-chatgpt-cdp/ and ~/chrome-gemini-cdp/). Future runs of setup.bat reuse them.


7. Configure the chapter you want to process

Open scripts/run_pipeline.cjs in any text editor. Find the CONFIG block at the top (around line 27):

const CONFIG = {
  NOTION_URL: 'paste your notion link here',
  GRADE:   7,                  // 5–11
  LANG:    'uz',               // 'uz' or 'ru'
  SUBJECT: 'jahon tarixi',     // subject name (fuzzy-matched in Notion)
  CHAPTER: 1,                  // chapter number
};
  • Paste the Notion page URL of the chapter you want (for reference / printing in logs)
  • Set GRADE, LANG, SUBJECT, CHAPTER to match how the chapter is indexed in your Notion
  • Save the file

8. Run the pipeline

Double-click start.bat (or node scripts/run_pipeline.cjs).

The pipeline will:

  1. Verify both Chrome windows + .env keys (pre-flight)
  2. Run all 5 stages — fetch → refine → prompts → images → animate
  3. Print a summary when done (✓ PIPELINE DONE)

Walk away. Total time: ~50–60 min for a fresh chapter (most of it is image + video generation).

If anything fails partway, fix the issue and re-run start.bat — completed stages skip automatically (file-existence-driven).


Output locations

All outputs land under the repo root:

chapters/g{GRADE}-{LANG}/{subject-slug}/ch{NN}-{title}.md     ← Notion fetch
refined/g{GRADE}-{LANG}/{subject-slug}/ch{NN}-{title}.md       ← ChatGPT-refined
prompts/g{GRADE}-{LANG}/{subject-slug}/ch{NN}-{title}.json    ← 80 prompts
images/g{GRADE}-{LANG}/{subject-slug}/ch{NN}-{title}/*.png    ← 80 PNGs
videos/g{GRADE}-{LANG}/{subject-slug}/ch{NN}-{title}/*.mp4    ← 80 MP4s

Troubleshooting

"Chrome not reachable on port 9222 / 9223" The Chrome window is closed. Re-run setup.bat (skips windows that are already up).

"ModuleNotFoundError: No module named 'notion_client'" Python deps not installed. Run setup.bat (it installs them) or manually: pip install -r requirements.txt.

"Cannot connect to keep-alive on :9222" (during REFINE) ChatGPT Chrome window is closed, or the keepalive Python script isn't running. The simplest fix is re-running setup.bat.

"Auto-login failed" You need to log in once manually inside the Chrome window opened by setup.bat. Sessions persist after that.

"No fetched chapter found" The Notion structure doesn't match (see step 5), or the integration doesn't have access to the textbook pages (see step 4: edit .env and verify connections in Notion).

Stage failed mid-run Re-run start.bat. Completed stages skip; the pipeline picks up where it left off.

Want to redo a specific stage Delete that stage's output folder/file (e.g., delete images/... to redo image generation), then re-run start.bat.


File reference

File Purpose
setup.bat One-time setup — bootstraps .env, installs Node + Python deps, launches Chrome windows
start.bat Run-anytime — executes the full pipeline
scripts/run_pipeline.cjs The orchestrator. Edit CONFIG here.
scripts/setup_chrome.cjs Launches the two debug-port Chrome windows
scripts/run_autonomous.cjs IMAGES stage wrapper (autonomous orchestrator)
scripts/run_animator.cjs ANIMATE stage wrapper (auto-restart on crash)
.env.example Template — committed; copied to .env by setup.bat
.env Your real API keys & passwords (gitignored — auto-created from .env.example)
requirements.txt Python deps
package.json Node deps
refine_prompt.txt The formula ChatGPT uses to refine chapters
80_prompt_formula.txt The formula ChatGPT uses to generate image prompts
GUIDE.md Quick-reference guide for day-to-day use