A small Flask web app that fetches English subtitles/transcripts for a YouTube video and displays them in the browser.
The sole purpose of this project is to make it easy for an end user to:
- Paste a YouTube link
- Click a button
- Copy a clean, human‑readable transcript
This is especially useful for feeding transcripts into LLMs for summarization, analysis, or note‑taking.
- Create a RapidAPI account
- Sign up at https://rapidapi.com
- Subscribe to this exact API (free plan is sufficient)
- 👉 https://rapidapi.com/ytjar/api/yt-api
- The free tier currently allows 300 requests per month
- Create a RapidAPI App
- RapidAPI will generate an API key for that app
- Create a
.envfile with the values below - Run the app (locally or with Docker)
That’s it — no direct YouTube API credentials required.
Main branch:
This app uses one provider only: the yt-api RapidAPI provider.
While the code could be refactored to support additional providers, only this RapidAPI integration is wired in onmain.
This project originally attempted to call YouTube APIs directly. That approach works locally, but once deployed to a server or datacenter IP, requests were blocked. Using RapidAPI avoids those IP‑based restrictions and provides a reliable hosted endpoint.
- Accepts a YouTube URL:
youtube.com/watch?v=…m.youtube.comyoutu.be/…
- Queries the RapidAPI yt-api endpoint for subtitle metadata
- Selects an English subtitle track (SRV1 format)
- Downloads and parses the XML transcript
- Renders a single, clean block of readable text
- Displays remaining request quota information
- Python
- Flask
requestsfor HTTP callsgunicornfor production serving- Docker + docker‑compose for deployment
You must do the following:
- Have a RapidAPI account
- Subscribe to yt-api:
- Create a RapidAPI App
- Use the App’s API key in this project
Without this, the app will not work.
Create a .env file (or set environment variables) with these exact values:
RAPIDAPI_HOST="yt-api.p.rapidapi.com"
YT_API_RAPIDAPI_URL="https://yt-api.p.rapidapi.com/subtitles"
RAPIDAPI_KEY="your_rapidapi_app_key_here"| Variable | Description |
|---|---|
RAPIDAPI_HOST |
Must be yt-api.p.rapidapi.com |
YT_API_RAPIDAPI_URL |
Subtitles endpoint used by the app |
RAPIDAPI_KEY |
API key from your RapidAPI App |
pip install -r requirements.txt
python app.pyThen open:
http://localhost:5000
Build the image:
docker build -t youtube-transcript-app .Run it:
docker run --rm -p 5000:5000 --env-file .env youtube-transcript-appOpen:
http://localhost:5000
The repository includes a docker-compose.yml file.
docker compose up -dThis expects:
- a
.envfile in the same directory - the RapidAPI variables defined above
A common deployment flow:
- Build the image locally
- Tag it
- Push to your registry (e.g. Docker Hub)
- Pull and restart on your server
Example:
docker build -t youtube-transcript-app .
docker tag youtube-transcript-app turc1656/youtube-transcript:latest
docker push turc1656/youtube-transcript:latestEnsure docker-compose.yml references the same image tag.
This repo includes deploy_script.py, which can trigger a server‑side webhook to pull the latest image and restart the container.
| Variable | Description |
|---|---|
DEPLOYMENT_WEBHOOK_URL |
Server endpoint that performs the deploy |
DEPLOYMENT_SECRET_TOKEN |
Shared secret validated by the server |
Run:
python deploy_script.pyThe current script sends the token as a query parameter (?token=...).
For better security in production, consider:
- Sending the token in a request header
- Validating it server‑side before deploying
MIT — see LICENSE.