|
Download scripts/README.md from brightmind-ai/codepractice-ai: direct link, hf CLI and curl.
- Browser
- Download file 4.03 kB
-
https://huggingface.co/spaces/brightmind-ai/codepractice-ai/resolve/main/scripts/README.md
- Command line
-
hf download hf://spaces/brightmind-ai/codepractice-ai/scripts/README.md
-
curl -L -o README.md https://huggingface.co/spaces/brightmind-ai/codepractice-ai/resolve/main/scripts/README.md
4.03 kB
| # Tutorial Video Creator | |
| This script automates browser interactions to create a tutorial video showing how to use the CodePractice AI website. | |
| ## Features | |
| - β Automated browser navigation | |
| - β Realistic mouse cursor movements | |
| - β Smooth scrolling animations | |
| - β Code typing simulation | |
| - β Button clicking | |
| - β LLM interaction simulation | |
| - β Automatic video recording | |
| ## Setup | |
| 1. **Install dependencies:** | |
| ```bash | |
| npm install | |
| ``` | |
| 2. **Install Playwright browsers:** | |
| ```bash | |
| npx playwright install chromium | |
| ``` | |
| 3. **Start your website** (if running locally): | |
| ```bash | |
| npm run dev | |
| ``` | |
| ## Usage | |
| ### Basic Usage | |
| ```bash | |
| npm run tutorial | |
| ``` | |
| Or directly: | |
| ```bash | |
| node scripts/create-tutorial-video.js | |
| ``` | |
| ### Custom URL | |
| To record from a different URL (e.g., production): | |
| ```bash | |
| WEBSITE_URL=https://your-website.com npm run tutorial | |
| ``` | |
| ## Configuration | |
| Edit `scripts/create-tutorial-video.js` to customize: | |
| - **Delays**: Adjust timing between actions | |
| - **Sample Code**: Change the code that gets typed | |
| - **LLM Questions**: Modify the questions asked | |
| - **Video Output**: Change output directory and filename | |
| ## Output | |
| Videos are saved to: `tutorial-videos/tutorial-YYYY-MM-DD.webm` | |
| ### Converting to MP4 | |
| Playwright records in WebM format. To convert to MP4: | |
| ```bash | |
| # Install ffmpeg (if not already installed) | |
| # macOS: brew install ffmpeg | |
| # Ubuntu: sudo apt-get install ffmpeg | |
| # Convert video | |
| ffmpeg -i tutorial-videos/tutorial-2025-12-20.webm \ | |
| -c:v libx264 \ | |
| -c:a aac \ | |
| tutorial-videos/tutorial-2025-12-20.mp4 | |
| ``` | |
| ## What the Script Does | |
| 1. **Opens the website** in a browser | |
| 2. **Shows the Home Page** with scrolling | |
| 3. **Selects a topic** (Array) and difficulty (Easy) | |
| 4. **Clicks "Start Practicing"** button | |
| 5. **Views the question** on Practice Page | |
| 6. **Types code** in the editor | |
| 7. **Clicks Run button** to execute code | |
| 8. **Opens Interview Helper** (LLM) | |
| 9. **Asks a question** in the LLM | |
| 10. **Modifies code** and asks another question | |
| ## Customization | |
| ### Change Sample Code | |
| Edit the `sampleCode` in the CONFIG object: | |
| ```javascript | |
| sampleCode: `def your_function(): | |
| # Your code here | |
| pass`, | |
| ``` | |
| ### Change LLM Questions | |
| Edit the `llmQuestions` array: | |
| ```javascript | |
| llmQuestions: [ | |
| "Your first question here", | |
| "Your second question here", | |
| ], | |
| ``` | |
| ### Adjust Timing | |
| Modify the `delays` object: | |
| ```javascript | |
| delays: { | |
| short: 500, // Quick pause | |
| medium: 1000, // Normal pause | |
| long: 2000, // Longer pause | |
| typing: 50, // Delay between keystrokes | |
| scroll: 300, // Scroll animation time | |
| }, | |
| ``` | |
| ## Troubleshooting | |
| ### Browser doesn't open | |
| - Make sure Playwright browsers are installed: `npx playwright install chromium` | |
| - Check that headless is set to `false` in the script | |
| ### Elements not found | |
| - The script uses flexible selectors, but you may need to adjust them based on your HTML structure | |
| - Check browser console for errors | |
| - Increase timeout values if needed | |
| ### Video not recording | |
| - Make sure the output directory exists | |
| - Check file permissions | |
| - Wait a few seconds after script completes for video to be written | |
| ### Cursor not visible | |
| - Make sure `headless: false` is set | |
| - The cursor should be visible in the recorded video | |
| ## Tips | |
| 1. **Run locally first**: Test with `http://localhost:3000` before using production URL | |
| 2. **Adjust delays**: Make them longer for slower demonstrations | |
| 3. **Customize code**: Use code that matches your tutorial's focus | |
| 4. **Multiple takes**: Run multiple times and pick the best recording | |
| 5. **Post-processing**: Use video editing software to add: | |
| - Background music | |
| - Text annotations | |
| - Zoom effects | |
| - Transitions | |
| ## Example Workflow | |
| 1. Start your website: `npm run dev` | |
| 2. Run the script: `npm run tutorial` | |
| 3. Wait for completion (usually 1-2 minutes) | |
| 4. Convert to MP4: `ffmpeg -i tutorial-videos/tutorial-*.webm -c:v libx264 -c:a aac output.mp4` | |
| 5. Edit in video software (optional) | |
| 6. Upload to YouTube/Vimeo or embed on your site | |