This program fetches your YouTube watch history for the past week, retrieves video transcripts and descriptions, and generates AI-powered summaries with key points and learnings for each video.
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt -U-
Set up YouTube API credentials:
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the YouTube Data API v3
- Create OAuth 2.0 credentials (Desktop application)
- Download the client configuration file and save it as
client_secrets.jsonin the project directory
-
Create a
.env.localfile with your API keys:
YOUTUBE_API_KEY=your_youtube_api_key
OPENAI_API_KEY=your_openai_api_key
Run the program:
python app.pyThe program will:
- Authenticate with YouTube (first time will open a browser for OAuth)
- Fetch your watch history for the past 7 days
- Get transcripts and descriptions for each video
- Generate summaries using OpenAI's GPT-4
- Save results to a JSON file named
youtube_summaries_YYYYMMDD.json
The output JSON will contain:
- Video details (ID, title, author, watch date)
- Summary of the video content
- Key points discussed
- Main learnings from the video
- The program requires YouTube OAuth authentication to access your watch history
- Video transcripts are retrieved when available; otherwise, video descriptions are used
- Summaries are generated using OpenAI's GPT-4 model
- Results are saved in JSON format for easy parsing and integration with other tools