filiksyos/Youtube-to-Doc
Tentang
Turn any YouTube video into a documentation link
Desain dan mediaYang dapat Anda lakukan
- πΊ YouTube Video Processing: Extract video metadata, descriptions, and thumbnails
- π Transcript Extraction: Automatically extract video transcripts in multiple languages
- π Optional SearchApi Fallback: SearchApi backs up video metadata and transcript extraction when existing providers fail. Setup instructions.
- π¬ Comments Integration: Optional inclusion of video comments for additional context
Pertumbuhan bintang terukur
- dalam 24 jam
- 0
- dalam 7 hari
- +1
- dalam 15 hari
- 0
- dalam 1 bulan
- Mengumpulkan riwayat
Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.
README.md
AsliYouTube to Doc
https://github.com/user-attachments/assets/4431d283-23c3-40eb-8c65-a20361a3e945
Turn any YouTube video into a comprehensive documentation link that AI coding tools and LLMs can easily index and understand.
π Features
- πΊ YouTube Video Processing: Extract video metadata, descriptions, and thumbnails
- π Transcript Extraction: Automatically extract video transcripts in multiple languages
- π Optional SearchApi Fallback: SearchApi backs up video metadata and transcript extraction when existing providers fail. Setup instructions.
- π¬ Comments Integration: Optional inclusion of video comments for additional context
- π€ AI-Friendly Output: Generate structured documentation perfect for LLM consumption
- β‘ Fast Processing: Efficient video processing with rate limiting and caching
- π Multi-Language Support: Support for transcripts in 9+ languages
- π± Responsive Design: Beautiful, modern UI built with Tailwind CSS
- π§ API Access: RESTful API for programmatic access
- π³ Docker Ready: Easy deployment with Docker and Docker Compose
π οΈ Tech Stack
- Backend: FastAPI + Python 3.11+
- Frontend: Tailwind CSS + Jinja2 templates
- Video Processing: yt-dlp, pytube, youtube-transcript-api
- Optional Fallback Provider: SearchApi for YouTube video metadata and transcripts
- Token Estimation: tiktoken
- Rate Limiting: slowapi
- Deployment: Docker, Docker Compose
π¦ Installation
Option 1: Docker (Recommended)
# Clone the repository
git clone https://github.com/filiksyos/Youtube-to-Doc.git
cd youtubedoc
# Run with Docker Compose
docker-compose up -d
Option 2: Local Installation
# Clone the repository
git clone https://github.com/filiksyos/Youtube-to-Doc.git
cd youtubedoc
# Install dependencies (using pnpm as specified in requirements)
pip install -r requirements.txt
# Run the application
uvicorn src.server.main:app --host 0.0.0.0 --port 8000 --reload
π Usage
Web Interface
- Open your browser and navigate to
http://localhost:8000 - Enter a YouTube video URL
- Configure processing options:
- Transcript Length: Maximum characters to include
- Language: Preferred transcript language
- Include Comments: Whether to extract video comments
- Click "Create Docs" to process the video
API Usage
Process a Video
curl -X POST "http://localhost:8000/" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "input_text=https://www.youtube.com/watch?v=dQw4w9WgXcQ" \
-d "max_transcript_length=10000" \
-d "language=en" \
-d "include_comments=false"
Python Example
import requests
url = "http://localhost:8000/"
data = {
"input_text": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"max_transcript_length": 10000,
"language": "en",
"include_comments": False
}
response = requests.post(url, data=data)
print(response.text)
π§ Configuration
Create a .env file based on .env.example:
cp .env.example .env
Key Configuration Options
ALLOWED_HOSTS: Comma-separated list of allowed hostsYOUTUBE_API_KEY: Optional YouTube Data API key for enhanced featuresSEARCHAPI_API_KEY: Optional server-side SearchApi key for metadata and transcript fallbackOPENAI_API_KEY: Optional OpenAI API key for AI-enhanced processingRATE_LIMIT_PER_MINUTE: Number of requests per minute per IP
Optional SearchApi Fallback
SearchApi provides the optional YouTube metadata and
transcript fallback. It is disabled by default and does not replace the existing
providers. To enable it, add your SearchApi key to the server's private .env:
SEARCHAPI_API_KEY=your_searchapi_api_key
Alternatively, set SEARCHAPI_API_KEY directly in your server's environment.
Restart the server after changing it. Leave it blank to keep SearchApi disabled.
Docker Compose passes this
variable through; for docker run, supply it with --env-file .env (keep that
file private). Never commit the key or include it in frontend code.
Existing providers stay first:
- Metadata: yt-dlp β pytube β SearchApi's
youtube_videoengine β minimal metadata. - Transcripts: youtube-transcript-api (including its existing language fallback)
β SearchApi's
youtube_transcriptsengine β no transcript.
SearchApi is called only when the existing providers fail, are unavailable, or return an empty transcript. It receives the video ID and, for transcripts, the preferred language. If SearchApi reports that language unavailable and lists other tracks, the app tries the first available alternative once and records its language. The same transcript length limit and truncation marker apply to both providers. Comments are unchanged; SearchApi is not used for comments.
Enabling this fallback can consume your SearchApi credits: each processing attempt can make one metadata request and up to two transcript requests. Successful primary providers make no SearchApi requests. Authentication, quota, timeout, malformed response, and service errors degrade to the existing minimal metadata / missing transcript behavior, without automatic retries. Requests have a 5-second connection timeout and 20-second read timeout. Credentials use the Authorization header, not the URL, and provider error bodies are not logged or returned to users.
See the official YouTube Video API and YouTube Transcripts API documentation. The automated tests use mocked responses and require no key or credits. A live smoke test requires a separately configured server key and will consume requests; it is not part of the test suite.
AWS S3 Integration (for cloud documentation links)
To publish generated docs to S3 and show "View Documentation" and "Copy Documentation Link" buttons (as used on youtubetodoc.com), configure an S3 bucket and environment variables.
- Create an S3 bucket
- Region: choose your region (e.g., eu-north-1)
- Object Ownership: ACLs disabled (Bucket owner enforced)
- Public access: turn OFF βBlock all public accessβ if you want public S3 URLs
- Add a read-only bucket policy (recommended to scope to
docs/):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowPublicReadDocs",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::YOUR_BUCKET/docs/*"
}
]
}
- Set environment variables in
.env:
AWS_S3_BUCKET=YOUR_BUCKET
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=eu-north-1
- Restart the server so
.envis reloaded.
Notes
- The app auto-detects the bucket's real region to construct the correct URL, avoiding PermanentRedirect.
- If you prefer not to expose public S3, keep Block Public Access on and serve via CloudFront instead.
Proxy Configuration (Cloud Deployment Only)
β οΈ Note: This is only needed for cloud deployment (Render, Heroku, AWS, etc.). Local development works without proxies.
When deploying to cloud providers, YouTube often blocks requests from cloud IPs, causing IpBlocked or RequestBlocked errors. To fix this, configure rotating residential proxies:
Sign up for Webshare (recommended by
youtube-transcript-api):- Visit webshare.io and create an account
- Purchase a "Rotating Residential" plan (NOT "Proxy Server" or "Static Residential")
- Go to Proxies β Rotating Residential β Proxy Settings to get your credentials
Set environment variables in your deployment:
# Webshare credentials (base username/password)
YTA_WEBSHARE_USERNAME=your_webshare_username
YTA_WEBSHARE_PASSWORD=your_webshare_password
YTA_WEBSHARE_LOCATIONS=jp,kr,tw # optional: filter by countries
# Proxy URLs for yt-dlp/pytube (use specific pod usernames from your proxy list)
YTA_HTTP_PROXY=http://your_pod_username:[email protected]:80
YTA_HTTPS_PROXY=http://your_pod_username:[email protected]:80
- Alternative: Use any HTTP/HTTPS proxy provider:
YTA_HTTP_PROXY=http://user:pass@proxy-host:port
YTA_HTTPS_PROXY=https://user:pass@proxy-host:port
The app will automatically route YouTube API calls through the proxy when these variables are set.
π Supported YouTube URL Formats
https://www.youtube.com/watch?v=VIDEO_IDhttps://youtu.be/VIDEO_IDhttps://www.youtube.com/embed/VIDEO_IDhttps://www.youtube.com/v/VIDEO_ID
π Supported Languages
- English (en)
- Spanish (es)
- French (fr)
- German (de)
- Italian (it)
- Portuguese (pt)
- Japanese (ja)
- Korean (ko)
- Chinese (zh)
π API Endpoints
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Home page with video processing form |
POST |
/ |
Process a YouTube video |
GET |
/video/{video_id} |
Get processing form for specific video |
POST |
/video/{video_id} |
Process specific video |
GET |
/api |
API documentation |
GET |
/health |
Health check endpoint |
π Rate Limits
- Main endpoint: 10 requests per minute per IP
- Video-specific endpoint: 5 requests per minute per IP
- Streaming processing endpoint: 5 requests per minute per IP (including cache checks)
These are per-IP limits, not an account-wide SearchApi spending cap. Monitor your provider quota before enabling the optional fallback on a public deployment.
π³ Docker Deployment
Development
docker-compose up -d
Production
# Build and run
docker build -t youtubedoc .
docker run -p 8000:8000 \
-e ALLOWED_HOSTS=yourdomain.com \
-e DEBUG=False \
youtubedoc
π Example Output
The generated documentation includes:
- Video Metadata: Title, duration, view count, channel info
- Description: Full video description
- Transcript: Complete video transcript with timestamps
- Comments: Top video comments (if enabled)
- Token Estimation: Estimated token count for LLM usage
π§ͺ Testing
Install test dependencies and run the mocked, network-free tests:
python -m pip install -r requirements.txt pytest
python -m pytest tests/
python -m compileall -q src tests
π€ Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- Inspired by Gittodoc for the overall architecture and design
- Built with FastAPI for the web framework
- Uses yt-dlp for robust YouTube video processing
- Styled with Tailwind CSS for the modern UI
π Support
If you encounter any issues or have questions:
- Check the API documentation
- Review the issues page
- Create a new issue if needed
Made with β€οΈ for the AI and developer community
Jelajahi proyek terkait
Memuatβ¦