chenjunkai 6 years ago
parent
commit
3d40883db7
1 changed files with 10 additions and 9 deletions
  1. 10 9
      Controller/DetectController.py

+ 10 - 9
Controller/DetectController.py

@@ -105,15 +105,16 @@ class DetectControllerView(View):
                 # 列表装载回放时间戳标记
                 vodqs = VodHlsModel.objects.filter(uid=uid, channel=p['Channel'], time=eventTime) \
                     .values("bucket__bucket", "bucket__endpoint")
-                bucket_name = vodqs[0]['bucket__bucket']
-                endpoint = vodqs[0]['bucket__endpoint']
-                bucket = oss2.Bucket(auth, endpoint, bucket_name)
-                ts = '{uid}/vod{channel}/{etime}/ts0.ts'.format(uid=devUid, channel=p['Channel'], etime=eventTime)
-                thumb0 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_0000,w_700'})
-                thumb1 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_1000,w_700'})
-                thumb2 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_2000,w_700'})
-                thumb3 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_3000,w_700'})
-                p['gif'] = [thumb0, thumb1, thumb2, thumb3]
+                if vodqs.exists():
+                    bucket_name = vodqs[0]['bucket__bucket']
+                    endpoint = vodqs[0]['bucket__endpoint']
+                    bucket = oss2.Bucket(auth, endpoint, bucket_name)
+                    ts = '{uid}/vod{channel}/{etime}/ts0.ts'.format(uid=devUid, channel=p['Channel'], etime=eventTime)
+                    thumb0 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_0000,w_700'})
+                    thumb1 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_1000,w_700'})
+                    thumb2 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_2000,w_700'})
+                    thumb3 = bucket.sign_url('GET', ts, 3600, params={'x-oss-process': 'video/snapshot,t_3000,w_700'})
+                    p['gif'] = [thumb0, thumb1, thumb2, thumb3]
             if devUid in uid_type_dict.keys():
                 p['uid_type'] = uid_type_dict[devUid]
             else: