|
@@ -1,4 +1,5 @@
|
|
|
import time
|
|
|
+
|
|
|
import boto3
|
|
|
import botocore
|
|
|
import oss2
|
|
@@ -7,12 +8,16 @@ from django.core.paginator import Paginator
|
|
|
from django.db.models import Q
|
|
|
from django.views.generic.base import View
|
|
|
|
|
|
+from Ansjer.config import CONFIG_EUR, CONFIG_US
|
|
|
from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, \
|
|
|
SERVER_TYPE
|
|
|
+from Controller.DetectControllerV2 import DetectControllerViewV2
|
|
|
+from Model import models
|
|
|
from Model.models import Device_Info, VodBucketModel, DeviceTypeModel
|
|
|
+from Object.OCIObjectStorage import OCIObjectStorage
|
|
|
+from Object.RedisObject import RedisObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
|
-from Model import models
|
|
|
from Object.utils import LocalDateTimeUtil
|
|
|
from Service.EquipmentInfoService import EquipmentInfoService
|
|
|
from Service.VodHlsService import SplitVodHlsObject
|
|
@@ -143,6 +148,11 @@ class MassageView(View):
|
|
|
region_name='cn-northwest-1'
|
|
|
)
|
|
|
|
|
|
+ # 国内生产环境默认不实例OCI对象
|
|
|
+ oci_eur = OCIObjectStorage(CONFIG_EUR)
|
|
|
+ oci_us = OCIObjectStorage(CONFIG_US)
|
|
|
+ redis_obj = RedisObject(3)
|
|
|
+
|
|
|
# ai消息标识所有组合标签
|
|
|
ai_all_event_type = EquipmentInfoService.get_all_comb_event_type()
|
|
|
|
|
@@ -161,12 +171,24 @@ class MassageView(View):
|
|
|
thumbspng = '{}/{}/{}.jpeg'.format(uid, channel, event_time)
|
|
|
if storage_location == 1: # 阿里云oss
|
|
|
img_url = oss_img_bucket.sign_url('GET', thumbspng, 300)
|
|
|
+ elif storage_location in [3, 4]:
|
|
|
+ prefix_name = f'{uid}/'
|
|
|
+ oci = oci_eur if storage_location == 4 else oci_us
|
|
|
+ img_url = DetectControllerViewV2.oci_object_url(oci, redis_obj, uid, prefix_name)
|
|
|
+ if img_url:
|
|
|
+ img_url = img_url + thumbspng
|
|
|
else:
|
|
|
params = {'Key': thumbspng}
|
|
|
if region == 1: # AWS国外
|
|
|
params['Bucket'] = 'foreignpush'
|
|
|
img_url = aws_s3.generate_presigned_url(
|
|
|
'get_object', Params=params, ExpiresIn=300)
|
|
|
+ elif storage_location in [3, 4]: # 国外OCI云
|
|
|
+ prefix_name = f'{uid}/'
|
|
|
+ oci = oci_eur if storage_location == 4 else oci_us
|
|
|
+ img_url = DetectControllerViewV2.oci_object_url(oci, redis_obj, uid, prefix_name)
|
|
|
+ if img_url:
|
|
|
+ img_url = img_url + thumbspng
|
|
|
else: # AWS国内
|
|
|
params['Bucket'] = 'push'
|
|
|
img_url = aws_s3_cn.generate_presigned_url(
|
|
@@ -190,9 +212,12 @@ class MassageView(View):
|
|
|
bucket = oss2.Bucket(auth, endpoint, bucket_name)
|
|
|
ts = '{}/vod{}/{}/ts0.ts'.format(uid, channel, event_time)
|
|
|
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'})
|
|
|
+ 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'})
|
|
|
img_url = ""
|
|
|
img_list = [thumb0, thumb1, thumb2]
|
|
|
else:
|
|
@@ -272,4 +297,3 @@ class MassageView(View):
|
|
|
except Exception as e:
|
|
|
print(e)
|
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
-
|