Metadata-Version: 2.1
Name: castbot
Version: 1.4.0
Summary: A Telegram Bot to stream contents (Telegram videos, Youtube videos and more) to your smart TV
Author: Zhongke Chen
Author-email: github@ch3n2k.com
Requires-Python: >=3.8,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: aiohttp (>=3.8,<4.0)
Requires-Dist: aiosignal (>=1.3,<2.0)
Requires-Dist: async-lru (>=2.0,<3.0)
Requires-Dist: async-timeout (>=4.0,<5.0)
Requires-Dist: async-upnp-client (>=0.36,<0.37)
Requires-Dist: attrs (>=23.1,<24.0)
Requires-Dist: casttube (==0.2.1)
Requires-Dist: catt (>=0.12.11,<0.13.0)
Requires-Dist: certifi (>=2023.7,<2024.0)
Requires-Dist: charset-normalizer (>=3.2,<4.0)
Requires-Dist: defusedxml (==0.7.1)
Requires-Dist: frozenlist (>=1.4,<2.0)
Requires-Dist: idna (>=3.4,<4.0)
Requires-Dist: ifaddr (==0.2.0)
Requires-Dist: multidict (>=6.0,<7.0)
Requires-Dist: protobuf (>=4.24,<5.0)
Requires-Dist: pyaes (==1.6.1)
Requires-Dist: pychromecast (>=13.0,<14.0)
Requires-Dist: pyrogram (>=2.0,<3.0)
Requires-Dist: pysocks (==1.7.1)
Requires-Dist: python-didl-lite (==1.3.2)
Requires-Dist: requests (>=2.31,<3.0)
Requires-Dist: tgcrypto (>=1.2,<2.0)
Requires-Dist: toml (>=0.10,<0.11) ; python_version < "3.11"
Requires-Dist: urllib3 (>=2.0,<3.0)
Requires-Dist: voluptuous (==0.13.1)
Requires-Dist: yarl (>=1.9,<2.0)
Requires-Dist: you-get (>=0.4,<0.5)
Requires-Dist: yt-dlp (>=2023.10.7,<2024.0.0)
Requires-Dist: zeroconf (>=0.115,<0.116)
Description-Content-Type: text/markdown

# CastBot

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

[![flake8](https://github.com/zhongkechen/castbot/actions/workflows/flake8.yml/badge.svg)](https://github.com/zhongkechen/castbot/actions/workflows/flake8.yml)

### Demonstration video
[![poc](https://i.ibb.co/ct8Qb3z/Screenshot-20200827-200637.png)](https://player.vimeo.com/video/452289383)


## 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](https://developers.google.com/cast/docs/media#video_codecs)
- Most LG TVs with WebOS have an incorrect UPnP implementation

## How-to setup (Release from pypi)
Make sure you have an updated version of python, only the latest version will be supported

- Install Poetry if it's not installed yet
- Clone the repository
- Install python dependencies
- Copy config.ini.example to config.ini
- Edit config.ini
- Start from python entrypoint

```bash
# install poetry
curl -sSL https://install.python-poetry.org | python3 -

git clone https://github.com/zhongkechen/castbot
cd castbot
poetry install
cp config.toml.example config.toml
nano config.toml
poetry run castbot -c config.toml -v 1
```

## How-to setup (Docker)
- Copy config.ini.example to config.ini
- Edit config.ini
- Build Docker image
- Start Docker container

```bash
cp config.toml.example config.toml
nano config.toml
docker image build -t castbot:latest .
docker run --network host -v "$(pwd)/config.toml:/app/config.toml:ro" -d castbot:latest
```

## FAQ

**Q:** How do I use the web interface?

**A:** Set `enabled` to `1` in `web_ui` config block, and change the `password`

- open http://`listen_ip`:`listen_port`/static/index.html

- now if you send a video in the bot on telegram you can choose to play it in the browser

##
**Q:** My Firewall block upnp and broadcasting, how can use kodi without it

**A:** Set `xbmc_enabled` to `1` and add your kodi device to `xbmc_devices` list

##
**Q:** What is the format of `xbmc_devices`

**A:** A List of Python Dict with `host`, `port`, (and optional: `username` and `password`)

**example:** `[{"host": "192.168.1.2", "port": 8080, "username": "pippo", "password": "pluto"}]`

##
**Q:** How-To control vlc from this bot

**A:** set `vlc_enabled` to `1` and add your vlc device to `vlc_devices` list

##
**Q:** What is the format of `vlc_devices`

**A:** A List of Python Dict with `host`, `port`, (and optional: `password`)

**example:** `[{"host": "127.0.0.1", "port": 4212, "password": "123"}]`


##
**Q:** How-To enable upnp on my device that use kodi

**A:** follow [this guide](https://kodi.wiki/view/Settings/Services/UPnP_DLNA) (you should enable remote control)

##
**Q:** How do I get a token?

**A:** From [@BotFather](https://telegram.me/BotFather)
##
**Q:** How do I set up admins?

**A:** You have to enter your user_id, there are many ways to get it, the easiest is to use [@getuseridbot](https://telegram.me/getuseridbot)
##
**Q:** How do I get an app_id and app_hash?

**A:** https://core.telegram.org/api/obtaining_api_id#obtaining-api-id
##
**Q:** The video keeps freezing

**A:** Check the video bitrate, this bot supports maximum ~4.5Mb/s

