|
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
Install dependencies:
npm installInstall Playwright browsers:
npx playwright install chromiumStart your website (if running locally):
npm run dev
Usage
Basic Usage
npm run tutorial
Or directly:
node scripts/create-tutorial-video.js
Custom URL
To record from a different URL (e.g., production):
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:
# 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
- Opens the website in a browser
- Shows the Home Page with scrolling
- Selects a topic (Array) and difficulty (Easy)
- Clicks "Start Practicing" button
- Views the question on Practice Page
- Types code in the editor
- Clicks Run button to execute code
- Opens Interview Helper (LLM)
- Asks a question in the LLM
- Modifies code and asks another question
Customization
Change Sample Code
Edit the sampleCode in the CONFIG object:
sampleCode: `def your_function():
# Your code here
pass`,
Change LLM Questions
Edit the llmQuestions array:
llmQuestions: [
"Your first question here",
"Your second question here",
],
Adjust Timing
Modify the delays object:
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
falsein 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: falseis set - The cursor should be visible in the recorded video
Tips
- Run locally first: Test with
http://localhost:3000before using production URL - Adjust delays: Make them longer for slower demonstrations
- Customize code: Use code that matches your tutorial's focus
- Multiple takes: Run multiple times and pick the best recording
- Post-processing: Use video editing software to add:
- Background music
- Text annotations
- Zoom effects
- Transitions
Example Workflow
- Start your website:
npm run dev - Run the script:
npm run tutorial - Wait for completion (usually 1-2 minutes)
- Convert to MP4:
ffmpeg -i tutorial-videos/tutorial-*.webm -c:v libx264 -c:a aac output.mp4 - Edit in video software (optional)
- Upload to YouTube/Vimeo or embed on your site