Have list_segment_files also list chat archives

Otherwise backfilling of chat doesn't work
pull/318/head
Mike Lang 2 years ago committed by Mike Lang
parent 3b6ce86c46
commit c493869b9a

@ -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.""" restreamer.list_segments but this avoids HTTP/JSON overheads."""
path = os.path.join(base_dir, channel, quality, hour) 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): def list_remote_hours(node, channel, quality, timeout=TIMEOUT):

@ -224,11 +224,12 @@ def hour_paths_for_range(hours_path, start, end):
current += datetime.timedelta(hours=1) 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. """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 Segment names are not parsed or verified, but only non-hidden .ts files
without an associated tombstone file will be listed. without an associated tombstone file will be listed.
If include_tombstones = true, the tombstone files themselves will also 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: try:
names = os.listdir(hour_path) names = os.listdir(hour_path)
@ -252,7 +253,7 @@ def list_segment_files(hour_path, include_tombstones=False):
segments = [ segments = [
name + ext for name, ext in splits name + ext for name, ext in splits
if name not in tombstones if name not in tombstones
and ext == ".ts" and (ext == ".ts" or (include_chat and ext == ".json"))
and not name.startswith('.') and not name.startswith('.')
] ]

@ -138,7 +138,7 @@ def list_hours(channel, quality):
@request_stats @request_stats
@has_path_args @has_path_args
def list_segments(channel, quality, hour): 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. hour. Returns empty list on non-existant channels, etc.
If tombstones = "true", will also list tombstone files for that hour. 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"]: if tombstones not in ["true", "false"]:
return "tombstones must be one of: true, false", 400 return "tombstones must be one of: true, false", 400
tombstones = (tombstones == "true") 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') @app.route('/thumbnail-templates')

Loading…
Cancel
Save