Skip to content

Commit

Permalink
Add more details to the cams.m3u8 endpoint
Browse files Browse the repository at this point in the history
Adds program guide details and thumbnails for better rendering in clients.
Implements #1414
  • Loading branch information
IDisposable committed Feb 12, 2025
1 parent bf89374 commit 0a8d80f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import time
from functools import wraps
from pathlib import Path
from urllib.parse import quote_plus
from urllib.parse import quote_plus, urlparse

from flask import (
Flask,
Expand All @@ -17,6 +17,7 @@
from wyze_bridge import WyzeBridge
from wyzebridge import config, web_ui
from wyzebridge.auth import WbAuth
from wyzebridge.bridge_utils import env_bool
from wyzebridge.web_ui import url_for


Expand Down Expand Up @@ -249,7 +250,8 @@ def iptv_playlist():
Generate an m3u8 playlist with all enabled cameras.
"""
cameras = web_ui.format_streams(wb.streams.get_all_cam_info())
resp = make_response(render_template("m3u8.html", cameras=cameras))
hostname = env_bool("DOMAIN", urlparse(request.root_url).hostname or "localhost")
resp = make_response(render_template("m3u8.html", cameras=cameras, hostname=hostname))
resp.headers.set("content-type", "application/x-mpegURL")
return resp

Expand Down
2 changes: 1 addition & 1 deletion app/templates/m3u8.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#EXTM3U
{% for name,camera in cameras.items() %}{% if camera.enabled %}
#EXTINF:-1 channel-id="{{name}}" tvc-guide-genres="{{camera.product_model}}", {{name}}
#EXTINF:-1 channel-id="{{name}}" tvc-guide-genres="{{camera.product_model}}, {{camera.model_name}}" tvc-guide-tags="Cam, Live" tvc-guide-title="{{camera.nickname}}" tvc-guide-description=="Live {{camera.nickname}}" tvc-guide-art="{{hostname}}:5000/{{camera.img_url}}", {{name}}
{{ camera.hls_url }}stream.m3u8
{% endif %}{% endfor %}

0 comments on commit 0a8d80f

Please sign in to comment.