diff --git a/backfiller/backfiller/main.py b/backfiller/backfiller/main.py index 416dff1..a5e6560 100644 --- a/backfiller/backfiller/main.py +++ b/backfiller/backfiller/main.py @@ -131,9 +131,17 @@ def get_remote_segment(base_dir, node, channel, quality, hour, missing_segment, return dir_name = os.path.dirname(path) - date, duration, _ = os.path.basename(path).split('-', 2) - temp_name = "-".join([date, duration, "temp", str(uuid.uuid4())]) - temp_path = os.path.join(dir_name, "{}.ts".format(temp_name)) + if quality == "chat": + # chat segment + _, filename_hash = os.path.basename(path).split('-', 1) + temp_name = "{}.{}.temp".format(os.path.basename(path), uuid4()) + else: + # video segment + date, duration, _ = os.path.basename(path).split('-', 2) + filename_hash = common.parse_segment_path(missing_segment).hash + temp_name = "{}.ts".format("-".join([date, duration, "temp", str(uuid.uuid4())])) + + temp_path = os.path.join(dir_name, temp_name) common.ensure_directory(temp_path) hash = hashlib.sha256() @@ -149,7 +157,6 @@ def get_remote_segment(base_dir, node, channel, quality, hour, missing_segment, common.writeall(f.write, chunk) hash.update(chunk) - filename_hash = common.parse_segment_path(missing_segment).hash if filename_hash != hash.digest(): logger.warn('Hash of segment {} does not match. Discarding segment'.format(missing_segment)) hash_mismatches.labels(remote=node, channel=channel, quality=quality, hour=hour).inc() diff --git a/chat_archiver/chat_archiver/main.py b/chat_archiver/chat_archiver/main.py index 3f89345..afd7065 100644 --- a/chat_archiver/chat_archiver/main.py +++ b/chat_archiver/chat_archiver/main.py @@ -187,6 +187,7 @@ class Archiver(object): def write_batch(path, batch_time, messages): + """Batches are named PATH/YYYY-MM-DDTHH/MM:SS-HASH.json""" output = (format_batch(messages) + '\n').encode('utf-8') hash = base64.b64encode(hashlib.sha256(output).digest(), b"-_").decode().rstrip("=") hour = datetime.utcfromtimestamp(batch_time).strftime("%Y-%m-%dT%H") diff --git a/restreamer/restreamer/main.py b/restreamer/restreamer/main.py index a481f69..ee45ea5 100644 --- a/restreamer/restreamer/main.py +++ b/restreamer/restreamer/main.py @@ -181,6 +181,9 @@ def generate_master_playlist(channel): playlists = {} for quality in qualities: + # "chat" is text only, not an actual video quality + if quality == "chat": + continue # If start or end are given, try to restrict offered qualities to ones which exist for that # time range. if start is not None or end is not None: