diff --git a/docker-compose.jsonnet b/docker-compose.jsonnet index f07e38e..94c5ce0 100644 --- a/docker-compose.jsonnet +++ b/docker-compose.jsonnet @@ -92,6 +92,8 @@ dbname: "wubloader", }, + condor_db:: "mysql://necrobot-read:necrobot-read@condor.live/condor_x2", + // Other database arguments db_super_user:: "postgres", // only accessible from localhost db_super_password:: "postgres", // Must not contain ' or \ as these are not escaped. @@ -216,7 +218,9 @@ command: [ "--base-dir", "/mnt", "--backdoor-port", std.toString($.backdoor_port), - ], + ] + (if $.condor_db == null then [] else [ + "--condor-db", $.condor_db, + ]), environment: $.env, }, diff --git a/downloader/downloader/main.py b/downloader/downloader/main.py index 62eda2c..8dd668c 100644 --- a/downloader/downloader/main.py +++ b/downloader/downloader/main.py @@ -10,6 +10,7 @@ import time import uuid from base64 import b64encode from contextlib import contextmanager +from urlparse import urlparse import argh import gevent @@ -595,11 +596,11 @@ class SegmentGetter(object): "Twitch channels to watch. Add a '!' suffix to indicate they're expected to be always up. " "This affects retry interval, error reporting and monitoring." ) -@argh.arg('--league-db', default="necrobot-read:necrobot-read@condor.live/condor_x2", help= +@argh.arg('--condor-db', default="mysql://necrobot-read:necrobot-read@condor.live/condor_x2", help= "Connection string for database to check for racers and commentators. " - "Should be of form USER:PASSWORD@HOST/DATABASE.", + "Should be of form mysql://USER:PASSWORD@HOST/DATABASE.", ) -def main(channels, base_dir=".", qualities="source", metrics_port=8001, backdoor_port=0, league_db=None): +def main(channels, base_dir=".", qualities="source", metrics_port=8001, backdoor_port=0, condor_db=None): qualities = qualities.split(",") if qualities else [] managers = {} @@ -620,10 +621,12 @@ def main(channels, base_dir=".", qualities="source", metrics_port=8001, backdoor if backdoor_port: gevent.backdoor.BackdoorServer(('127.0.0.1', backdoor_port), locals=locals()).start() - if league_db: - user, rest = league_db.split(':', 1) - password, rest = rest.split('@', 1) - host, db = rest.split('/', 1) + if condor_db: + db_args = urlparse(condor_db) + user = db_args.username + password = db_args.password + host = db_args.hostname + db = db_args.path.lstrip('/') prev_check = 0 CHECK_INTERVAL = 60 @@ -632,7 +635,7 @@ def main(channels, base_dir=".", qualities="source", metrics_port=8001, backdoor for channel in managers.keys(): logging.info("Stopping channel {} for shutdown".format(channel)) managers.pop(channel).stop() - elif league_db and time.time() - prev_check > CHECK_INTERVAL: + elif condor_db and time.time() - prev_check > CHECK_INTERVAL: logging.info("Checking for new racers") prev_check = time.time() try: diff --git a/downloader/setup.py b/downloader/setup.py index e527e23..470053d 100644 --- a/downloader/setup.py +++ b/downloader/setup.py @@ -9,7 +9,7 @@ setup( "python-dateutil", "gevent", "monotonic", - "mysql-connector-python", + "mysql-connector-python==8.0.5", # old version for py2 compat "prometheus-client==0.7.1", # locked version as we rely on internals "requests", "wubloader-common", diff --git a/restreamer/restreamer/main.py b/restreamer/restreamer/main.py index 2d56a16..707d301 100644 --- a/restreamer/restreamer/main.py +++ b/restreamer/restreamer/main.py @@ -369,7 +369,7 @@ def review_race(match_id, race_number): if app.condor_db is None: return "Reviews are disabled", 501 start_range = map(float, request.args.get('start_range', '0,5').split(',')) - finish_range = map(float, request.args.get('finish_range', '0,5').split(',')) + finish_range = map(float, request.args.get('finish_range', '-5,10').split(',')) try: review_path = review(match_id, race_number, app.static_folder, app.condor_db, start_range, finish_range) except RaceNotFound as e: diff --git a/restreamer/restreamer/review.py b/restreamer/restreamer/review.py index 559c38d..638bd43 100644 --- a/restreamer/restreamer/review.py +++ b/restreamer/restreamer/review.py @@ -104,7 +104,7 @@ def review(match_id, race_number, base_dir, db_url, start_range=(0, 5), finish_r ] if not data: - raise RaceNotFound("Could not find race number {} of match {}".format(match_id, race_number)) + raise RaceNotFound("Could not find race number {} of match {}".format(race_number, match_id)) assert len(data) == 1, repr(data) (racer1, racer2, start, duration), = data @@ -112,7 +112,9 @@ def review(match_id, race_number, base_dir, db_url, start_range=(0, 5), finish_r output_name = "{}-{}-{}-{}".format(match_id, racer1, racer2, race_number) output_dir = os.path.join(base_dir, "reviews", output_name) - result_name = "review.{}.{}.mp4".format(*finish_range) + if not os.path.exists(output_dir): + os.makedirs(output_dir) + result_name = "review_{}_{}.mp4".format(*finish_range) result_path = os.path.join(output_dir, result_name) if os.path.exists(result_path): logger.info("Result already exists for {}, reusing".format(result_path)) diff --git a/restreamer/setup.py b/restreamer/setup.py index 9770ac9..529132a 100644 --- a/restreamer/setup.py +++ b/restreamer/setup.py @@ -10,6 +10,7 @@ setup( "flask", "gevent", "monotonic", + "mysql-connector-python==8.0.5", # old version for py2 compat "prometheus-client", "wubloader-common", ],