Command-line client for CyTube via kryten-py library
Project description
Kryten CLI
Command-line client for sending CyTube commands via the kryten-py library.
Overview
This CLI provides a simple command-line interface to control CyTube channels through the Kryten bridge. It uses the high-level kryten-py library for all communication, making it a clean and maintainable reference implementation.
Installation
Install the CLI tool:
pip install -e .
This will automatically install the kryten-py dependency.
Or run directly:
python kryten_cli.py --help
Configuration
The CLI reads connection settings from config.json in the current directory. Create one with your NATS server and CyTube channel:
{
"nats": {
"servers": ["nats://localhost:4222"]
},
"channels": [
{
"domain": "cytu.be",
"channel": "your-channel-name"
}
]
}
Legacy Format Support: The CLI also supports the older config format with cytube.channel for backward compatibility.
You can also specify a different config file:
kryten --config /path/to/config.json say "Hello"
Usage Examples
Chat Commands
Send a chat message:
kryten say "Hello world"
Send a private message:
kryten pm UserName "Hi there!"
Playlist Commands
Add video to end of playlist:
kryten playlist add https://youtube.com/watch?v=xyz
kryten playlist add yt:abc123
Add video to play next:
kryten playlist addnext https://youtube.com/watch?v=abc
Add as temporary (auto-deleted after playing):
kryten playlist add --temp https://youtube.com/watch?v=xyz
Delete video from playlist:
kryten playlist del video-uid-123
Move video in playlist:
kryten playlist move video-uid-5 after video-uid-3
Jump to specific video:
kryten playlist jump video-uid-7
Clear entire playlist:
kryten playlist clear
Shuffle playlist:
kryten playlist shuffle
Set video temporary status:
kryten playlist settemp video-uid-5 true
kryten playlist settemp video-uid-5 false
Playback Commands
Pause current video:
kryten pause
Resume playback:
kryten play
Seek to timestamp (in seconds):
kryten seek 120.5
Moderation Commands
Kick user:
kryten kick UserName
kryten kick UserName "Stop spamming"
Ban user:
kryten ban UserName
kryten ban UserName "Banned for harassment"
Vote to skip current video:
kryten voteskip
Command Reference
| Command | Description |
|---|---|
say <message> |
Send a chat message |
pm <user> <message> |
Send a private message |
playlist add <url> |
Add video to end of playlist |
playlist addnext <url> |
Add video to play next |
playlist del <uid> |
Delete video from playlist |
playlist move <uid> after <uid> |
Move video in playlist |
playlist jump <uid> |
Jump to specific video |
playlist clear |
Clear entire playlist |
playlist shuffle |
Shuffle playlist |
playlist settemp <uid> <true|false> |
Set temporary status |
pause |
Pause playback |
play |
Resume playback |
seek <seconds> |
Seek to timestamp |
kick <user> [reason] |
Kick user from channel |
ban <user> [reason] |
Ban user from channel |
voteskip |
Vote to skip current video |
Options
| Option | Description |
|---|---|
--config <path> |
Path to config file (default: config.json) |
--channel <name> |
Override channel from config |
--help |
Show help message |
NATS Message Format
All commands are published to NATS subjects following this pattern:
cytube.commands.{channel}.{action}
Message payload:
{
"action": "chat",
"data": {
"message": "Hello world"
}
}
This format is compatible with the Kryten bidirectional bridge's CommandSubscriber.
Requirements
- Python 3.11+
- nats-py >= 2.9.0
- Kryten bidirectional bridge running with
commands.enabled = true
Examples
Automated DJ
Add a list of videos:
for url in $(cat playlist.txt); do
kryten playlist add "$url"
sleep 1
done
Bot Integration
Use in scripts to respond to events:
#!/bin/bash
# Greet new users
kryten say "Welcome to the channel!"
Remote Moderation
Quick moderation commands:
kryten kick TrollUser "Please follow the rules"
kryten ban SpamBot "Automated spam detected"
Troubleshooting
Connection refused
Make sure NATS server is running:
# Start NATS server
nats-server
Command not found
Make sure the CLI is installed:
pip install -e .
Or use the module directly:
python kryten_cli.py say "Hello"
Commands not executing
- Check that Kryten bridge is running
- Verify
commands.enabled = truein Kryten's config - Check NATS connection settings match between CLI and Kryten
- Verify channel name is correct
Version 2.0 - Using kryten-py Library
Version 2.0 is a complete rewrite that uses the kryten-py library instead of direct NATS calls. This provides:
- Cleaner code: High-level API instead of low-level NATS
- Type safety: Typed interfaces and better IDE support
- Better maintenance: Shares code with other kryten projects
- New features: Automatic URL parsing for media commands
For migration information from v1.x, see MIGRATION.md.
For complete details about the refactor, see REFACTOR_SUMMARY.md.
Contributing
This project serves as a reference implementation for using kryten-py. Contributions are welcome!
License
See LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kryten_cli-2.1.1.tar.gz.
File metadata
- Download URL: kryten_cli-2.1.1.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96b192d1fdcb4538eaa0f7dff996119de71b050272cb8c2fde6080eb6bb12c96
|
|
| MD5 |
c4f138c2053895bd558572e203e6341f
|
|
| BLAKE2b-256 |
c9859e5cfb0736e7a20ab085d76fe88d972fb76fb7f4f4b117973e97594003cd
|
Provenance
The following attestation bundles were made for kryten_cli-2.1.1.tar.gz:
Publisher:
python-publish.yml on grobertson/kryten-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kryten_cli-2.1.1.tar.gz -
Subject digest:
96b192d1fdcb4538eaa0f7dff996119de71b050272cb8c2fde6080eb6bb12c96 - Sigstore transparency entry: 754789547
- Sigstore integration time:
-
Permalink:
grobertson/kryten-cli@6a8ca0658bbf37de448b450de9383955853d84f8 -
Branch / Tag:
refs/tags/v2.1.1 - Owner: https://github.com/grobertson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@6a8ca0658bbf37de448b450de9383955853d84f8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file kryten_cli-2.1.1-py3-none-any.whl.
File metadata
- Download URL: kryten_cli-2.1.1-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f56d203cf94c46c6b05aa9779f78bdcd50200a3842244e884f6b9687b16381d8
|
|
| MD5 |
65ec8854a3a1126f761a4f92a7d32bc2
|
|
| BLAKE2b-256 |
a60ab0b8d6ea42c04b851737add0d37625966b775dc1d815a8241a1398ccd6d6
|
Provenance
The following attestation bundles were made for kryten_cli-2.1.1-py3-none-any.whl:
Publisher:
python-publish.yml on grobertson/kryten-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kryten_cli-2.1.1-py3-none-any.whl -
Subject digest:
f56d203cf94c46c6b05aa9779f78bdcd50200a3842244e884f6b9687b16381d8 - Sigstore transparency entry: 754789580
- Sigstore integration time:
-
Permalink:
grobertson/kryten-cli@6a8ca0658bbf37de448b450de9383955853d84f8 -
Branch / Tag:
refs/tags/v2.1.1 - Owner: https://github.com/grobertson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@6a8ca0658bbf37de448b450de9383955853d84f8 -
Trigger Event:
release
-
Statement type: