|
@@ -294,11 +294,13 @@ class DetectControllerViewV2(View):
|
|
|
if not qs.exists():
|
|
|
return response.json(0, {'datas': [], 'count': 0})
|
|
|
qs = qs.values('id', 'devUid', 'devNickName', 'Channel', 'eventType', 'status', 'alarm', 'eventTime',
|
|
|
- 'receiveTime', 'is_st', 'addTime')
|
|
|
+ 'receiveTime', 'is_st', 'addTime', 'storage_location')
|
|
|
|
|
|
count = qs.count()
|
|
|
qr = qs[(page - 1) * line:page * line]
|
|
|
res = []
|
|
|
+ auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
|
+ oss_img_bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
|
|
|
aws_s3_guonei = boto3.client(
|
|
|
's3',
|
|
|
aws_access_key_id=AWS_ACCESS_KEY_ID[0],
|
|
@@ -318,18 +320,23 @@ class DetectControllerViewV2(View):
|
|
|
devUid = p['devUid']
|
|
|
eventTime = p['eventTime']
|
|
|
channel = p['Channel']
|
|
|
+ storage_location = p['storage_location']
|
|
|
if p['is_st'] == 1:
|
|
|
thumbspng = '{uid}/{channel}/{time}.jpeg'.format(uid=devUid, channel=p['Channel'], time=eventTime)
|
|
|
- if region == 2: # 2:国内
|
|
|
- response_url = aws_s3_guonei.generate_presigned_url(
|
|
|
- 'get_object',
|
|
|
- Params={'Bucket': 'push', 'Key': thumbspng}, ExpiresIn=3600)
|
|
|
+ if storage_location == 1: # oss
|
|
|
+ response_url = oss_img_bucket.sign_url('GET', thumbspng, 300)
|
|
|
p['img'] = response_url
|
|
|
p['img_list'] = [response_url]
|
|
|
- else: # 1:国外
|
|
|
- response_url = aws_s3_guowai.generate_presigned_url(
|
|
|
- 'get_object',
|
|
|
- Params={'Bucket': 'foreignpush', 'Key': thumbspng}, ExpiresIn=3600)
|
|
|
+ if region == 2 and storage_location == 2: # 2:国内,aws
|
|
|
+ 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]
|
|
|
+ if region == 1 and storage_location == 2: # 1:国外,aws
|
|
|
+ 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]
|
|
|
|
|
@@ -341,38 +348,44 @@ class DetectControllerViewV2(View):
|
|
|
if vodqs.exists():
|
|
|
bucket_name = vodqs[0]['bucket__bucket']
|
|
|
endpoint = vodqs[0]['bucket__endpoint']
|
|
|
- # bucket = oss2.Bucket(auth, endpoint, bucket_name)
|
|
|
+ bucket = oss2.Bucket(auth, endpoint, bucket_name)
|
|
|
ts = '{uid}/vod{channel}/{etime}/ts0.ts'.format(uid=devUid, channel=p['Channel'], etime=eventTime)
|
|
|
- if region == 2: # 2:国内
|
|
|
- thumb = aws_s3_guonei.generate_presigned_url(
|
|
|
- 'get_object',
|
|
|
- Params={'Bucket': 'push', 'Key': ts}, ExpiresIn=3600)
|
|
|
- else: # 1:国外
|
|
|
- thumb = aws_s3_guowai.generate_presigned_url(
|
|
|
- 'get_object',
|
|
|
- Params={'Bucket': 'foreignpush', 'Key': ts}, ExpiresIn=3600)
|
|
|
- p['img_list'] = [thumb]
|
|
|
- # 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]
|
|
|
+ if storage_location == 1: # oss
|
|
|
+ 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
|
|
|
+ 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
|
|
|
+ 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:
|
|
|
# 列表装载回放时间戳标记
|
|
|
p['img_list'] = []
|
|
|
for i in range(p['is_st']):
|
|
|
thumbspng = '{uid}/{channel}/{time}_{st}.jpeg'.format(uid=devUid, channel=p['Channel'], time=eventTime, st=i)
|
|
|
- if region == 2: # 2:国内
|
|
|
- response_url = aws_s3_guonei.generate_presigned_url(
|
|
|
- 'get_object',
|
|
|
- Params={'Bucket': 'push', 'Key': thumbspng}, ExpiresIn=3600)
|
|
|
+ if storage_location == 1: # oss
|
|
|
+ img = oss_img_bucket.sign_url('GET', thumbspng, 300)
|
|
|
+ p['img_list'].append(img)
|
|
|
+ elif region == 2 and storage_location == 2: # 2:国内,aws
|
|
|
+ response_url = aws_s3_guonei.generate_presigned_url('get_object',
|
|
|
+ Params={'Bucket': 'push', 'Key': thumbspng},
|
|
|
+ ExpiresIn=300)
|
|
|
img = response_url
|
|
|
- else: # 1:国外
|
|
|
- response_url = aws_s3_guowai.generate_presigned_url(
|
|
|
- 'get_object',
|
|
|
- Params={'Bucket': 'foreignpush', 'Key': thumbspng}, ExpiresIn=3600)
|
|
|
+ p['img_list'].append(img)
|
|
|
+ elif region == 1 and storage_location == 2: # 1:国外,aws
|
|
|
+ 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)
|
|
|
+ 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']
|
|
@@ -643,7 +656,8 @@ class NotificationView(View):
|
|
|
alarm='Motion \tChannel:{channel}'.format(channel=channel),
|
|
|
is_st=int_is_st,
|
|
|
receiveTime=n_time,
|
|
|
- addTime=now_time
|
|
|
+ addTime=now_time,
|
|
|
+ storage_location=2
|
|
|
))
|
|
|
if is_sys_msg:
|
|
|
sys_msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz,
|
|
@@ -950,6 +964,7 @@ class NotificationView(View):
|
|
|
redisObject.set_data(key=tmpDKey, val=1, expire=detect_interval)
|
|
|
|
|
|
|
|
|
+# 这个接口没有调用过,不敢动
|
|
|
# http://test.dvema.com/detect/add?uidToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJQMldOR0pSRDJFSEE1RVU5MTExQSJ9.xOCI5lerk8JOs5OcAzunrKCfCrtuPIZ3AnkMmnd-bPY&n_time=1526845794&channel=1&event_type=51&is_st=0
|
|
|
# 移动侦测接口
|
|
|
class PushNotificationView(View):
|
|
@@ -1118,7 +1133,8 @@ class PushNotificationView(View):
|
|
|
alarm='Motion \tChannel:{channel}'.format(channel=channel),
|
|
|
is_st=is_st,
|
|
|
receiveTime=n_time,
|
|
|
- addTime=now_time
|
|
|
+ addTime=now_time,
|
|
|
+ storage_location=2
|
|
|
))
|
|
|
if is_sys_msg:
|
|
|
sys_msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz,
|