Sign inSign up

birdxs/teleplay

By birdxs

•Updated about 2 months ago

Image
0

2.6K

birdxs/teleplay repository overview

ā šŸ“ŗ TelePlay

Your personal, self-hosted media server — powered by Telegram.

TelePlay Banner

Stream and manage your Telegram files on any device — TV, Mobile, or Browser — without downloading the entire file. TelePlay uses Telegram as unlimited cloud storage and streams content on-demand at high speed using its multi-client parallel download technology. Upload via a Telegram Bot, organize through a Web App, and watch anywhere.

License Python FastAPI React Kotlin


⁠✨ Features

ā šŸ¤– Telegram Bot — Full Command List⁠
  • Upload any file type (video, audio, documents, photos)
  • Organize files into folders with inline buttons
  • Rename, move, and delete files via chat commands
  • Search your library with /myfiles
  • Get an auto-login web link with /web
⁠🌐 Web App — Login Methods⁠
  • Full file browser with folder navigation
  • Multi-select, batch delete, rename, and move operations
  • Context menu (right-click) on files
  • Inline video/audio player with seeking
  • Three login methods (direct link, login code, remote authorization⁠)
  • Responsive — works on desktop and mobile
ā šŸ“ŗ Android TV & Mobile App — Installation Guide⁠
  • Designed for TV with D-Pad / remote control navigation
  • Continue Watching and Recently Added rows on the home screen
  • Full-screen ExoPlayer playback with transport controls
  • Download files for offline playback (Mobile)
  • Picture-in-Picture mode (Mobile)
  • Watch progress automatically synced with the server
⁠⚔ Platform — Architecture Overview⁠

ā šŸ—ļø How It Works

  You                Telegram Cloud              Your Server              Your Devices
  ───                ──────────────              ───────────              ────────────
   │                                                  │
   │  1. Send file to Bot ──────────────────────────► │
   │                         2. Bot forwards to  ───► │ (Private Channel)
   │                            Storage Channel       │
   │                                                  │ 3. Saves metadata
   │                                                  │    to Database
   │                                                  │
   │  4. Open Web / TV App ◄──────────────────────────│
   │                                                  │
   │  5. Press Play ──────────────────────────────► │
   │                         6. Fetches chunks   ◄──  │ (from Telegram)
   │  7. Streams to you ◄────────────────────────── │
   │                                                  │

Your files are never stored on your server — TelePlay streams them directly from Telegram's cloud on demand.


ā šŸ“ø Screenshots

⁠🌐 Web Interface

ā šŸ“ŗ Android TV

ā šŸ“± Mobile App


⁠� Quick Start

⁠Prerequisites — Detailed Steps⁠
RequirementHow to get it
Telegram Bot TokenCreate via @BotFather⁠
API ID & HashRegister at my.telegram.org⁠
Storage ChannelCreate a private channel, add your bot as admin
DockerInstall Docker⁠
⁠1. Clone & Configure
git clone https://github.com/yourusername/teleplay.git
cd teleplay
cp .env.example .env

Edit .env with your credentials:

TELEGRAM_API_ID=12345678
TELEGRAM_API_HASH=abcdef1234567890abcdef1234567890
TELEGRAM_BOT_TOKEN=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
TELEGRAM_STORAGE_CHANNEL_ID=-100xxxxxxxxxx
JWT_SECRET=your-super-secret-key-at-least-32-characters

# Use PostgreSQL (recommended) or SQLite (no setup needed):
DATABASE_URL=sqlite:///./data/teleplay.db
# DATABASE_URL=postgresql://postgres:password@db:5432/teleplay
⁠2. Deploy
docker compose up -d

That's it! Your services are now running:

⁠3. Start Using
  1. Open Telegram and send a video file to your bot.
  2. Send /web to get a link to your Web App.
  3. Stream your files! šŸŽ¬

For detailed setup, usage, and login instructions, see the Setup & Usage Guide⁠.

For VPS, Railway, Render, and CapRover deployments, see the Deployment Guide⁠.


ā šŸ“± Android TV & Mobile App

Download the APK from the Releases⁠ page:

APKBest For
arm64-v8aModern TV boxes, phones, NVIDIA Shield
universalAny device (if unsure, use this one)

