From f7f07a26880ed8a909f226a13535d267284b9b78 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Sat, 26 Oct 2019 07:15:37 -0700 Subject: [PATCH] Add /defaults to thrimshim, use it to populate config stuff in thrimbletrimmer Thrimbletrimmer needs to know stuff like the bustime start time, default channel, even if it's not looking at a specific row. --- thrimbletrimmer/index.html | 4 ++-- thrimbletrimmer/scripts/IO.js | 15 ++++++++++++--- thrimshim/thrimshim/main.py | 13 +++++++++++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/thrimbletrimmer/index.html b/thrimbletrimmer/index.html index 33d1700..cd5a2d6 100644 --- a/thrimbletrimmer/index.html +++ b/thrimbletrimmer/index.html @@ -41,8 +41,8 @@ - - + + diff --git a/thrimbletrimmer/scripts/IO.js b/thrimbletrimmer/scripts/IO.js index 5d6d848..5b8a07a 100644 --- a/thrimbletrimmer/scripts/IO.js +++ b/thrimbletrimmer/scripts/IO.js @@ -41,9 +41,18 @@ pageSetup = function() { else { document.getElementById('SubmitButton').disabled = true; - var startOfHour = new Date(new Date().setMinutes(0,0,0)); - document.getElementById("StreamStart").value = new Date(startOfHour.getTime() - 1000*60*60).toISOString().substring(0,19); - document.getElementById("StreamEnd").value = startOfHour.toISOString().substring(0,19); + fetch("/thrimshim/defaults").then(data => data.json()).then(function (data) { + desertBusStart = new Date(data.bustime_start); + document.getElementById("VideoTitlePrefix").value = data.title_prefix; + document.getElementById("VideoTitle").setAttribute("maxlength", data.title_max_length); + document.getElementById("StreamName").value = data.video_channel; + setOptions('uploadLocation', data.upload_locations); + + // Default time range to the last 10min. This is useful for giffers, immediate replay, etc. + document.getElementById("StreamStart").value = new Date(new Date().getTime() - 1000*60*10).toISOString().substring(0,19); + document.getElementById("StreamEnd").value = new Date().toISOString().substring(0,19); + setBustimeRange(); + }); loadPlaylist(); } diff --git a/thrimshim/thrimshim/main.py b/thrimshim/thrimshim/main.py index 4e69860..cca218b 100644 --- a/thrimshim/thrimshim/main.py +++ b/thrimshim/thrimshim/main.py @@ -120,6 +120,19 @@ def get_all_rows(): return json.dumps(rows) +@app.route('/thrimshim/defaults') +@request_stats +def get_defaults(): + """Get default info needed by thrimbletrimmer when not loading a specific row.""" + return json.dumps({ + "video_channel": app.default_channel, + "bustime_start": app.bustime_start, + "title_prefix": app.title_header, + "title_max_length": MAX_TITLE_LENGTH - len(app.title_header), + "upload_locations": app.upload_locations, + }) + + @app.route('/thrimshim/', methods=['GET']) @request_stats def get_row(ident):