|
@@ -368,35 +368,23 @@ class DetectControllerViewV2(View):
|
|
|
if p['is_st'] == 1:
|
|
|
thumbspng = '{uid}/{channel}/{time}.jpeg'.format(uid=devUid, channel=p['Channel'], time=eventTime)
|
|
|
if storage_location == 1: # oss
|
|
|
- is_exist = oss_img_bucket.object_exists(thumbspng)
|
|
|
- if is_exist:
|
|
|
- response_url = oss_img_bucket.sign_url('GET', thumbspng, 300)
|
|
|
- p['img'] = response_url
|
|
|
- p['img_list'] = [response_url]
|
|
|
- else:
|
|
|
- continue
|
|
|
+ response_url = oss_img_bucket.sign_url('GET', thumbspng, 300)
|
|
|
+ p['img'] = response_url
|
|
|
+ p['img_list'] = [response_url]
|
|
|
elif region == 2 and storage_location == 2: # 2:国内,aws
|
|
|
- try:
|
|
|
- aws_s3_guonei.get_object(Bucket='push', Key=thumbspng)
|
|
|
- response_url = aws_s3_guonei.generate_presigned_url('get_object',
|
|
|
- Params={'Bucket': 'push',
|
|
|
- 'Key': thumbspng},
|
|
|
- ExpiresIn=300)
|
|
|
- p['img'] = response_url
|
|
|
- p['img_list'] = [response_url]
|
|
|
- except aws_s3_guonei.exceptions.NoSuchKey:
|
|
|
- continue
|
|
|
+ response_url = aws_s3_guonei.generate_presigned_url('get_object',
|
|
|
+ Params={'Bucket': 'push',
|
|
|
+ 'Key': thumbspng},
|
|
|
+ ExpiresIn=300)
|
|
|
+ p['img'] = response_url
|
|
|
+ p['img_list'] = [response_url]
|
|
|
elif region == 1 and storage_location == 2: # 1:国外,aws
|
|
|
- try:
|
|
|
- aws_s3_guowai.get_object(Bucket='foreignpush', Key=thumbspng)
|
|
|
- response_url = aws_s3_guowai.generate_presigned_url('get_object',
|
|
|
- Params={'Bucket': 'foreignpush',
|
|
|
- 'Key': thumbspng},
|
|
|
- ExpiresIn=300)
|
|
|
- p['img'] = response_url
|
|
|
- p['img_list'] = [response_url]
|
|
|
- except aws_s3_guowai.exceptions.NoSuchKey:
|
|
|
- continue
|
|
|
+ response_url = aws_s3_guowai.generate_presigned_url('get_object',
|
|
|
+ Params={'Bucket': 'foreignpush',
|
|
|
+ 'Key': thumbspng},
|
|
|
+ ExpiresIn=300)
|
|
|
+ p['img'] = response_url
|
|
|
+ p['img_list'] = [response_url]
|
|
|
elif p['is_st'] == 2:
|
|
|
# 列表装载回放时间戳标记
|
|
|
split_vod_hls_obj = SplitVodHlsObject()
|
|
@@ -413,36 +401,24 @@ class DetectControllerViewV2(View):
|
|
|
ts = '{uid}/vod{channel}/{etime}/ts0.ts'.format(uid=devUid, channel=p['Channel'],
|
|
|
etime=eventTime)
|
|
|
if storage_location == 1: # oss
|
|
|
- is_exist = bucket.object_exists(ts)
|
|
|
- if is_exist:
|
|
|
- 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['img_list'] = [thumb0, thumb1, thumb2]
|
|
|
- else:
|
|
|
- continue
|
|
|
+ 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['img_list'] = [thumb0, thumb1, thumb2]
|
|
|
elif region == 2 and storage_location == 2: # 2:国内,aws
|
|
|
- try:
|
|
|
- aws_s3_guonei.get_object(Bucket='push', Key=ts)
|
|
|
- thumb = aws_s3_guonei.generate_presigned_url('get_object',
|
|
|
- Params={'Bucket': 'push', 'Key': ts},
|
|
|
- ExpiresIn=3600)
|
|
|
- p['img_list'] = [thumb]
|
|
|
- except aws_s3_guonei.exceptions.NoSuchKey:
|
|
|
- continue
|
|
|
+ thumb = aws_s3_guonei.generate_presigned_url('get_object',
|
|
|
+ Params={'Bucket': 'push', 'Key': ts},
|
|
|
+ ExpiresIn=3600)
|
|
|
+ p['img_list'] = [thumb]
|
|
|
elif region == 1 and storage_location == 2: # 1:国外,aws
|
|
|
- try:
|
|
|
- aws_s3_guowai.get_object(Bucket='foreignpush', Key=ts)
|
|
|
- thumb = aws_s3_guowai.generate_presigned_url('get_object',
|
|
|
- Params={'Bucket': 'foreignpush', 'Key': ts},
|
|
|
- ExpiresIn=3600)
|
|
|
- p['img_list'] = [thumb]
|
|
|
- except aws_s3_guowai.exceptions.NoSuchKey:
|
|
|
- continue
|
|
|
+ thumb = aws_s3_guowai.generate_presigned_url('get_object',
|
|
|
+ Params={'Bucket': 'foreignpush', 'Key': ts},
|
|
|
+ ExpiresIn=3600)
|
|
|
+ p['img_list'] = [thumb]
|
|
|
elif p['is_st'] == 3 or p['is_st'] == 4:
|
|
|
# 列表装载回放时间戳标记
|
|
|
p['img_list'] = []
|
|
@@ -450,36 +426,23 @@ class DetectControllerViewV2(View):
|
|
|
thumbspng = '{uid}/{channel}/{time}_{st}.jpeg'.format(uid=devUid, channel=p['Channel'],
|
|
|
time=eventTime, st=i)
|
|
|
if storage_location == 1: # oss
|
|
|
- is_exist = oss_img_bucket.object_exists(thumbspng)
|
|
|
- if is_exist:
|
|
|
- img = oss_img_bucket.sign_url('GET', thumbspng, 300)
|
|
|
- p['img_list'].append(img)
|
|
|
- else:
|
|
|
- break
|
|
|
+ img = oss_img_bucket.sign_url('GET', thumbspng, 300)
|
|
|
+ p['img_list'].append(img)
|
|
|
elif region == 2 and storage_location == 2: # 2:国内,aws
|
|
|
- try:
|
|
|
- aws_s3_guonei.get_object(Bucket='push', Key=thumbspng)
|
|
|
- response_url = aws_s3_guonei.generate_presigned_url('get_object',
|
|
|
- Params={'Bucket': 'push',
|
|
|
- 'Key': thumbspng},
|
|
|
- ExpiresIn=300)
|
|
|
- img = response_url
|
|
|
- p['img_list'].append(img)
|
|
|
- except aws_s3_guonei.exceptions.NoSuchKey:
|
|
|
- break
|
|
|
+ response_url = aws_s3_guonei.generate_presigned_url('get_object',
|
|
|
+ Params={'Bucket': 'push',
|
|
|
+ 'Key': thumbspng},
|
|
|
+ ExpiresIn=300)
|
|
|
+ img = response_url
|
|
|
+ p['img_list'].append(img)
|
|
|
elif region == 1 and storage_location == 2: # 1:国外,aws
|
|
|
- try:
|
|
|
- aws_s3_guowai.get_object(Bucket='foreignpush', Key=thumbspng)
|
|
|
- response_url = aws_s3_guowai.generate_presigned_url('get_object',
|
|
|
- Params={'Bucket': 'foreignpush',
|
|
|
- 'Key': thumbspng},
|
|
|
- ExpiresIn=300)
|
|
|
- img = response_url
|
|
|
- p['img_list'].append(img)
|
|
|
- except aws_s3_guowai.exceptions.NoSuchKey:
|
|
|
- break
|
|
|
- if not p['img_list']:
|
|
|
- continue
|
|
|
+ response_url = aws_s3_guowai.generate_presigned_url('get_object',
|
|
|
+ Params={'Bucket': 'foreignpush',
|
|
|
+ 'Key': thumbspng},
|
|
|
+ ExpiresIn=300)
|
|
|
+ img = response_url
|
|
|
+ p['img_list'].append(img)
|
|
|
+
|
|
|
if devUid in uid_type_dict.keys():
|
|
|
p['uid_type'] = uid_type_dict[devUid]['type']
|
|
|
p['devNickName'] = uid_type_dict[devUid]['NickName']
|