Setup:

  1. Install the APK on your device.
  2. Enter your Server URL (e.g., http://192.168.1.100).
  3. A 6-digit code will appear — send /login CODE to your bot.
  4. Done! Browse and stream your library.

For APK signing and release automation, see the Releasing Guide⁠.


ā āš™ļø Environment Variables

VariableRequiredDescription
TELEGRAM_API_IDāœ…From my.telegram.org⁠
TELEGRAM_API_HASHāœ…From my.telegram.org⁠
TELEGRAM_BOT_TOKENāœ…From @BotFather⁠
TELEGRAM_STORAGE_CHANNEL_IDāœ…Private channel ID (starts with -100)
JWT_SECRETāœ…Secret key for JWT signing (min 32 chars)
DATABASE_URLāœ…Database connection URL (see below)
WEB_BASE_URLāŒPublic URL of the web app
TELEGRAM_HELPER_BOT_TOKENSāŒExtra bot tokens for parallel downloads⁠
AUTH_USERSāŒComma-separated Telegram IDs for restricted access

šŸ’” DATABASE_URL Options:

  • PostgreSQL (recommended): postgresql://postgres:password@localhost:5432/teleplay
  • SQLite (no setup needed): sqlite:///./data/teleplay.db

Use SQLite if you don't want to set up PostgreSQL — it works out of the box for small deployments.


ā šŸ› ļø Tech Stack

LayerTechnology
BackendPython 3.11+, FastAPI, Uvicorn
TelegramPyroTGFork (MTProto)
DatabasePostgreSQL (prod) / SQLite (dev), SQLAlchemy 2.0
AuthJWT (Access + Refresh Tokens)
WebReact 18, TypeScript, Vite
AndroidKotlin, Jetpack Compose for TV, ExoPlayer
DeployDocker, Docker Compose, Nginx

ā šŸ“ Project Structure — Full Breakdown⁠

teleplay/
ā”œā”€ā”€ backend/                  # Python backend (FastAPI + Bot)
│   ā”œā”€ā”€ app/
│   │   ā”œā”€ā”€ routers/          # API endpoints (auth, files, folders, streaming, tv)
│   │   ā”œā”€ā”€ bot.py            # Telegram bot command handlers
│   │   ā”œā”€ā”€ streaming.py      # Multi-client parallel streaming engine
│   │   ā”œā”€ā”€ models.py         # SQLAlchemy ORM models
│   │   └── main.py           # FastAPI app entry point
│   ā”œā”€ā”€ Dockerfile
│   └── requirements.txt
ā”œā”€ā”€ web/                      # React web interface
│   ā”œā”€ā”€ src/
│   │   ā”œā”€ā”€ components/       # UI components
│   │   ā”œā”€ā”€ lib/api.ts        # API client & hooks
│   │   └── App.tsx           # Main app with routing
│   └── Dockerfile
ā”œā”€ā”€ android/                  # Android TV & Mobile app
│   └── app/src/main/java/    # Kotlin (Compose + ExoPlayer)
ā”œā”€ā”€ docs/                     # Documentation
│   ā”œā”€ā”€ ARCHITECTURE.md       # Technical deep-dive
│   ā”œā”€ā”€ DEPLOYMENT.md         # Deployment guide
│   ā”œā”€ā”€ SETUP.md              # Setup & usage guide
│   └── RELEASING.md          # APK release process
ā”œā”€ā”€ docker-compose.yml
└── .env.example

ā šŸ”§ Development

⁠Backend
cd backend
python -m venv venv
venv\Scripts\activate        # Linux/Mac: source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env         # Edit with your credentials
uvicorn app.main:app --reload
⁠Web App
cd web
npm install
npm run dev
⁠Android

Open the android/ folder in Android Studio and build.


ā šŸ”’ Security — Details⁠

  • JWT Authentication — Short-lived access tokens with refresh token rotation⁠
  • User Authorization — Optional AUTH_USERS⁠ whitelist
  • Rate Limiting — SlowAPI middleware on all endpoints
  • CORS Protection — Restricted to configured origins
  • Input Validation — Pydantic schemas prevent injection attacks
  • Security Headers — Standard headers on all responses

ā šŸ“š Documentation

GuideDescription
Setup & Usage⁠How the app works, bot commands, login methods, and troubleshooting
Deployment⁠Docker, VPS, Railway, Render, and CapRover deployment
Architecture⁠Technical deep-dive: streaming engine, API endpoints, database models
Releasing⁠APK build automation and signing via GitHub Actions

ā šŸ¤ Contributing

Contributions are welcome! Please see CONTRIBUTING.md⁠ for guidelines.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

ā šŸ“„ License

This project is licensed under the MIT License — see the LICENSE⁠ file for details.

ā šŸ™ Acknowledgments

Tag summary

Content type

Image

Digest

sha256:f3ef64cdd…

Size

25.1 MB

Last updated

about 2 months ago

docker pull birdxs/teleplay:web-latest