GramStream is an Android app (phone and Android TV) that turns your Telegram channels into a Stremio addon that runs on your own device. You log in with your Telegram account, pick the channels that hold your videos, and the app runs a small HTTP server that Stremio can install from a manifest link. Videos stream directly from Telegram and support seeking. You don't need a VPS or a PC.
To use it outside your home network, the app has a built-in Cloudflare
Tunnel that gives you a public https://….trycloudflare.com URL with one tap.
The Home tab shows:
- the logged-in Telegram account
- the server switch and background-execution status
- the Cloudflare Tunnel button
- the addon manifest URL with a QR code to scan from Stremio
- buttons to copy the link and clear the catalog cache
- On first launch you enter your own API ID / API Hash from
my.telegram.org. They are stored on the device,
never hard-coded (
ApiCredentialsActivity.kt). - Phone number → login code → 2FA password, driven by TDLib's auth state
machine (
LoginActivity.kt,TdLibManager.kt). - When you're already logged in, the app goes straight to the main screen.
-
An embedded NanoHTTPD server (
AddonServer.kt) runs inside a foreground service (AddonForegroundService.kt) on port 11470 by default. The port can be changed. -
Endpoints:
Path Purpose /manifest.jsonAddon manifest (catalog, stream, meta; id prefixes tg_,tgz:,tt)/catalog/movie/latest[/search=…].json"Telegram" catalog: latest videos, with search and paging /meta/movie/<id>.jsonMetadata, enriched with TMDB when a key is set /stream/movie/<id>.jsonStream links for Telegram ids and IMDb ids ( tt…)/file/<chatId>_<messageId>Streams a single video with HTTP Range support /zipfile/<chatId>/<base>Streams a video stored inside split .zip.001/.002/…archives -
CORS headers are set on every response, so Stremio Web works too.
- Lists and searches video messages in your channels through TDLib.
- Multi-channel: you add channels by numeric chat ID on the Channels tab.
- Global Search (optional): searches every chat you've joined instead of only the channels you added.
- Split
.zip.NNNvolumes are grouped into one catalog entry (ZipVolumeResolver.groupVolumes). - Posters and metadata come from TMDB when you set an API key. Enrichment runs in the background, and the catalog is cached for 15 minutes.
When Stremio asks for streams for a Cinemeta item such as
/stream/movie/tt0398286.json:
TmdbClient.findByImdbIdresolves the IMDb id to a title and year.- Query templates from
assets/remote_config.json("{title} {year}","{title}") build the Telegram search strings, which are tried in order. Fuzzy.similarity(token overlap plus Levenshtein ratio) filters the results usingtitle_threshold_fuzzy.- Each match is returned as a
/file/...or/zipfile/...stream (up tomax_streams).
- Progressive streaming with seeking (
ProgressiveFileInputStream.kt): it starts the TDLib download at the requested byte offset and serves bytes as they arrive. A seek starts a new download at the new offset. - Multi-volume zip streaming (
ZipVolumeResolver.kt,MultiVolumeProgressiveInputStream.kt):- It reads the zip local file header of volume 1 to find where the video data starts. Resolved plans are cached.
- It presents all volumes to the player as one continuous byte range.
- It prefetches the next volume once playback gets within about 8 MB of the end of the current one, so playback doesn't stall at the volume boundary.
- The
cloudflaredbinary is bundled asjniLibs/<abi>/libcloudflared.so. The.soname anduseLegacyPackaging truemake Android extract it tonativeLibraryDir, where it is allowed to run. - Tapping Start Cloudflare Tunnel on the Home tab runs
cloudflared tunnel --url http://127.0.0.1:<port>(IPv4, http2). The app reads the*.trycloudflare.comURL from its output and saves it as the public host. - While the tunnel runs, the manifest link and QR code switch to
https://<tunnel>/manifest.json, so you can install the addon from anywhere. Stopping the tunnel switches back to the LAN address. - Quick tunnels need no Cloudflare account, but the URL changes every time the tunnel starts. Reinstall the addon in Stremio after a restart.
- Server on/off switch with a status indicator.
- Manifest link with a Copy button and a QR code. When no tunnel is running, the LAN IP is detected automatically. The link and QR code refresh when the network changes, for example on a Wi-Fi ↔ mobile data handover.
- Start/stop the Cloudflare Tunnel.
- Allow running in background: asks Android to exempt the app from battery optimization (on TV this is already allowed).
- Clear the catalog cache and TDLib storage.
- Shows the Telegram account that is logged in.
- Global Search, Wi-Fi only mode and Auto-start on boot switches.
- Max cache size (MB, default 2048), buffer size (MB, default 20), server port and TMDB API key.
- In-app debug log viewer (last 500 entries) with Copy logs. Long-press the log window to open a storage diagnostics report.
- Backup settings to a JSON file (API credentials, TMDB key, channels and config). To restore it on a new install, tap Restore on the first-launch screen. That fills in your API ID/Hash and brings back your channels and config. You still log in to Telegram again, because the session isn't part of the backup.
- Log out of Telegram.
- Foreground service (
dataSync) keeps the server alive in the background. - Network awareness: the service watches the default network. In Wi-Fi only mode it stops itself when Wi-Fi is lost. Handovers are debounced, so a brief gap while switching networks doesn't stop it.
- Boot resilience (
BootReceiver.kt): when auto-start is on, the service restarts afterBOOT_COMPLETED/QUICKBOOT_POWERON. The service also starts TDLib itself on a cold start, so catalogs aren't empty after a reboot. - Storage limits: a 60-second timer plus read-based cleanup keep the TDLib cache under the configured max size.
- Leanback launcher entry and TV banner. Touchscreen is not required.
- Landscape layout on TV, portrait on phones.
- Native libraries for
arm64-v8aandarmeabi-v7a, which covers 32-bit TV boxes.
app/src/main/
├── AndroidManifest.xml
├── assets/remote_config.json # search templates, thresholds, video extensions
├── jniLibs/<abi>/libtdjni.so # TDLib native library
├── jniLibs/<abi>/libcloudflared.so # cloudflared binary (Cloudflare Tunnel)
├── java/org/drinkless/tdlib/ # TDLib Java bindings (Client, TdApi)
└── java/com/example/GramStream/
├── ApiCredentialsActivity.kt # first launch: API ID / Hash
├── LoginActivity.kt # phone / code / 2FA
├── MainActivity.kt # bottom nav host
├── HomeFragment.kt ChannelsFragment.kt ConfigFragment.kt SettingsFragment.kt
├── AddonForegroundService.kt # runs the server, network watcher, storage timer
├── AddonServer.kt # Stremio addon HTTP endpoints
├── CatalogRepository.kt # catalog / meta / stream JSON
├── TdLibManager.kt # TDLib client, auth, downloads, storage
├── ProgressiveFileInputStream.kt
├── MultiVolumeProgressiveInputStream.kt
├── ZipVolumeResolver.kt
├── CloudflaredTunnel.kt
├── TmdbClient.kt Fuzzy.kt RemoteConfig.kt
├── Settings.kt DebugLog.kt NetworkStateNotifier.kt BootReceiver.kt
└── ChannelAdapter.kt
Requirements: Android Studio, JDK 17, Android SDK 34 (minSdk 24).
- TDLib:
libtdjni.soand theorg.drinkless.tdlibJava sources are already in the repo. To rebuild them, follow BUILD_TDLIB.md. - cloudflared:
libcloudflared.sois the Linux/Androidcloudflaredbinary for each ABI (linux-arm64→arm64-v8a,linux-arm→armeabi-v7a), renamed with a.soextension. To update it, download a newer release from cloudflare/cloudflared releases and replace the files. - Open the project in Android Studio, let Gradle sync, then use Build → Build APK(s).
- Go to my.telegram.org and log in with your phone number.
- Open API development tools and create an app. Any name and short name will do.
- Copy the App api_id (a number) and the App api_hash. You enter these in GramStream on first launch.
- In Telegram, tap New Channel. A private channel is fine and recommended.
- Upload or forward your movie files to it. You can send them as a video or as a file/document; both work.
- The account you log in to GramStream with must be a member of the channel. It's easiest to log in with the account that owns it.
Naming files: GramStream reads the caption first, or the file name
if there is no caption. Everything before the year becomes the title, and the
year is the first 19xx/20xx it finds. Dots and underscores become spaces.
| Good name / caption | Parsed as |
|---|---|
Oppenheimer.2023.1080p.BluRay.x264.mkv |
Oppenheimer (2023) |
The_Dark_Knight_2008_720p.mp4 |
The Dark Knight (2008) |
Interstellar (2014) 2160p.mkv |
Interstellar (2014) |
- Always put the year right after the title. It makes TMDB and IMDb matching much more accurate.
- Big files (over 2 GB): zip and split them into parts, see Uploading big files below.
- Series aren't supported yet. Only movies are.
Telegram accepts files up to 2 GB (4 GB with Premium). For a bigger movie, put it in a zip, split the zip into parts of under 2 GB each, and upload all the parts to the same channel. GramStream joins the parts into one entry in the catalog and plays them as a single video.
-
Install 7-Zip if you don't have it.
-
Right-click the movie file → 7-Zip → Add to archive…
-
Set the options:
Option Value Archive Oppenheimer.2023.1080p.zip(the movie's name, ending in.zip)Archive format zip Compression level Store (no compression) Split to volumes, bytes 1950M -
Click OK. 7-Zip creates the parts next to the movie:
Oppenheimer.2023.1080p.zip.001 (1.9 GB) Oppenheimer.2023.1080p.zip.002 (1.9 GB) Oppenheimer.2023.1080p.zip.003 (the rest)
7z a -tzip -mx=0 -v1950m "Oppenheimer.2023.1080p.zip" "Oppenheimer.2023.1080p.mkv"-tzip makes a zip, -mx=0 is Store (no compression) and -v1950m splits
it into 1950 MB parts.
- One movie per zip.
- Store only. The zip must not be compressed.
- Part size: 1950M keeps every part safely under Telegram's 2 GB limit.
With Premium you can use up to
3900M. - Names: keep them exactly as 7-Zip made them, ending in
.zip.001,.zip.002, … (three digits). Don't rename the parts one by one, because they must all share the same base name. - Base name: use the movie's title and year, for example
Oppenheimer.2023.1080p, just like single files. The catalog title comes from part.001. - Upload every part, as a file, to the same channel.
- Captions: leave them empty, or give every part the same caption. Don't write "Part 1", "Part 2" and so on in the captions.
- Supported split format: only
.zip.001style splits are joined..z01splits (made by WinZip orzip -s), plain.mkv.001splits and "CD1 / CD2" files are not.
GramStream needs the channel's numeric ID. For channels it always starts with
-100, for example -1001234567890. Any of these four methods works.
- In Telegram, search for @getidsbot (or @userinfobot, or @RawDataBot) and tap Start.
- Open your channel, long-press any message (for example one of your movie files) and tap Forward.
- Pick the bot's chat as the destination and send.
- The bot replies with info about where the message came from. Copy the ID
shown for the origin chat / forwarded from chat:
- @getidsbot: under Origin chat →
id: -1001234567890 - @userinfobot: the line with the channel's Id
- @RawDataBot: in the JSON,
"forward_from_chat": { "id": -1001234567890, … }
- @getidsbot: under Origin chat →
- Make sure you copy the channel ID that starts with
-100, not your own user ID (a positive number).
If forwarding is blocked (the channel has Restrict saving content turned on), use Method B or C instead. The bot only reads the forwarded message's info; it doesn't need to join or be admin in your channel.
- In your channel, long-press (or right-click) any message and tap Copy Message Link.
- For a private channel you get a link like
https://t.me/c/1234567890/42. - Take the number between
/c/and the next/and put-100in front of it:1234567890→-1001234567890.
- Open web.telegram.org/a and click your channel.
- The address bar shows something like
https://web.telegram.org/a/#-1001234567890. The number after#is the ID. - If you see the
/k/version (…/k/#-1234567890) without the-100, replace the-with-100:-1234567890→-1001234567890.
- Go to Settings → Advanced → Experimental settings and turn on Show Peer IDs in Profile.
- Open the channel's info page. The ID is shown there. If it doesn't start
with
-100, add-100in front.
Do I need to create my own bot (BotFather)? No. Some Telegram-to-Stremio servers need a BotFather bot that is admin in your channels. GramStream logs in as your own Telegram account through TDLib, so it can read any channel you've joined. There's no bot token and no admin setup. The only bot you might use is a public ID bot from Method A, once, to look up the channel ID.
- Install the APK, then enter your API ID / API Hash (or tap Restore to load a backup).
- Log in with your phone number, the login code Telegram sends you, and your 2FA password if you have one.
- Channels tab: paste the
-100…channel ID and tap Add. Repeat for each channel. Or turn on Global Search in Config to search every chat you've joined. - Config tab: add a TMDB API key (free at themoviedb.org). You need it for posters and for Stremio's normal movie pages to find your files.
- Home tab: tap Allow running in background, then turn the server on.
- Same Wi-Fi: copy the
http://<phone-ip>:11470/manifest.jsonlink from the Home tab, or scan its QR code. - From anywhere: tap Start Cloudflare Tunnel, wait for the
https://….trycloudflare.comaddress, then copy that link or scan the QR code. - In Stremio, open Addons, paste the link into the search box and install.
- Your files show up in the Telegram catalog on Stremio's Discover page. When TMDB is set up, they also appear as streams on Stremio's normal movie pages.
- Only the
movietype is exposed. Series templates exist inremote_config.json, but series/episode streams aren't wired up yet. - Restore needs a system file picker. Some Android TV boxes don't have one, so on those, restore on a phone or install a file manager.
- Quick-tunnel URLs change on every start. A named Cloudflare tunnel with a fixed hostname isn't supported yet.
ZipVolumeResolverassumes a standard (non-ZIP64) local file header and a single entry per archive, i.e. one movie split and zipped for size.- If the zip used a data descriptor (compressed size unknown at write time), the entry length falls back to "everything after the header". The stream may then include a few trailing zip bytes, which most players tolerate.
- Stream responses are always sent as
video/x-matroska. - Not built yet: anime/Kitsu matching and an OTA self-updater.
GramStream is free software, licensed under the GNU General Public License v3.0 (GPL-3.0), the same license as Telegram-Stremio, which inspired it.
You may use, study, modify and share it. If you distribute a modified version or an APK built from it, you must release its source code under GPL-3.0 too, and keep the copyright and license notices.
GramStream - stream your Telegram channels to Stremio from Android
Copyright (C) 2026 GLlgGL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Bundled third-party components keep their own licenses: TDLib (Boost Software License 1.0), cloudflared (Apache 2.0), NanoHTTPD (BSD 3-Clause), ZXing (Apache 2.0) and AndroidX/Material (Apache 2.0).
- The idea and design are based on weebzone/Telegram-Stremio by Karan, a self-hosted Telegram → Stremio server (FastAPI, MongoDB, PyroFork, GPL-3.0). GramStream brings the same concept to a single Android device, with no VPS, database or bot.
- TDLib by Telegram, cloudflared by Cloudflare, NanoHTTPD, ZXing and TMDB for metadata. This product uses the TMDB API but is not endorsed or certified by TMDB.
- Stremio addon protocol.
Vibe coded by GLlgGL

