YouTube to Google Sheets Summarizer Bot
This project automates the process of watching a YouTube video, using Google's Gemini AI to extract structured information about specific topics (like stock charts), and populating a Google Sheet with the results.
The project is broken into three main, modular scripts orchestrated by a main bot script.
Complete code : https://github.com/naren4b/ai-journey/tree/main/cow_video_summary_bot
Workflow Diagram
The following diagram illustrates the complete data flow from the user's command to the final updated Google Sheet.
Project Structure
video_summary_bot.py: The main entry point and orchestrator. You run this script.transcript_fetcher.py: Fetches the video transcript and saves it locally.gemini_processor.py: Reads the local transcript, analyzes it with Gemini, and saves the structured results.sheets_updater.py: Reads the structured results and updates the Google Sheet.credentials.json: (You must provide this) Your secret key for the Google Cloud Service Account..gitignore: Tells version control which files to ignore.
Setup
-
Install Python Libraries:
-
Google Cloud & Sheets API:
- Create a Google Cloud Project and enable the Google Sheets API and Google Drive API.
- Create a Service Account with the Editor role.
- Create a JSON key for the service account and download it. Rename the file to
credentials.jsonand place it in this project folder. - Share your target Google Sheet (
Chart Of The Week) with theclient_emailfound inside yourcredentials.jsonfile, giving it "Editor" permissions.
-
Set Environment Variables: This project requires environment variables for security.
On Windows (Command Prompt):
On macOS/Linux:
How to Run
Execute the main bot script from your terminal, providing the YouTube video URL as a command-line argument.
The script will run through the three steps (fetching, processing, updating) and print its progress. Upon completion, your Google Sheet will be updated with the extracted information.