Agent Angus is an AI agent that automates YouTube publishing and audience feedback collection for AI-generated music videos.
Agent Angus automates the following tasks:
- Upload existing songs from Supabase to YouTube
- Track uploaded videos in a new YouTube table
- Retrieve and store YouTube comments in the Supabase database for analysis
angus.py- Main script for Agent Angusyoutube_client.py- Client for interacting with YouTube APIsupabase_client.py- Client for interacting with Supabaseopenai_utils.py- Utilities for generating responses using OpenAIcreate_youtube_table.sql- SQL script to create the YouTube table in Supabaserequirements.txt- List of Python dependenciesRoadmap.md- Project roadmap and implementation detailsTESTING.md- Documentation for testing the OpenAI comment response feature- Test scripts:
test_openai_response.py- Tests OpenAI response generationtest_youtube_reply.py- Tests YouTube comment reply functionalitytest_comment_response_flow.py- Tests the complete comment response flowtest_fetch_specific_video.py- Tests fetching comments for a specific videotest_angus_specific_video.py- Tests running Angus on a specific video
- Python 3.7+
- Supabase account with existing songs database
- YouTube API credentials (API key, OAuth client ID and client secret, channel ID)
- OpenAI API key (for generating responses to YouTube comments)
- 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:
- Go to "Credentials" > "Create Credentials" > "OAuth client ID"
- Select "Desktop app" as the application type
- Add the following authorized redirect URI:
urn:ietf:wg:oauth:2.0:oob(this is for out-of-band authentication)
- Note your Client ID and Client Secret
- Create an API key for simple API calls
-
Clone the repository:
git clone <repository-url> cd angus
-
Install dependencies:
pip install -r requirements.txt
Or install dependencies manually:
pip install google-auth google-auth-oauthlib google-auth-httplib2 google-api-python-client supabase requests openai python-dotenv schedule
-
Set up environment variables:
# YouTube API Credentials export YOUTUBE_API_KEY=your-api-key export YOUTUBE_CLIENT_ID=your-client-id export YOUTUBE_CLIENT_SECRET=your-client-secret export YOUTUBE_CHANNEL_ID=your-channel-id # Supabase Credentials export SUPABASE_URL=your-supabase-url export SUPABASE_KEY=your-supabase-key # OpenAI API Credentials export OPENAI_API_KEY=your-openai-api-key
Alternatively, create a
.envfile with these variables.
Create the YouTube table in Supabase to track uploaded videos:
python angus.py --create-tableUpload songs from the Supabase songs table to YouTube:
python angus.py --upload --limit 5This will upload up to 5 songs that have video URLs but haven't been uploaded to YouTube yet.
Retrieve comments for uploaded YouTube videos, store them in the Supabase feedback table, and reply to them:
python angus.py --fetch-comments --limit 10 --max-replies 10This will:
- Fetch comments for up to 10 uploaded videos
- Store them in the feedback table
- Reply to up to 10 comments across all videos using OpenAI-generated responses
You can adjust the --max-replies parameter (default: 10) to control how many comments to reply to in a single run.
Run Agent Angus continuously with scheduled tasks:
python angus.py --daemonIn daemon mode, Agent Angus will:
- Upload 1 video to YouTube every hour
- Fetch comments from up to 10 videos every hour
- Automatically respond to up to 10 new comments per hour using OpenAI-generated responses
- Distribute replies fairly across videos
- Run continuously until interrupted (Ctrl+C)
This is useful for automating the YouTube publishing and feedback collection process.
Agent Angus automatically uploads videos from your Supabase songs table to YouTube. It ensures that each song is only uploaded once by tracking the upload status in the YouTube table.
Agent Angus fetches comments from your YouTube videos and stores them in the Supabase feedback table for analysis.
Agent Angus uses OpenAI to generate personalized responses to YouTube comments. The system:
- Fetches new comments from your videos
- Generates contextual responses based on the song title and style
- Posts the responses as replies to the comments
- Tracks which comments have already been responded to
- Intelligently distributes replies across multiple videos
- Limits the number of replies per hour to avoid rate limiting
The multi-comment reply capability ensures that:
- Up to 10 comments (configurable) are replied to per hour
- Replies are distributed fairly across all videos
- Comments that already have replies are skipped
- All processed comments are stored in the feedback table
This feature helps engage with your audience automatically and provides a way to track which comments have been processed.
The YouTube table tracks videos uploaded to YouTube:
| Field Name | Type | Description |
|---|---|---|
id (PK) |
uuid |
Unique ID, primary key (auto-generated) |
song_id |
uuid |
Reference to songs table |
youtube_id |
text |
YouTube video ID |
title |
text |
Video title on YouTube |
description |
text |
Video description on YouTube |
upload_date |
timestamp |
Timestamp of when the video was uploaded |
status |
text |
Upload status (e.g., "pending", "uploaded", "failed") |
view_count |
integer |
Number of views (can be updated periodically) |
like_count |
integer |
Number of likes (can be updated periodically) |
The first time you run the script with the --upload flag, you'll need to authenticate with YouTube:
-
Make sure you've added the required redirect URI to your Google Cloud Console project:
urn:ietf:wg:oauth:2.0:oob(for out-of-band authentication)
-
When you run the script, it will display a URL in the console like this:
Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?... After authorization, you will receive a code. Please enter that code here: -
Copy and paste this URL into your browser
-
Sign in with your Google account and grant the requested permissions
-
After authorization, you'll see a code displayed in the browser. Copy this code.
-
Paste the code back into the console prompt and press Enter
-
If authentication is successful, a
token.picklefile will be created in your project directory. This file stores your credentials for future use, so you won't need to repeat this process unless the token expires.
If you encounter OAuth errors:
- Verify that you've added the correct redirect URI (
urn:ietf:wg:oauth:2.0:oob) to your Google Cloud Console project - Make sure you're using the correct client ID and client secret in your
.envfile - Check that your Google Cloud project has the YouTube Data API v3 enabled
- If you're still having issues, try deleting the
token.picklefile (if it exists) and authenticating again
If you encounter Supabase connection errors:
- Verify your Supabase URL and key in the
.envfile - Make sure your Supabase project is active
- Check that the required tables exist in your database
If videos fail to upload:
- Check that the video URLs in your songs table are valid and accessible
- Verify that your YouTube account has upload permissions
- Check for any quota limitations on your YouTube API usage
If you encounter issues with OpenAI comment responses:
- Verify your OpenAI API key is correct in the
.envfile - Check that your OpenAI account has sufficient credits
- If responses are not being generated, check the OpenAI API status at https://status.openai.com/
- Adjust the system prompt in
openai_utils.pyif you want to change the style or length of responses
Agent Angus includes several test scripts to verify different aspects of the system:
Test the OpenAI response generation without requiring YouTube integration:
python test_openai_response.pyThis tests the ability to generate contextual responses to comments using OpenAI.
Test replying to a specific YouTube comment:
python test_youtube_reply.py --video-id VIDEO_ID [--comment-id COMMENT_ID]This tests the ability to fetch comments and post replies on YouTube.
Test the entire comment response flow:
python test_comment_response_flow.py --video-id VIDEO_IDThis tests the complete process from fetching comments to generating responses and posting replies.
Test fetching comments for a specific video and checking if they have replies:
python test_fetch_specific_video.py --video-id VIDEO_IDTest running Angus on a specific video:
python test_angus_specific_video.py --video-id VIDEO_IDFor more detailed testing instructions, see the TESTING.md file.