diff --git a/backfiller/backfiller/main.py b/backfiller/backfiller/main.py index f0ac18b..3240368 100644 --- a/backfiller/backfiller/main.py +++ b/backfiller/backfiller/main.py @@ -94,7 +94,7 @@ def list_local_segments(base_dir, channel, quality, hour, include_tombstones=Fal restreamer.list_segments but this avoids HTTP/JSON overheads.""" path = os.path.join(base_dir, channel, quality, hour) - return list_segment_files(path, include_tombstones=include_tombstones) + return list_segment_files(path, include_tombstones=include_tombstones, include_chat=True) def list_remote_hours(node, channel, quality, timeout=TIMEOUT): diff --git a/common/common/segments.py b/common/common/segments.py index 557afb1..fd4e565 100644 --- a/common/common/segments.py +++ b/common/common/segments.py @@ -224,11 +224,12 @@ def hour_paths_for_range(hours_path, start, end): current += datetime.timedelta(hours=1) -def list_segment_files(hour_path, include_tombstones=False): +def list_segment_files(hour_path, include_tombstones=False, include_chat=False): """Return a list of filenames of segments in the given hour path. Segment names are not parsed or verified, but only non-hidden .ts files without an associated tombstone file will be listed. If include_tombstones = true, the tombstone files themselves will also be listed. + If include_chat = true, .json files will also be listed. """ try: names = os.listdir(hour_path) @@ -252,7 +253,7 @@ def list_segment_files(hour_path, include_tombstones=False): segments = [ name + ext for name, ext in splits if name not in tombstones - and ext == ".ts" + and (ext == ".ts" or (include_chat and ext == ".json")) and not name.startswith('.') ] diff --git a/restreamer/restreamer/main.py b/restreamer/restreamer/main.py index 44323fd..21bccdc 100644 --- a/restreamer/restreamer/main.py +++ b/restreamer/restreamer/main.py @@ -138,7 +138,7 @@ def list_hours(channel, quality): @request_stats @has_path_args def list_segments(channel, quality, hour): - """Returns a JSON list of segment files for a given channel, quality and + """Returns a JSON list of segment or chat files for a given channel, quality and hour. Returns empty list on non-existant channels, etc. If tombstones = "true", will also list tombstone files for that hour. """ @@ -152,7 +152,7 @@ def list_segments(channel, quality, hour): if tombstones not in ["true", "false"]: return "tombstones must be one of: true, false", 400 tombstones = (tombstones == "true") - return json.dumps(list_segment_files(path, include_tombstones=tombstones)) + return json.dumps(list_segment_files(path, include_tombstones=tombstones, include_chat=True)) @app.route('/thumbnail-templates')