Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: andrew-ld/smart-tv-telegram
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.1.1-dev1
Choose a base ref
...
head repository: andrew-ld/smart-tv-telegram
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length=140
68 changes: 68 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
# ******** NOTE ********

name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '42 8 * * 5'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
46 changes: 46 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Docker multi-arch build and push

on: [push, release]

jobs:
build:
name: Build Docker image (linux/386, linux/amd64, linux/arm/v6, linux/arm/v7, linux/arm64, linux/ppc64le)
runs-on: ubuntu-latest
env:
DH_IMAGE_TAG: ${{ secrets.DOCKERHUB_USERNAME }}/smart-tv-telegram

steps:
- name: Checkout current repo
uses: actions/checkout@v2
with:
submodules: "recursive"

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: |
${{ env.DH_IMAGE_TAG }}
tag-sha: true

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/386, linux/amd64, linux/arm/v6, linux/arm/v7, linux/arm64, linux/ppc64le
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
25 changes: 25 additions & 0 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "flake8"

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install -r requirements.txt
- name: Analysing the code with flake8
run: |
flake8 smart_tv_telegram/
shell: bash
25 changes: 25 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "pylint"

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
pip install -r requirements.txt
- name: Analysing the code with pylint
run: |
pylint $(find smart_tv_telegram/ -name "*.py" -type f | grep -v "test_" | xargs -n1)
shell: bash
29 changes: 29 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}

run: |
python setup.py sdist bdist_wheel
twine upload dist/*
31 changes: 31 additions & 0 deletions .github/workflows/setuptools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "setuptools"

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.8, 3.9]

steps:
- name: Initialize pythom
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Checkout repository
uses: actions/checkout@v2

- name: build and install wheel package
run: |
pip install wheel
python setup.py sdist bdist_wheel
find dist -name "*.whl" -type f -exec pip install {} \;
shell: bash
18 changes: 18 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[FORMAT]
expected-line-ending-format=LF
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
indent-after-paren=4
indent-string=' '
max-line-length=120

[DESIGN]
max-attributes=30
min-public-methods=0
max-locals=30
max-statements=100
max-branches=100
max-returns=15
max-public-methods=25

[MESSAGES CONTROL]
disable=missing-function-docstring,missing-module-docstring,invalid-overridden-method,cyclic-import,missing-class-docstring,super-init-not-called,broad-except,protected-access,duplicate-code,consider-using-with
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3
FROM python:3.10

ENV PYTHONUNBUFFERED=1

@@ -14,8 +14,6 @@ WORKDIR /app

RUN rm -rf /tmp/setup

COPY healthcheck.py /

HEALTHCHECK CMD ["/healthcheck.py", "/app/config.ini"]
HEALTHCHECK CMD ["smart_tv_telegram", "--healthcheck"]

CMD ["smart_tv_telegram"]
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include smart_tv_telegram/static/*
42 changes: 34 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# smart-tv-telegram [![PyPI](https://img.shields.io/pypi/v/smart-tv-telegram)](https://pypi.org/project/smart-tv-telegram/) [![PyPI - License](https://img.shields.io/pypi/l/smart-tv-telegram)](https://github.com/andrew-ld/smart-tv-telegram/blob/master/LICENSE) [![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/andrewhyphenld/smart-tv-telegram)](https://hub.docker.com/r/andrewhyphenld/smart-tv-telegram)
# smart-tv-telegram [![PyPI](https://img.shields.io/pypi/v/smart-tv-telegram)](https://pypi.org/project/smart-tv-telegram/) [![PyPI - License](https://img.shields.io/pypi/l/smart-tv-telegram)](https://github.com/andrew-ld/smart-tv-telegram/blob/master/LICENSE) [Docker](https://hub.docker.com/r/andrewhyphenld/smart-tv-telegram)
A Telegram Bot to stream content on your smart TV (also Chromecast, FireTV and other UPnP device)

### Demonstration video
@@ -8,27 +8,44 @@ A Telegram Bot to stream content on your smart TV (also Chromecast, FireTV and o
## Feature
- Streaming, the bot will not have to download the entire file before playing it on your device
- You can play anything if your device has the right codec
- You can streaming on any device that supports UPnP (AVTransport)
- You can stream on any device that supports UPnP (AVTransport)
- Chromecast, Vlc (telnet api) and Kodi (xbmc http api) support
- Streaming over HTTP
- Web interface that plays videos in your browser

Note: Chromecast (1st, 2nd and 3rd Gen.) [only supports H.264 and VP8 video codecs](https://developers.google.com/cast/docs/media#video_codecs)

Note: Most LG TVs with WebOS have an incorrect UPnP implementation, throw it in the trash and buy a new TV
Note: Most LG TVs with WebOS have an incorrect UPnP implementation

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

(currently it also works on Python 3.6)
- Install smart-tv-telegram from pip
- Download config.ini.example as config.ini
- Edit config.ini
- Start from python entrypoint

```bash
python3 -m pip install --upgrade smart-tv-telegram
curl https://raw.githubusercontent.com/andrew-ld/smart-tv-telegram/master/config.ini.example -o config.ini
nano config.ini
smart_tv_telegram -c config.ini -v 1
```

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

- Download the repository
- Install python dependencies from requirements.txt
- Build wheel package
- Install package
- Copy config.ini.example to config.ini
- Edit config.ini
- Start from python entrypoint

```bash
git clone https://github.com/andrew-ld/smart-tv-telegram
cd smart-tv-telegram
python3 -m pip install wheel
python3 setup.py sdist bdist_wheel
python3 -m pip install dist/*.whl
cp config.ini.example config.ini
@@ -39,8 +56,8 @@ smart_tv_telegram -c config.ini -v 1
## How-to setup (Docker)
- Copy config.ini.example to config.ini
- Edit config.ini
- Build Docker
- Start Docker
- Build Docker image
- Start Docker container

```bash
cp config.ini.example config.ini
@@ -51,6 +68,15 @@ docker run --network host -v "$(pwd)/config.ini:/app/config.ini:ro" -d smart-tv-

## Troubleshooting

**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
29 changes: 17 additions & 12 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# Security Policy
# Reporting Security Issues
If you believe you have found a security vulnerability, please report it to us through coordinated disclosure.

## Supported Versions
Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.

| Version | Supported |
| ------- | ------------------ |
| latest commit | :white_check_mark: |
| any other version | :x: |
Instead, please send an email to andrew-ld@protonmail.com

## Well-known bugs
- we know the files are being transmitted via http, we're highly screwed since the tvs don't support https.
- there is no token to request the files: and after so much they can do mitm (read the point above)
- docker only goes if I use the host network, tell the pychromecast people how to do it without it, and I do it.
Please include as much of the information listed below as you can to help us better understand and resolve the issue:

## How to contact me
on github somewhere you can click to contact me, but I don't give money anyway so don't bust my balls.
The type of issue
Full paths of source file(s) related to the manifestation of the issue
The location of the affected source code (tag/branch/commit or direct URL)
Any special configuration required to reproduce the issue
Step-by-step instructions to reproduce the issue
Proof-of-concept or exploit code (if possible)
Impact of the issue, including how an attacker might exploit the issue

This information will help us triage your report more quickly.

# Well-known weakness
- Media are transmitted via http by design, as many devices lack support for https
Loading