A lightweight daemon that automatically syncs Jellyfin user access with Telegram channel membership. When a user leaves (or is removed from) your Telegram channel, their Jellyfin account is disabled. When they rejoin, it is re-enabled. All state is tracked in a local SQLite database.
This is useful for communities that distribute Jellyfin access through a private Telegram channel -- the channel becomes the single source of truth for who should have access.
python:3.13-slim, with only two runtime dependencies (telethon, requests).api_id and api_hash from my.telegram.org.-1001234567890) that serves as your access list.Create a docker-compose.yml:
services:
jellytelegram-sync:
image: drumsergio/jellytelegram-sync:0.0.10
container_name: jellytelegram-sync
environment:
- TELEGRAM_API_ID=your_telegram_api_id
- TELEGRAM_API_HASH=your_telegram_api_hash
- TELEGRAM_CHANNEL=-1001234567890
- THRESHOLD_ENTRIES=100
- JELLYFIN_URL=http://your_jellyfin_url:8096
- JELLYFIN_API_KEY=your_jellyfin_api_key
- SCRIPT_INTERVAL=3600
volumes:
- ./data:/app/data
restart: unless-stopped
docker compose up -d
| Variable | Required | Default | Description |
|---|---|---|---|
TELEGRAM_API_ID | Yes | -- | Telegram API ID from my.telegram.org |
TELEGRAM_API_HASH | Yes | -- | Telegram API hash from my.telegram.org |
TELEGRAM_CHANNEL | Yes | -- | Numeric Telegram channel ID (e.g., -1001234567890) |
THRESHOLD_ENTRIES | Yes | -- | Minimum number of members expected. If fewer are returned, the sync cycle is skipped to prevent accidental mass-disabling. Set this to a value safely below your actual member count. |
JELLYFIN_URL | Yes | -- | Base URL of your Jellyfin server (e.g., http://jellyfin:8096) |
JELLYFIN_API_KEY | Yes | -- | Jellyfin API key |
SCRIPT_INTERVAL | No | 3600 | Seconds between sync cycles |
The container expects a bind-mounted volume at /app/data containing two files:
jellyfin_users.db)Create the database and populate it with your user mappings:
sqlite3 data/jellyfin_users.db <<'SQL'
CREATE TABLE IF NOT EXISTS users (
ID TEXT,
JellyfinUser TEXT PRIMARY KEY,
Enabled INTEGER DEFAULT 1
);
SQL
Insert your users. The ID column holds one or more Telegram user IDs (space-separated if multiple):
sqlite3 data/jellyfin_users.db "INSERT INTO users (ID, JellyfinUser, Enabled) VALUES ('123456789', 'alice', 1);"
sqlite3 data/jellyfin_users.db "INSERT INTO users (ID, JellyfinUser, Enabled) VALUES ('987654321 111222333', 'bob', 1);"
The second example shows a user (bob) mapped to two Telegram accounts.
session_name.session)Generate the Telethon session file by running an interactive authentication once:
docker run -it --rm \
-e TELEGRAM_API_ID=your_api_id \
-e TELEGRAM_API_HASH=your_api_hash \
-e TELEGRAM_CHANNEL=0 \
-e THRESHOLD_ENTRIES=0 \
-e JELLYFIN_URL=http://localhost \
-e JELLYFIN_API_KEY=dummy \
-v ./data:/app/data \
drumsergio/jellytelegram-sync:0.0.10 \
python -c "
from telethon.sync import TelegramClient
client = TelegramClient('/app/data/session_name', $(echo $TELEGRAM_API_ID), '$(echo $TELEGRAM_API_HASH)')
client.start()
print('Session created successfully.')
client.disconnect()
"
Follow the prompts to enter your phone number and verification code. The session file will be saved to your data/ directory.
Each sync cycle follows this sequence:
THRESHOLD_ENTRIES, the cycle is aborted as a safety measure.SCRIPT_INTERVAL seconds before repeating.| Problem | Cause | Solution |
|---|---|---|
Telegram client is not authorized | Missing or expired session file | Re-generate the session file (see above) |
| All users disabled at once | THRESHOLD_ENTRIES set too low, or Telegram API returned partial results | Increase the threshold to a safe value below your actual member count |
| User not being synced | Telegram ID not in the database | Check logs for "Unrecognized Telegram users" and add the mapping |
User 'X' has no Telegram IDs in DB | Empty ID field in the database row | Update the row: UPDATE users SET ID = 'telegram_id' WHERE JellyfinUser = 'X'; |
| Jellyfin API errors (401/403) | Invalid or expired API key | Regenerate the API key in Jellyfin admin panel |
root user not appearing | Filtered out by design | The root admin account is always excluded from sync |
This project is licensed under the GNU Lesser General Public License v2.1.
Content type
Image
Digest
sha256:e75cfcb2e…
Size
50 MB
Last updated
about 2 months ago
docker pull drumsergio/jellyfin-telegram-channel-sync