Skip to main content

A Telegram Bot to stream contents (Telegram videos, Youtube videos and more) to your smart TV

Project description

CastBot

A Telegram Bot to stream contents (Telegram videos, Youtube videos and more) to your smart TV

Flake8 Pylint PyPI Docker Image on Github Docker Image on DockerHub

Demonstration video

poc

Feature

  • Stream Telegram videos to any device that supports UPnP (AVTransport), Chromecast, Vlc (telnet api), Kodi (xbmc http api)
  • Web interface that plays videos in your browser
  • Download videos by URLs and stream to devices

Known issues

  • Chromecast (1st, 2nd and 3rd Gen.) only supports H.264 and VP8 video codecs
  • Most LG TVs with WebOS have an incorrect UPnP implementation
  • This bot supports videos of ~4.5Mb/s bit rate at maximum. The videos of higher bit rate would keep freezing.

How to run castbot with pip

Create a configuration file config.toml and then run the following command

pip install castbot
castbot -c config.toml -v 1

Note: Make sure you have a version of Python 3.8+

How to run castbot with Docker

Create a configuration file config.toml and then run the following command

docker run --network host -v "$(pwd)/config.toml:/app/config.toml:ro" -d ghcr.io/zhongkechen/castbot:master

How to config

Create a file config.toml with the following content

# Use yt-dlp or you-get to download Youtube videos
downloader = "yt-dlp"

[bot]

# `api_id` and `api_hash` can be generated here: https://core.telegram.org/api/obtaining_api_id
api_id=652324
api_hash="eb06d4abfb49dc3eeb1aeb9f581e"

# `token` can be created from https://telegram.me/BotFather
token="xxxxxxxxx"

# `session_name` can be an arbitary string.
session_name="castbot"

# Only users in this `admins` list can use this bot. 
# Your own user id can be found here https://telegram.me/getuseridbot
admins=[337885031,32432424,44353421]

[http]

# The IP address or the hostname of the host running castbot
listen_host = "192.168.1.2"

# An arbitary port that is not in use
listen_port = 8350


# The following devices sections are optional. Add the sections you need.

[[devices]]
# When this section is added, all the UPNP devices in the local network will be auto-discovered.
# For Kodi, UPNP must be enabled in Settings -> Services -> UPNP/DLNA
# https://kodi.wiki/view/Settings/Services/UPnP_DLNA
type="upnp"

[[devices]]
# When this section is added, all the ChromeCast devices in the local network will be auto-discovered.
type="chromecast"

[[devices]]
# When this section is added, open http://`listen_host`:`listen_port`/static/index.html in a browser.
# Now if you send a video to the bot, you can choose to play it in the browser
type="web"
password="changeit"

[[devices]]
# When this section is added, we can play video on a device running VLC.
# VLC Telnet interface must be enabled.
type="vlc"
host = "127.0.0.1"
port = 4212
password = "123"

[[devices]]
# When UPNP is blocked by firewall, we can use this section to connect to Kodi.
# Remote Control of Kodi must be enabled: Settings -> Services -> Control.
# https://kodi.wiki/view/Settings/Services/Control
type="xbmc"
host = "192.168.42.140"
port = 8080
username = ""
password = ""

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

castbot-1.4.1.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

castbot-1.4.1-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file castbot-1.4.1.tar.gz.

File metadata

  • Download URL: castbot-1.4.1.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for castbot-1.4.1.tar.gz
Algorithm Hash digest
SHA256 9a2b50c53a68d49002fd131f9f04d9619ede518fa4c01ab7f3d459645e8f8e92
MD5 9128ca2814139c24373a09be19d3a5de
BLAKE2b-256 9bf096ab2561b4bbfebdf6657753ddd2fbb0bedefaa21cc2376283737c1e8b48

See more details on using hashes here.

File details

Details for the file castbot-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: castbot-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for castbot-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d7213915be95931c4b057d5449808b9548ccb92daaff1a5cec5296f845423b5
MD5 3aae3534f77a1671fe8f2d4544b83bb1
BLAKE2b-256 f8cfc4852225b1e58f33c75b5fdfcf59263a08afb8bb915b2e4fd018e9a50b0f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page