Skip to content

Add YouTube live stream monitoring workflow#103

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-102
Draft

Add YouTube live stream monitoring workflow#103
Copilot wants to merge 4 commits intomainfrom
copilot/fix-102

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 19, 2025

Implements a temporal workflow that monitors YouTube channels for new live streams and sends Slack notifications when channels go live.

Features

  • Automated Monitoring: Runs every 2 minutes via Temporal scheduler
  • YouTube API Integration: Polls YouTube Data API v3 to detect new live streams
  • Smart Filtering: Only notifies for streams that started within the last 2 minutes
  • Slack Notifications: Sends formatted messages to a configurable Slack channel
  • Configurable Channels: Monitor any YouTube channels by channel ID
  • Error Handling: Graceful handling of API failures and network issues

Implementation Details

New Components

  • YouTubeLiveWorkflow - Main temporal workflow that orchestrates the monitoring
  • check_youtube_live_streams_activity - Activity that queries YouTube API
  • send_slack_notification_activity - Activity that sends Slack notifications
  • Parameter classes for type-safe workflow configuration

Integration

  • Added to existing temporal worker configuration
  • Follows established patterns from SlackMessageQODWorkflow
  • Uses existing Slack client infrastructure

Configuration

Requires YOUTUBE_API_KEY environment variable with YouTube Data API v3 credentials.

Default monitored channels (configurable):

channel_ids = [
    "UC_x5XG1OV2P6uZZ5FSM9Ttw",  # Google Developers
    "UCsooa4yRKGN_zEE8iknghZA",  # TED-Ed
    "UC8butISFwT-Wl7EV0hUK0BQ",  # Free Code Camp
]

Example Notification

🔴 *Google Developers* just went live!
📺 Building Modern Web Apps with Firebase
🔗 https://youtube.com/watch?v=abc123

Testing

Added comprehensive unit tests covering:

  • Workflow parameter validation
  • Activity parameter structures
  • Schedule configuration (2-minute intervals)
  • Data model instantiation

Documentation

  • Complete setup guide in docs/youtube-live-monitor.md
  • API quota usage estimates
  • Environment configuration examples

Fixes #102.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits June 19, 2025 22:48
Co-authored-by: QMasterMoo <3915399+QMasterMoo@users.noreply.github.com>
Co-authored-by: QMasterMoo <3915399+QMasterMoo@users.noreply.github.com>
Copilot AI changed the title [WIP] create a youtube live workflow Add YouTube live stream monitoring workflow Jun 19, 2025
Copilot AI requested a review from QMasterMoo June 19, 2025 22:50
youtube = build("youtube", "v3", developerKey=api_key)

# Calculate time threshold
now = datetime.now(timezone.utc)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should use the scheduled time on temporal. otherwise it would be possible for delays

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit a51da38. The activity now uses workflow.info().current_build_started_at as the scheduled time instead of datetime.now(). This ensures consistent monitoring windows even if there are execution delays, preventing missed streams or incorrect time calculations.

…nitoring windows

Co-authored-by: QMasterMoo <3915399+QMasterMoo@users.noreply.github.com>
Copilot AI requested a review from QMasterMoo June 19, 2025 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create a youtube live workflow

2 participants