Added a report of all current tuuube streams
This commit is contained in:
parent
9151ddce42
commit
bed92bf0af
@ -173,6 +173,16 @@ def radio_info(radio):
|
||||
# Youtube shit
|
||||
tubes = {}
|
||||
|
||||
@app.route('/tuuube/report')
|
||||
def tuuube_report():
|
||||
"""List the tuuube streams opened and their streaming status.
|
||||
---
|
||||
responses:
|
||||
200:
|
||||
description: JSON
|
||||
"""
|
||||
return jsonify({id:{'active':tube.is_streaming(),'playing':tube.is_playing()} for id,tube in tubes.items()})
|
||||
|
||||
@app.route('/tuuube/<id>/start')
|
||||
def start_tuuube_stream(id):
|
||||
"""Start streaming from a youtube source.
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
from threading import Thread
|
||||
|
||||
def is_alive(subprocess):
|
||||
return (subprocess.poll() is None)
|
||||
return True if (subprocess and subprocess.poll() is None) else False
|
||||
|
||||
class Streamer:
|
||||
def __init__(self):
|
||||
|
||||
@ -25,9 +25,12 @@ class Tuuube(Streamer):
|
||||
|
||||
def __init__(self, id):
|
||||
self.id = id
|
||||
|
||||
self.playback = None
|
||||
super().__init__()
|
||||
|
||||
def is_playing(self):
|
||||
return is_alive(self.playback)
|
||||
|
||||
def _stream_path(self):
|
||||
return f":{Tuuube.PORT}/tuuube/{self.id}"
|
||||
|
||||
@ -62,7 +65,7 @@ class Tuuube(Streamer):
|
||||
)
|
||||
|
||||
while self.run:
|
||||
if not is_alive(self.playback):
|
||||
if not self.is_playing():
|
||||
print('Playback failed, aborting stream.', file=sys.stderr)
|
||||
break
|
||||
time.sleep(0.1)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user