Skip to content

Commit

Permalink
Merge pull request #18 from l3uddz/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
desimaniac authored Jan 22, 2019
2 parents 59730bd + 59503ef commit 73a69e4
Showing 1 changed file with 35 additions and 24 deletions.
59 changes: 35 additions & 24 deletions patrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,45 @@ def add_stream_ip(user, ip):

def kill_paused_stream(stream, check_again_mins, kick_reason):
log.info("%s will have their stream killed in %d mins, unless it is resumed", stream.user, check_again_mins)
time.sleep(60 * check_again_mins)
current_streams = server.get_streams()
if current_streams is None:
log.error(
"Unable to check if %s stream is still paused because there was an error retrieving the active streams...",
stream.user)
watchlist.remove(stream.session_id)
return
#Tracker for total time spent paused
totalTimePaused = 0
while(1):
streamFound = False
current_streams = server.get_streams()
if current_streams is None:
log.error(
"Unable to check if %s stream is still paused because there was an error retrieving the active streams...",
stream.user)
watchlist.remove(stream.session_id)
return

for current_stream in current_streams:
if current_stream.session_id == stream.session_id:
if current_stream.state == 'paused':
if server.kill_stream(stream.session_id, kick_reason):
log.info("Kicked %s because their stream was still paused %d minutes later", stream.user,
check_again_mins)
watchlist.remove(stream.session_id)
return
for current_stream in current_streams:
if current_stream.session_id == stream.session_id:
streamFound = True
if current_stream.state == 'paused':
#Increment total pause time by check interval and proceed to see if u
totalTimePaused += config.CHECK_INTERVAL
if(totalTimePaused >= (check_again_mins * 60)):
if server.kill_stream(stream.session_id, kick_reason):
log.info("Kicked %s because their stream was still paused %d minutes later", stream.user,
check_again_mins)
watchlist.remove(stream.session_id)
return
else:
log.error("Unable to kick the stream of %s, not sure why...", stream.user)
watchlist.remove(stream.session_id)
return
else:
time.sleep(config.CHECK_INTERVAL)
break
else:
log.error("Unable to kick the stream of %s, not sure why...", stream.user)
log.info("%s stream was resumed, so we wont kill their stream, they're in the clear!", stream.user)
watchlist.remove(stream.session_id)
return
else:
log.info("%s stream was resumed, so we wont kill their stream, they're in the clear!", stream.user)
watchlist.remove(stream.session_id)
return
log.info("%s is no longer streaming...", stream.user)
watchlist.remove(stream.session_id)

if streamFound == False:
log.info("%s is no longer streaming...", stream.user)
watchlist.remove(stream.session_id)
return

def should_kick_stream(stream):
# is stream using a blacklisted client
Expand Down

0 comments on commit 73a69e4

Please sign in to comment.