restreamer: Hack in a path to re-stream "last 20 seconds", for live 'replays'

condor-scripts
Mike Lang 6 years ago
parent a59fe25cfa
commit e789e04b27

@ -230,7 +230,28 @@ def generate_media_playlist(channel, quality):
return generate_hls.generate_media(segments, os.path.join(app.static_url_path, channel, quality))
@app.route('/cut/<channel>/<quality>.ts')
@app.route('/replay/<stream>/<variant>.m3u8')
@has_path_args
def replay(stream, variant):
hours_path = os.path.join(app.static_folder, stream, variant)
if not os.path.isdir(hours_path):
abort(404)
start = datetime.datetime.utcnow() - datetime.timedelta(seconds=20)
end = datetime.datetime.utcnow() - datetime.timedelta(seconds=5)
segments = get_best_segments(hours_path, start, end)
if segments == [None]:
print "No replay, serving placeholder"
stream, variant = 'ekimekim', 'source'
segments = get_best_segments(os.path.join(app.static_folder, stream, variant),
datetime.datetime(2019, 5, 14, 9, 58, 46),
datetime.datetime(2019, 5, 14, 9, 58, 48),
)
return generate_hls.generate_media(segments, os.path.join(app.static_url_path, stream, variant))
@app.route('/cut/<stream>/<variant>.ts')
@request_stats
@has_path_args
def cut(channel, quality):

Loading…
Cancel
Save