diff --git a/README.md b/README.md index a8c3385..c3dc443 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Multi channel stream setup with Flask REST API for scheduling channels. 5. Run the stack using `docker-compose up -d --build --remove-orphans` 6. Issue a certificate: -`source variables.env; docker exec acme.sh --issue -d $BASE_URL -d $SCHEDULER_API_HOSTNAME -d $CORE_API_HOSTNAME --stateless` +`source variables.env; docker exec acme.sh --issue -d $BASE_URL d $CORE_HOSTNAME --stateless` 7. Install the certificate: `source variables.env; docker exec acme.sh --install-cert -d $BASE_URL --reloadcmd "cat \$CERT_KEY_PATH \$CERT_FULLCHAIN_PATH > /certificates/$BASE_URL.pem" diff --git a/config/haproxy/haproxy.cfg b/config/haproxy/haproxy.cfg index 45f5dcf..37582db 100644 --- a/config/haproxy/haproxy.cfg +++ b/config/haproxy/haproxy.cfg @@ -57,12 +57,10 @@ frontend web # Router # ACL to match the sni hosts acl is_base ssl_fc_sni -i "${BASE_URL}" - acl is_api ssl_fc_sni -i "api.${BASE_URL}" acl is_stream ssl_fc_sni -i "stream.${BASE_URL}" # Define the ACL conditions and corresponding actions use_backend backend_api if is_base - use_backend backend_api if is_api use_backend backend_restreamer if is_stream backend backend_api diff --git a/src/api/api.py b/src/api/api.py index 4703c07..b39e39f 100644 --- a/src/api/api.py +++ b/src/api/api.py @@ -25,11 +25,10 @@ logger_job.setLevel(log_level) logger_content = logging.getLogger('content') # Variables -scheduler_hostname = os.environ.get('SCHEDULER_API_HOSTNAME', 'api.example.com') core_sync_period = int(os.environ.get('CORE_SYNC_PERIOD', 15)) -api_hostname = os.environ.get('CORE_API_HOSTNAME', 'stream.example.com') -api_username = os.environ.get('CORE_API_AUTH_USERNAME', 'admin') -api_password = os.environ.get('CORE_API_AUTH_PASSWORD', 'pass') +core_hostname = os.environ.get('CORE_HOSTNAME', 'stream.example.com') +core_username = os.environ.get('CORE_USERNAME', 'admin') +core_password = os.environ.get('CORE_PASSWORD', 'pass') rec_path = "/recordings" enable_delay = 24 @@ -161,7 +160,6 @@ def update_playhead(stream_id, stream_name, stream_prio, stream_hls_url): # Execute stream def exec_stream(stream_id, stream_name, stream_prio, stream_hls_url): global prio - logger_job.warning(f'Hello {stream_name}! :]') if stream_prio > prio: prio = stream_prio logger_job.warning(f'Source priority is now set to: {prio}') @@ -278,7 +276,7 @@ def core_api_sync(): stream_name = meta['restreamer-ui']['meta']['name'] stream_description = meta['restreamer-ui']['meta']['description'] stream_storage_type = meta['restreamer-ui']['control']['hls']['storage'] - stream_hls_url = f'https://{api_hostname}/{stream_storage_type}/{stream_id}.m3u8' + stream_hls_url = f'https://{core_hostname}/{stream_storage_type}/{stream_id}.m3u8' if state.exec == "running": process_running_channel(database, scheduler, stream_id, stream_name, stream_description, stream_hls_url) @@ -295,8 +293,8 @@ def core_api_sync(): # Datarhei CORE API login try: - client = Client(base_url='https://' + api_hostname, username=api_username, password=api_password) - logger_api.warning('Logging in to Datarhei Core API ' + api_username + '@' + api_hostname) + client = Client(base_url='https://' + core_hostname, username=core_username, password=core_password) + logger_api.warning('Logging in to Datarhei Core API ' + core_username + '@' + core_hostname) client.login() except Exception as err: logger_api.error('Client login error') @@ -330,12 +328,6 @@ def root_route(): return render_template('index.html', now=datetime.utcnow(), video_files=video_files, thumbnails=sorted_thumbnails) # API -@app.route('/about', methods=['GET']) -def about_route(): - about_json = { 'about': 'DeflaxTV API' } - return jsonify(about_json) - -# JSON data @app.route('/playhead', methods=['GET']) def playhead_route(): global playhead diff --git a/src/api/templates/index.html b/src/api/templates/index.html index c666a7d..7fcde55 100644 --- a/src/api/templates/index.html +++ b/src/api/templates/index.html @@ -71,7 +71,7 @@ document.addEventListener('DOMContentLoaded', () => { const video = document.querySelector("video"); const source = 'https://stream.deflax.net/memfs/f2844c7c-e86c-4f0a-afb6-a1b0e25a5071.m3u8'; - const playhead_url = "https://api.deflax.net/playhead"; + const playhead_url = "https://deflax.net/playhead"; // For more options, see: https://github.com/sampotts/plyr/#options // captions.update is required for captions to work with hls.js diff --git a/variables.env.dist b/variables.env.dist index 5c7c3c8..d3ddb60 100644 --- a/variables.env.dist +++ b/variables.env.dist @@ -1,11 +1,10 @@ BASE_URL=example.com EMAIL=info@example.com CORE_LOG_LEVEL=warn -CORE_API_HOSTNAME=stream.example.com -CORE_API_AUTH_USERNAME=admin -CORE_API_AUTH_PASSWORD=changeme +CORE_HOSTNAME=stream.example.com +CORE_USERNAME=admin +CORE_PASSWORD=changeme SCHEDULER_LOG_LEVEL=warn -SCHEDULER_API_HOSTNAME=api.example.com DISCORDBOT_TOKEN=changeme DISCORDBOT_LIVE_CHANNEL_ID=0 DISCORDBOT_LIVE_CHANNEL_UPDATE=1440