|
@@ -26,6 +26,8 @@ def main(apiArg, recordArg):
|
|
global isRecording
|
|
global isRecording
|
|
global currentDate
|
|
global currentDate
|
|
global currentTime
|
|
global currentTime
|
|
|
|
+ global broadcast
|
|
|
|
+ global mpd_url
|
|
currentTime = str(int(time.time()))
|
|
currentTime = str(int(time.time()))
|
|
currentDate = time.strftime("%Y%m%d")
|
|
currentDate = time.strftime("%Y%m%d")
|
|
isRecording = False
|
|
isRecording = False
|
|
@@ -36,8 +38,7 @@ def main(apiArg, recordArg):
|
|
def recordStream(broadcast):
|
|
def recordStream(broadcast):
|
|
try:
|
|
try:
|
|
def check_status():
|
|
def check_status():
|
|
- heartbeat_info = api.broadcast_heartbeat_and_viewercount(broadcast['id'])
|
|
|
|
- cLogger.log('[I] Broadcast status: %s' % heartbeat_info['broadcast_status'], "GREEN")
|
|
|
|
|
|
+ printStatus()
|
|
return heartbeat_info['broadcast_status'] not in ['active', 'interrupted']
|
|
return heartbeat_info['broadcast_status'] not in ['active', 'interrupted']
|
|
|
|
|
|
mpd_url = (broadcast.get('dash_manifest')
|
|
mpd_url = (broadcast.get('dash_manifest')
|
|
@@ -71,10 +72,9 @@ def recordStream(broadcast):
|
|
last_stream.write('<b>Username:</b> {}<br><b>MPD URL:</b> <a href="{}">LINK</a><br><b>Viewers:</b> {}<br><b>Missing:</b> {}'
|
|
last_stream.write('<b>Username:</b> {}<br><b>MPD URL:</b> <a href="{}">LINK</a><br><b>Viewers:</b> {}<br><b>Missing:</b> {}'
|
|
.format(record, mpd_url, str(int(viewers)), started_label))
|
|
.format(record, mpd_url, str(int(viewers)), started_label))
|
|
last_stream.close()
|
|
last_stream.close()
|
|
- cLogger.log('[I] Username : ' + record, "GREEN")
|
|
|
|
- cLogger.log('[I] MPD URL : ' + mpd_url, "GREEN")
|
|
|
|
- cLogger.log('[I] Viewers : ' + str(int(viewers)) + " watching", "GREEN")
|
|
|
|
- cLogger.log('[I] Missing : ' + started_label, "GREEN")
|
|
|
|
|
|
+ cLogger.log('[I] Username : ' + record, "GREEN")
|
|
|
|
+ cLogger.log('[I] MPD URL : ' + mpd_url, "GREEN")
|
|
|
|
+ printStatus(api, broadcast)
|
|
cLogger.log('[I] Recording broadcast...', "GREEN")
|
|
cLogger.log('[I] Recording broadcast...', "GREEN")
|
|
dl.run()
|
|
dl.run()
|
|
stitchVideo(dl, broadcast)
|
|
stitchVideo(dl, broadcast)
|
|
@@ -121,4 +121,16 @@ def getBroadcast(user_id):
|
|
if (e.__name__ is not NoBroadcastException):
|
|
if (e.__name__ is not NoBroadcastException):
|
|
cLogger.log('[E] Could not get broadcast info: ' + str(e), "RED")
|
|
cLogger.log('[E] Could not get broadcast info: ' + str(e), "RED")
|
|
cLogger.seperator("GREEN")
|
|
cLogger.seperator("GREEN")
|
|
- sys.exit(0)
|
|
|
|
|
|
+ sys.exit(0)
|
|
|
|
+
|
|
|
|
+def printStatus(api, broadcast):
|
|
|
|
+ heartbeat_info = api.broadcast_heartbeat_and_viewercount(broadcast['id'])
|
|
|
|
+ viewers = broadcast.get('viewer_count', 0)
|
|
|
|
+ started_mins, started_secs = divmod((int(time.time()) - broadcast['published_time']), 60)
|
|
|
|
+ started_label = '%d minutes and ' % started_mins
|
|
|
|
+ if started_secs:
|
|
|
|
+ started_label += '%d seconds' % started_secs
|
|
|
|
+ cLogger.log('[I] Viewers : ' + str(int(viewers)) + " watching", "GREEN")
|
|
|
|
+ cLogger.log('[I] Airing time : ' + started_label, "GREEN")
|
|
|
|
+ cLogger.log('[I] Status : ' + heartbeat_info['broadcast_status'].title(), "GREEN")
|
|
|
|
+ cLogger.log('', "GREEN")
|