-
Notifications
You must be signed in to change notification settings - Fork 556
Source Echo examples
Alex X edited this page Sep 14, 2022
·
5 revisions
Docker and Hass Add-on users has preinstalled python3
without any additional libraries, like requests or others. If you need some additional libraries - you need to install them to folder with your script:
- Install SSH & Web Terminal
- Goto Add-on Web UI
- Install library:
pip install requests -t /config/echo
- Add your script to
/config/echo/myscript.py
- Use your script as source
echo:python3 /config/echo/myscript.py
streams:
apple_hls: echo:python3 hls.py https://developer.apple.com/streaming/examples/basic-stream-osx-ios5.html
hls.py
import re
import sys
from urllib.parse import urljoin
from urllib.request import urlopen
html = urlopen(sys.argv[1]).read().decode("utf-8")
url = re.search(r"https.+?m3u8", html)[0]
html = urlopen(url).read().decode("utf-8")
m = re.search(r"^[a-z0-1/_]+\.m3u8$", html, flags=re.MULTILINE)
url = urljoin(url, m[0])
# ffmpeg:https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear1/prog_index.m3u8#video=copy
print("ffmpeg:" + url + "#video=copy")