A command-line Twitch client for ad-free streaming using Android platform impersonation. Play live streams and VODs directly from your terminal with your choice of media player.
- Ad-free playback - Uses Android mobile platform impersonation to bypass ads. You may get one 15s ad once then no more ads after that.
- Multiple player support - Works with mpv, VLC, Flatpak VLC and ffplay
- Live streams & VODs - Supports both live channels and video-on-demand
- OAuth authentication - Optional login for extended features
- Followed Channels: List and play live streams from your followed channels.
- Category Search: Search for and play live streams by game/category.
- Stream info display - Shows stream title, channel, and game category
- Colored terminal output - Beautiful ANSI-colored banners and help text
- Language: Python 3.7+
- HTTP Client: requests
- Media Players: mpv (recommended), VLC, Flatpak VLC, ffplay
- Authentication: OAuth 2.0 (Implicit Grant)
- API: Twitch GraphQL & Helix API
- Networking:
requests - Optional:
qrcode(for QR login generation)
Before installing, ensure you have:
- Python 3.7+ - Download from python.org
- pip - Python package manager (usually bundled with Python)
- A media player - One of the following:
mpv(recommended) - mpv.iovlc- videolan.orgffplay- Part of ffmpegflatpak-vlc- flatpak-vlc
# Clone or download the repository
cd twitch-cli
# Install Python dependencies
pip install requests qrcode
# Run the installer (optional, makes scripts executable)
chmod +x install.sh twitch_cli.py twitch
./install.shLinux (Ubuntu/Debian):
sudo apt install mpv # Recommended
sudo apt install vlc # Alternative
sudo apt install ffmpeg # For ffplayLinux (Fedora):
sudo dnf install mpv # Recommended
sudo dnf install vlc # Alternative
sudo dnf install ffmpeg # For ffplayLinux (Flatpak):
flatpak install flathub org.videolan.VLC macOS (Homebrew):
brew install mpv
brew install vlc
brew install ffmpegWindows (Chocolatey):
choco install mpv
choco install vlc
choco install ffmpeg# Play a channel by name
python twitch_cli.py STREAMER
# Login to access your followed channels
python twitch_cli.py --login
# Play from URL
python twitch_cli.py https://www.twitch.tv/emiru
# Search live streams by game
python twitch_cli.py --search "GAME"
# List followed live streams
python twitch_cli.py --followed
# Use specific player
python twitch_cli.py STREAMER -p vlc
# Play VOD by ID
python twitch_cli.py https://www.twitch.tv/videos/1234567890
# Show help with colors
python twitch_cli.py --help| Option | Description | Default |
|---|---|---|
CHANNEL |
Channel name or Twitch URL | Required |
-p, --player PLAYER |
Media player (mpv, vlc, ffplay, flatpak-vlc) | mpv |
--list-players |
Show available players | - |
--login |
Force OAuth re-login | - |
--logout |
Clear stored token | - |
--followed |
List and play live followed channels | - |
--search "GAME" |
Search and play live streams for a game | - |
--custom-player CMD |
Custom player command with {url} placeholder |
- |
--token TOKEN |
Use provided OAuth token | - |
# Play xQc's stream with default mpv player
python twitch_cli.py xqc
# Play Emiru with VLC
python twitch_cli.py nmplol -p vlc
# Play with custom mpv settings (fullscreen, no border)
python twitch_cli.py shroud --custom-player "mpv --fullscreen --no-border {url}"
# Force OAuth login (for private streams)
python twitch_cli.py --login
# Clear saved OAuth token
python twitch_cli.py --logout
# List all available player options
python twitch_cli.py --list-playersUser Input (channel name or URL)
↓
Parse URL → Extract channel/VOD ID
↓
Twitch GraphQL API (Android mobile params)
↓
Fetch stream playback token + signature
↓
Generate HLS URL with auth params
↓
Launch media player with stream URL
↓
Ad-free playback in mpv/vlc/ffplay
The tool mimics an Android mobile client when requesting stream URLs:
params = {
"platform": "android",
"playerBackend": "mediaplayer",
"playerType": "mobile"
}This causes Twitch to serve:
- Ad-free stream URLs (no mid-roll ads)
- Mobile-optimized bitrates
- No ad SDK required on client side
twitch_cli.py - Main script (~750 lines)
TwitchPlayerclass - Handles API communicationget_stream_info()- Fetches stream title, game, channel infoget_stream_playback_token()- Gets authenticated playback tokenget_stream_url()/get_vod_url()- Generates final HLS URLget_player_args()- Configures media player command
Authentication Flow:
- Check for stored OAuth token (
.twitch_token) - If missing, generate QR code for S0undTV OAuth
- User scans QR with phone, pastes redirect URL
- Token extracted and saved locally
- Token used for subsequent API requests
Player Configuration:
| Player | Command Flags | Title Support |
|---|---|---|
| mpv | --vo=gpu --hwdec=auto --cache=yes |
--force-media-title |
| vlc | --intf=rc |
--meta-title |
| ffplay | -autoexit -headers |
-window_title |
MPV configuration with ~/.config/mpv/mpv.conf
# Start with a manageable default size
autofit=70%
# Ensure the window is always created
force-window=yes
# Set volume to 70% on startup
volume=70
twitch-cli/
├── twitch_cli.py # Main CLI script (746 lines)
├── twitch # Wrapper script for direct execution
├── install.sh # Installer with dependency checks
├── README.md # This documentation
├── QUICKSTART.md # Quick start guide
├── TWITCH_API.md # Twitch Helix API Integration
└── .twitch_token # Stored OAuth token (after login)
When playing a stream, the CLI displays:
╭────────────────────────────────────────────────╮
│ Twitch CLI Player — Ad-free streaming │
╰────────────────────────────────────────────────╯
Fetching stream for willneff...
Stream: MOBIES - willneff | Just Chatting
Player: mpv
Starting playback...
The stream info includes:
- Title - Current stream title from Twitch
- Channel - Streamer's username
- Game - Category/game being played
- Private/subscriber-only streams
- Age-restricted content
- Higher API rate limits
- Chat integration (future feature)
# Force login
python twitch_cli.py --login
# Interactive flow:
# 1. QR code displayed in terminal
# 2. Scan with phone
# 3. Paste redirect URL
# 4. Token saved to .twitch_token- Location:
.twitch_tokenin the script directory - Format: Plain text OAuth token
- Security: Local file, user permissions apply
# View stored token
cat .twitch_token
# Delete token (logout)
python twitch_cli.py --logout
rm .twitch_tokenModuleNotFoundError: No module named 'requests'
pip install requestsPlayer 'mpv' not found
# Install mpv
sudo apt install mpv # Ubuntu/Debian
sudo dnf install mpv # Fedora
brew install mpv # macOS
choco install mpv # WindowsChannel not found or 404 Not Found
- Channel is offline (not live)
- Check spelling of channel name
- Try full URL:
python twitch_cli.py https://twitch.tv/channelname
HTTP 403 Forbidden
- OAuth token expired - run
--logoutthen--login - Channel has subscriber-only mode
- Geographic restrictions apply
Stream buffering or stuttering
- Lower quality: Player can switch video/audio quality during playback via its own controls
- Check network connection
- Try different player:
-p vlc
Colors not displaying correctly
- Ensure terminal supports ANSI escape codes
- Try a modern terminal emulator (alacritty, kitty, iTerm2)
- Windows: Use Windows Terminal or WSL
| Feature | Twitch CLI | Twitch Desktop | Twitch Web |
|---|---|---|---|
| Ad-free | ✅ Yes | ❌ No | ❌ No |
| Resource usage | ~50MB | ~500MB+ | ~300MB+ |
| Player choice | Any | Built-in only | Built-in only |
| Customization | Full | Limited | None |
| Offline viewing | Manual | No | No |
This tool is for personal use only. Key points:
- Respect streamers - Consider subscribing if you enjoy their content
- No redistribution - Do not redistribute stream content
- Terms of Service - Use may violate Twitch ToS; use at your own risk
- Educational purpose - Provided as a learning tool for API integration
- Technique inspired by S0undTV Android client
- Uses Twitch GraphQL & Helix API for stream metadata
- OAuth flow based on Twitch's official documentation
