From 9327c98e48863dabec92b15f6a1d184e7bcfddb0 Mon Sep 17 00:00:00 2001 From: Evgeny Sorokin Date: Wed, 3 Apr 2024 05:22:52 +0300 Subject: web_kbn upd --- bin/web_kbn.py | 12 ++++++++++-- web/kbn_assets/app.js | 8 +++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bin/web_kbn.py b/bin/web_kbn.py index 48af167..bfa32f6 100755 --- a/bin/web_kbn.py +++ b/bin/web_kbn.py @@ -9,6 +9,7 @@ import re import inverterd import phonenumbers import time +import os.path from io import StringIO from aiohttp import web @@ -441,9 +442,16 @@ async def cams(req: web.Request): cams = cc.get_all_cam_names() mode = {'type': 'all'} + if req.headers.get('Host').endswith('.manor.id'): + hls_pfx = 'https://'+req.headers.get('Host') + hls_pfx += re.sub(r'/home/?$', '/ipcam/', os.path.dirname(req.headers.get('X-Real-URI'))) + else: + hls_pfx = 'http://'+config.app_config['hls_local_host']+'/ipcam/' + js_config = { - 'host': config.app_config['hls_local_host'], - 'proto': 'http', + 'pfx': hls_pfx, + # 'host': config.app_config['hls_local_host'], + # 'proto': 'http', 'cams': cams, 'hlsConfig': { 'opts': { diff --git a/web/kbn_assets/app.js b/web/kbn_assets/app.js index 9136af9..4405e8d 100644 --- a/web/kbn_assets/app.js +++ b/web/kbn_assets/app.js @@ -140,12 +140,11 @@ function indexInit() { var Cameras = { hlsOptions: null, - host: null, - proto: null, + pfx: null, hlsDebugVideoEvents: false, getUrl: function(name) { - return this.proto + '://' + this.host + '/ipcam/' + name + '/live.m3u8'; + return this.pfx + '/live.m3u8'; }, setupHls: function(video, name, useHls) { @@ -201,8 +200,7 @@ var Cameras = { }, init: function(opts) { - this.proto = opts.proto; - this.host = opts.host; + this.pfx = opts.pfx; this.hlsOptions = opts.hlsConfig; var useHls; -- cgit v1.2.3