Skip to content

Its-donkey/yougopher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

123 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yougopher

Go Reference codecov Go Report Card

A YouTube API toolkit in Go focused on live chat bot functionality.

Installation

go get github.com/Its-donkey/yougopher

Features

  • OAuth 2.0 - Authorization code flow, device flow, service accounts
  • Quota Tracking - Built-in YouTube API quota management
  • Data API - Videos, channels, playlists, search, comments, subscriptions
  • Live Streaming - Live chat polling, moderation, broadcasts, stream management
  • Analytics - Channel statistics, views, demographics, revenue
  • Caching - In-memory cache with TTL support
  • Middleware - Logging, retry, metrics, rate limiting

Requirements

  • Go 1.23 or later
  • YouTube Data API v3 credentials

Quick Start

package main

import (
    "context"
    "log"

    "github.com/Its-donkey/yougopher/youtube/auth"
    "github.com/Its-donkey/yougopher/youtube/core"
    "github.com/Its-donkey/yougopher/youtube/streaming"
)

func main() {
    ctx := context.Background()

    // Initialize clients
    client := core.NewClient()
    authClient := auth.NewAuthClient(auth.Config{
        ClientID:     "your-client-id",
        ClientSecret: "your-client-secret",
        RedirectURL:  "http://localhost:8080/callback",
    })

    // Create chat bot
    bot, err := streaming.NewChatBotClient(client, authClient, "live-chat-id")
    if err != nil {
        log.Fatal(err)
    }

    // Register message handler
    bot.OnMessage(func(msg *streaming.ChatMessage) {
        log.Printf("[%s] %s", msg.Author.DisplayName, msg.Message)
    })

    // Connect and start listening
    if err := bot.Connect(ctx); err != nil {
        log.Fatal(err)
    }
    defer bot.Close()

    select {} // Keep running
}

Packages

Package Description
youtube/core HTTP client, errors, quota tracking, cache, middleware
youtube/auth OAuth 2.0 flows, device flow, service accounts, token management
youtube/streaming Live chat bot, polling, moderation, broadcasts
youtube/data Videos, channels, playlists, search, comments, subscriptions
youtube/analytics YouTube Analytics API (channel stats, demographics, revenue)

Documentation

Example Projects

See docs/examples/ for complete working applications:

License

MIT License - see LICENSE for details.

About

A YouTube API toolkit in Go focused on live chat bot functionality

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors