Posts what I'm watching on YouTube to Twitter/X. (personal use)
- Discord bot that monitors YouTube URLs in a specific channel
- Automatically posts to Twitter/X with video thumbnail
- Converts various YouTube URL formats to the short format
- Escapes @ mentions to prevent unwanted notifications
- Python 3.11+
- uv (Python package manager)
- Discord Bot Token
- Twitter API credentials
- YouTube Data API key
- Install uv if you haven't already:
curl -LsSf https://astral.sh/uv/install.sh | sh- Clone the repository and install dependencies:
git clone <repo-url>
cd yt-poster
uv sync- Create a
.envfile with your credentials:
DISCORD_BOT_TOKEN=your_discord_bot_token
CHANNEL_ID=your_discord_channel_id
TWITTER_CONSUMER_KEY=your_twitter_consumer_key
TWITTER_CONSUMER_SECRET=your_twitter_consumer_secret
TWITTER_ACCESS_TOKEN=your_twitter_access_token
TWITTER_ACCESS_TOKEN_SECRET=your_twitter_access_token_secret
YOUTUBE_API_KEY=your_youtube_api_keyLocal development:
# Using uv directly
uv run python src/main.py
# Or using the convenience script
uv run python run.py
# Or using Make
make run
make devDocker:
# Manual
docker-compose up --build
# Or using Make
make build
make startmake install- Install dependenciesmake run- Run the application locallymake dev- Run using the convenience scriptmake build- Build Docker imagemake start- Start with Dockermake start-bg- Start with Docker in backgroundmake stop- Stop Docker containersmake logs- Show Docker logsmake check- Check code syntaxmake clean- Clean up Docker and cachemake update- Update dependencies
| Variable | Description |
|---|---|
DISCORD_BOT_TOKEN |
Your Discord bot token |
CHANNEL_ID |
Discord channel ID to monitor |
TWITTER_CONSUMER_KEY |
Twitter API consumer key |
TWITTER_CONSUMER_SECRET |
Twitter API consumer secret |
TWITTER_ACCESS_TOKEN |
Twitter API access token |
TWITTER_ACCESS_TOKEN_SECRET |
Twitter API access token secret |
YOUTUBE_API_KEY |
YouTube Data API v3 key |