Skip to content

JohnGenri/MediaKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MediaKit Telegram Bot

Python python-telegram-bot PostgreSQL yt-dlp FFmpeg Yandex SpeechKit

MediaKit is a Telegram bot for media downloading, cached delivery, and voice/video-note transcription.

Stack and Tooling

  • Python + python-telegram-bot for Telegram polling and handlers
  • PostgreSQL (asyncpg) for request log and media cache (file_id)
  • yt-dlp + ffmpeg for download and conversion pipelines
  • Yandex SpeechKit + YandexGPT for speech-to-text and summarization
  • Local Telegram Bot API support via telegram.api_base_url

Core Features

  • Download media from:
    • YouTube, Instagram, TikTok, Reddit, PornHub, Pinterest
    • Yandex Music, Spotify, YouTube Music
  • Normalize links for stable DB cache hits
  • Reuse cached file_id when possible (faster repeat delivery)
  • Voice/video-note transcription and summary
  • Admin panel for chat list, direct message, and broadcast
  • Background cleanup for temporary files

Important: 5-Minute Update Expiration During Downtime

To prevent replay storms after restart, the bot intentionally drops stale updates.

  • drop_pending_updates=True is enabled at polling startup.
  • features.max_update_age_sec is set to 300 (5 minutes).

What this means:

  • If the bot is down and a message waits too long (older than 5 minutes), that update can be skipped after restart.
  • This is by design to avoid repeated old downloads/transcriptions.
  • Users can resend links/messages if they were sent during downtime and got skipped.

This is update-age logic, not content deduplication by text.

Configuration

Main config file: important/config.json

  • telegram: token, admin ID, API base URL, request timeouts
  • database: PostgreSQL connection settings
  • network: proxies, cookies, and headers
  • integrations: RapidAPI, Reddit, Yandex services
  • limits: upload size, concurrency, cleanup intervals
  • downloads: yt-dlp default format and socket timeout
  • messages: all user-facing status and error strings
  • features: excluded chats, exact matches, skip-conversion list, stale-update window

Current skip-conversion list:

  • YouTube
  • TikTok
  • PornHub
  • Pinterest

Installation

  1. Clone repository:
git clone https://github.com/JohnGenri/MediaKit.git
cd MediaKit
  1. Install dependencies to system Python:
python3 -m pip install --break-system-packages --ignore-installed -r requirements.txt
  1. Prepare runtime files:
cp download_instagram.sh.example download_instagram.sh
chmod +x download_instagram.sh
cp important/config.json.example important/config.json
  1. Fill important/config.json with valid credentials and tokens.

systemd Service Example

[Unit]
Description=MediaKit Telegram Bot
After=network.target

[Service]
User=root
Group=root
WorkingDirectory=/root/BOTS/MediaKit
Environment=PYTHONDONTWRITEBYTECODE=1
ExecStart=/usr/bin/python3 /root/BOTS/MediaKit/MediaKit.py
Restart=always
RestartSec=5s

[Install]
WantedBy=multi-user.target

Useful commands:

systemctl daemon-reload
systemctl enable mediakit.service
systemctl restart mediakit.service
systemctl status mediakit.service
journalctl -u mediakit -f

About

Telegram seamless media downloading with advanced AI-powered voice processing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors