AtlatestRepositorytube
1# tube
2
3Video platform management CLI and MCP server — YouTube + Twitch unified in one interface.
4
5Upload videos, edit metadata, check analytics, schedule streams, manage chat, and get a cross-platform overview of your content channels.
6
7## Installation
8
9Requires a C toolchain. On Guix:
11```bash
12guix shell -m ../sigil/manifest.scm
13```
15Build:
17```bash
18sigil build --redirects dev-redirects.sgl
19```
21Run tests:
23```bash
24sigil test
25```
27## Usage
29### CLI Mode
31```bash
32# Platform overview (subscribers, followers, live status)
33tube status
35# List recent YouTube videos with stats
36tube videos --limit 20
38# Upload a video to YouTube
39tube upload video.mp4 --title "My Video" --description "About this video" --privacy unlisted
41# Analytics summary (YouTube + Twitch combined)
42tube analytics --days 30
44# View stream schedule across platforms
45tube stream-schedule --platform both
47# Start a broadcast
48tube go-live --title "Weekly Livestream" --platform both
50# Send a chat message
51tube chat "Hello everyone!" --platform twitch
52```
54### MCP Server Mode
56```bash
57tube serve
58```
60This starts an MCP server exposing the following tools:
62| Tool | Description |
63|------|-------------|
64| `tube/upload` | Upload video to YouTube |
65| `tube/videos` | List recent videos with stats |
66| `tube/analytics` | Cross-platform analytics summary |
67| `tube/schedule` | View stream schedule (YouTube + Twitch) |
68| `tube/go-live` | Start broadcast on one or both platforms |
69| `tube/chat` | Send message to live chat |
70| `tube/status` | Platform overview (subs, followers, live status) |
72## Configuration
74### OAuth Mode (Recommended)
76Set client credentials and use `tube auth` to authorize:
78```bash
79export YOUTUBE_CLIENT_ID="your-google-client-id"
80export YOUTUBE_CLIENT_SECRET="your-google-client-secret"
81export TWITCH_CLIENT_ID="your-twitch-client-id"
82export TWITCH_CLIENT_SECRET="your-twitch-client-secret"
84# Authorize each platform (opens browser, stores tokens)
85tube auth youtube
86tube auth twitch
87```
89Tokens are stored in `~/.config/sigil/<service>/tokens.json` and automatically refreshed when expired.
91### Direct Token Mode (Legacy)
93For manual token management, set access tokens directly:
95| Variable | Required | Description |
96|----------|----------|-------------|
97| `YOUTUBE_ACCESS_TOKEN` | For YouTube write ops | YouTube OAuth2 access token |
98| `YOUTUBE_API_KEY` | For YouTube read ops | YouTube Data API key |
99| `TWITCH_CLIENT_ID` | For Twitch | Twitch application client ID |
100| `TWITCH_ACCESS_TOKEN` | For Twitch | Twitch OAuth2 access token |
101| `TUBE_DEFAULT_PLATFORM` | No | Default platform: `youtube`, `twitch`, or `both` (default: `both`) |
103### OAuth Environment Variables
105| Variable | Description |
106|----------|-------------|
107| `YOUTUBE_CLIENT_ID` | Google Cloud OAuth2 client ID |
108| `YOUTUBE_CLIENT_SECRET` | Google Cloud OAuth2 client secret |
109| `TWITCH_CLIENT_ID` | Twitch application client ID |
110| `TWITCH_CLIENT_SECRET` | Twitch application client secret |
112You only need credentials for the platforms you want to use. If you only have YouTube credentials, Twitch operations will gracefully report that credentials are missing, and vice versa.
114## Architecture
116```
117src/tube/
118 config.sgl — Environment-based configuration
119 youtube.sgl — YouTube operations (wraps sigil-youtube)
120 twitch.sgl — Twitch operations (wraps sigil-twitch)
121 tools.sgl — MCP tool definitions + shared helpers
122 main.sgl — Dual CLI/MCP entry point
123```
125tube follows the dual CLI/MCP server pattern used by [fjo](https://codeberg.org/sigil/fjo) and [tally](https://codeberg.org/sigil/tally). The same business logic serves both the command-line interface and MCP tool handlers.
127## Dependencies
129- [sigil-youtube](https://codeberg.org/sigil/sigil-youtube) — YouTube Data API v3 client
130- [sigil-twitch](https://codeberg.org/sigil/sigil-twitch) — Twitch Helix API client
131- [sigil-mcp](https://codeberg.org/sigil/sigil) — MCP server framework
133## License
135BSD-3-Clause