|
@@ -275,8 +275,8 @@ class deviceStatus(TemplateView):
|
|
|
play_url = "http://rtsp.zositech.org:10008/api/v1/players"
|
|
|
push_url = "http://rtsp.zositech.org:10008/api/v1/pushers"
|
|
|
try:
|
|
|
- queryPlay = requests.get(url=play_url, timeout=5)
|
|
|
- qplay = queryPlay.json()
|
|
|
+ # queryPlay = requests.get(url=play_url, timeout=5)
|
|
|
+ # qplay = queryPlay.json()
|
|
|
|
|
|
queryPush = requests.get(url=push_url, timeout=5)
|
|
|
qpush = queryPush.json()
|
|
@@ -285,10 +285,10 @@ class deviceStatus(TemplateView):
|
|
|
else:
|
|
|
# response.json(103, res=list(qplay))
|
|
|
#正在拉流的ID
|
|
|
- play_rows = qplay['rows']
|
|
|
- play_paths = []
|
|
|
- for val in play_rows:
|
|
|
- play_paths.append(val['path'])
|
|
|
+ # play_rows = qplay['rows']
|
|
|
+ # play_paths = []
|
|
|
+ # for val in play_rows:
|
|
|
+ # play_paths.append(val['path'])
|
|
|
|
|
|
#正在推流的ID
|
|
|
push_rows = qpush['rows']
|
|
@@ -296,22 +296,32 @@ class deviceStatus(TemplateView):
|
|
|
for val in push_rows:
|
|
|
startAt = self.str_to_timestamp(val['startAt'])
|
|
|
run_time = int(time.time()) - int(startAt)
|
|
|
- if run_time > 5*60:
|
|
|
+ if run_time > 1*60:
|
|
|
push_paths.append(val['path'])
|
|
|
send_flag = False
|
|
|
#正在推流但是没有拉流的推流通知设备断掉
|
|
|
+ # for push_path in push_paths:
|
|
|
+ # if push_path not in play_paths:
|
|
|
+ # path_list = push_path.split('/')
|
|
|
+ # has_rtsp_url = UidRtspModel.objects.filter(rtsp_url=path_list[-1]).values('uid','password')
|
|
|
+ # # has_rtsp_url = UidRtspModel.objects.filter(rtsp_url='RFJrWk9OVVJPUVRnM1IxaFNXazFFUXpFeE1VRT1U').values('uid')
|
|
|
+ # if has_rtsp_url.exists():
|
|
|
+ # send_flag = self.runSendStop(has_rtsp_url[0]['uid'], has_rtsp_url[0]['password'], push_path)
|
|
|
+ # if send_flag:
|
|
|
+ # return JsonResponse({'res':'success'})
|
|
|
+ # else:
|
|
|
+ # return JsonResponse({'res':'fail'})
|
|
|
+
|
|
|
+ success = 0
|
|
|
for push_path in push_paths:
|
|
|
- if push_path not in play_paths:
|
|
|
- path_list = push_path.split('/')
|
|
|
- has_rtsp_url = UidRtspModel.objects.filter(rtsp_url=path_list[-1]).values('uid','password')
|
|
|
- # has_rtsp_url = UidRtspModel.objects.filter(rtsp_url='RFJrWk9OVVJPUVRnM1IxaFNXazFFUXpFeE1VRT1U').values('uid')
|
|
|
- if has_rtsp_url.exists():
|
|
|
- send_flag = self.runSendStop(has_rtsp_url[0]['uid'], has_rtsp_url[0]['password'], push_path)
|
|
|
- if send_flag:
|
|
|
- return JsonResponse({'res':'success'})
|
|
|
- else:
|
|
|
- return JsonResponse({'res':'fail'})
|
|
|
-
|
|
|
+ path_list = push_path.split('/')
|
|
|
+ has_rtsp_url = UidRtspModel.objects.filter(rtsp_url=path_list[-1]).values('uid','password')
|
|
|
+ # has_rtsp_url = UidRtspModel.objects.filter(rtsp_url='RFJrWk9OVVJPUVRnM1IxaFNXazFFUXpFeE1VRT1U').values('uid')
|
|
|
+ if has_rtsp_url.exists():
|
|
|
+ send_flag = self.runSendStop(has_rtsp_url[0]['uid'], has_rtsp_url[0]['password'], push_path)
|
|
|
+ if send_flag:
|
|
|
+ success += 1
|
|
|
+ return JsonResponse({'successStopNum': success})
|
|
|
|
|
|
#把格式化时间转换成时间戳
|
|
|
def str_to_timestamp(self, str_time=None, format='%Y-%m-%d %H:%M:%S'):
|
|
@@ -340,7 +350,7 @@ class deviceStatus(TemplateView):
|
|
|
# print('command=>{command}'.format(command=command))
|
|
|
command_url = "http://47.115.134.251/index.php?command={command}".format(command=command)
|
|
|
try:
|
|
|
- exec_res = requests.get(url=command_url, timeout=2)
|
|
|
+ exec_res = requests.get(url=command_url, timeout=5)
|
|
|
res = exec_res.json()
|
|
|
if res['code'] == 200:
|
|
|
return True
|