This Python script generates notes from YouTube video transcripts using AI. It fetches the transcript, generates summarized notes, and saves them in both markdown and PDF formats.
- Fetch transcripts from YouTube videos
- Generate summarized notes using AI (Gemini)
- Save notes in markdown and PDF formats
- Copy notes to clipboard (optional)
- Python 3.11+
- ffmpeg (required for yt-dlp)
- wkhtmltopdf (required for pdfkit)
- yt-dlp
- litellm
- python-dotenv
- markdown2
- pdfkit
- pyperclip
You can install this project using either pip or Poetry.
-
Install ffmpeg:
- On macOS (using Homebrew):
brew install ffmpeg
- On Ubuntu/Debian:
sudo apt-get install ffmpeg
- On Windows: Download from https://ffmpeg.org/download.html and add to PATH
- On macOS (using Homebrew):
-
Install wkhtmltopdf:
- On macOS (using Homebrew):
brew install wkhtmltopdf
- On Ubuntu/Debian:
sudo apt-get install wkhtmltopdf
- On Windows: Download from https://wkhtmltopdf.org/downloads.html and add to PATH
- On macOS (using Homebrew):
-
Clone the repository:
git clone https://github.com/risonsimon/youtube-notes.git cd youtube-notes
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the required packages:
pip install yt-dlp litellm python-dotenv markdown2 pdfkit pyperclip
Poetry is a modern dependency management and packaging tool for Python projects.
-
Clone the repository:
git clone https://github.com/risonsimon/youtube-notes.git cd youtube-notes
-
Install Poetry if you haven't already:
curl -sSL https://install.python-poetry.org | python3 -
-
Initialize a new Poetry project:
poetry init
-
Add the required dependencies:
poetry add yt-dlp litellm python-dotenv markdown2 pdfkit pyperclip
-
Install the dependencies:
poetry install
To use the AI features of this script, you need a Gemini API key. Follow these steps to obtain your API key:
- Visit Google AI Studio.
- Sign in with your Google account.
- Follow the instructions to generate a new API key.
- Copy the generated API key for use in the script.
-
Activate your virtual environment (if using pip) or run
poetry shell
(if using Poetry). -
Run the script with the following command:
python youtube-notes/index.py <YouTube_URL> --gemini-api-key <YOUR_GEMINI_API_KEY> [--copy-to-clipboard]
Replace
<YouTube_URL>
with the URL of the video you want to generate notes for, and<YOUR_GEMINI_API_KEY>
with your actual Gemini API key.Use the
--copy-to-clipboard
flag if you want to copy the generated notes to your clipboard. -
The script will generate a transcript file, a text file with the notes, and a PDF file with the formatted notes in your Downloads folder.
You can set the GEMINI_API_KEY
environment variable instead of passing it as a command-line argument. Create a .env
file in the project root directory with the following content:
GEMINI_API_KEY=your_gemini_api_key_here
This project is licensed under the MIT License - see the LICENSE file for details.