|
@@ -45,6 +45,8 @@ from Object.UidTokenObject import UidTokenObject
|
|
|
from Service.CommonService import CommonService
|
|
|
from Service.ModelService import ModelService
|
|
|
from Object.m3u8generate import PlaylistGenerator
|
|
|
+from Model.models import Device_User, Device_Info, UID_Bucket, UID_Preview, UidSetModel, UidPushModel
|
|
|
+
|
|
|
|
|
|
|
|
|
SERVER_DOMAIN = 'http://test.dvema.com/'
|
|
@@ -87,6 +89,9 @@ class testView(View):
|
|
|
elif operation == 'get_sign_sts':
|
|
|
ip = CommonService.get_ip_address(request)
|
|
|
return self.do_test_get_sign_sts(request_dict, ip, response)
|
|
|
+ elif operation == 'eqi_query':
|
|
|
+ userID = '158943594633713800138000'
|
|
|
+ return self.queryInterface(request_dict, userID, response)
|
|
|
else:
|
|
|
return 12344444
|
|
|
|
|
@@ -112,6 +117,79 @@ class testView(View):
|
|
|
with open('local.txt', 'wb') as f:
|
|
|
f.write(resp['Body'].read())
|
|
|
|
|
|
+ # 新查询设备字段
|
|
|
+ def queryInterface(self, request_dict, userID, response):
|
|
|
+ page = request_dict.get('page', None)
|
|
|
+ line = request_dict.get('line', None)
|
|
|
+ NickName = request_dict.get('NickName', None)
|
|
|
+ uid = request_dict.get('uid', None)
|
|
|
+ page = int(page)
|
|
|
+ line = int(line)
|
|
|
+ response.lang = 'cn'
|
|
|
+ userID = userID
|
|
|
+ dvqs = Device_Info.objects.filter(userID_id=userID)
|
|
|
+ # # 已重置的设备
|
|
|
+ # dvqs = dvqs.filter(~Q(isExist=2))
|
|
|
+ if NickName:
|
|
|
+ dvqs = dvqs.filter(NickName__icontains=NickName)
|
|
|
+ if uid:
|
|
|
+ dvqs = dvqs.filter(UID=uid)
|
|
|
+ # count = dvqs.count()
|
|
|
+ #分页
|
|
|
+ dvql = dvqs[(page - 1) * line:page * line].values('id', 'userID', 'NickName', 'UID', 'View_Account',
|
|
|
+ 'View_Password', 'ChannelIndex', 'Type', 'isShare',
|
|
|
+ 'primaryUserID', 'primaryMaster', 'data_joined',
|
|
|
+ 'version',
|
|
|
+ 'isVod', 'isExist', 'NotificationMode')
|
|
|
+ dvls = CommonService.qs_to_list(dvql)
|
|
|
+ uid_list = []
|
|
|
+ for dvl in dvls:
|
|
|
+ uid_list.append(dvl['UID'])
|
|
|
+ # if dvl['isShare'] is False:
|
|
|
+ # uid_list.append(dvl['UID'])
|
|
|
+ ubqs = UID_Bucket.objects.filter(uid__in=uid_list). \
|
|
|
+ values('bucket__content', 'status', 'channel', 'endTime', 'uid')
|
|
|
+ upqs = UID_Preview.objects.filter(uid__in=uid_list).order_by('channel').values('id', 'uid', 'channel')
|
|
|
+ auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
|
+ bucket = oss2.Bucket(auth, 'oss-cn-hongkong.aliyuncs.com', 'statres')
|
|
|
+ nowTime = int(time.time())
|
|
|
+ data = []
|
|
|
+ # 设备拓展信息表
|
|
|
+ us_qs = UidSetModel.objects.filter(uid__in=uid_list). \
|
|
|
+ values('uid', 'version', 'nickname', 'detect_interval')
|
|
|
+ uv_dict = {}
|
|
|
+ for us in us_qs:
|
|
|
+ uv_dict[us['uid']] = {'version': us['version'],
|
|
|
+ 'nickname': us['nickname'],
|
|
|
+ 'detect_interval': us['detect_interval']}
|
|
|
+ for p in dvls:
|
|
|
+ p['vod'] = []
|
|
|
+ for dm in ubqs:
|
|
|
+ if p['UID'] == dm['uid']:
|
|
|
+ if dm['endTime'] > nowTime:
|
|
|
+ p['vod'].append(dm)
|
|
|
+ p['preview'] = []
|
|
|
+ for up in upqs:
|
|
|
+ if p['UID'] == up['uid']:
|
|
|
+ obj = 'uid_preview/{uid}/channel_{channel}.png'. \
|
|
|
+ format(uid=up['uid'], channel=up['channel'])
|
|
|
+ img_sign = bucket.sign_url('GET', obj, 300)
|
|
|
+ p['preview'].append(img_sign)
|
|
|
+ p_uid = p['UID']
|
|
|
+ if p_uid in uv_dict:
|
|
|
+ # 设备版本号
|
|
|
+ p['uid_version'] = uv_dict[p_uid]['version']
|
|
|
+ p['detect_interval'] = uv_dict[p_uid]['detect_interval']
|
|
|
+ # 设备昵称 调用影子信息昵称,先阶段不可
|
|
|
+ if uv_dict[p_uid]['nickname']:
|
|
|
+ p['NickName'] = uv_dict[p_uid]['nickname']
|
|
|
+ else:
|
|
|
+ # 设备版本号
|
|
|
+ p['uid_version'] = ''
|
|
|
+ data.append(p)
|
|
|
+ return response.json(0, data)
|
|
|
+
|
|
|
+
|
|
|
#获取播放列表
|
|
|
def do_test_query_vod_list(self, userID, ip, request_dict, response):
|
|
|
uid = 'GZL2PEFJPLY7W6BG111A'
|
|
@@ -143,7 +221,7 @@ class testView(View):
|
|
|
# m3u8 = '{uid}/vod{channel}/{time}/{time}.m3u8'. \
|
|
|
# format(uid=uid, channel=channel, time=vod['time'])
|
|
|
thumb_url = response_url
|
|
|
- vod_url = 'http://13.56.215.252:8077/testApi/signplaym3u8?' \
|
|
|
+ vod_url = 'http://192.168.136.201:8000/testApi/signplaym3u8?' \
|
|
|
'uid={uid}&channel={channel}&time={time}&sign=tktktktk'. \
|
|
|
format(ip=ip, uid=uid, channel=channel, time=1590485548)
|
|
|
vod_play_list.append({
|
|
@@ -183,7 +261,7 @@ class testView(View):
|
|
|
'Bucket': bucket_name,
|
|
|
'Key': thumbspng
|
|
|
},
|
|
|
- ExpiresIn=3600
|
|
|
+ ExpiresIn=86400
|
|
|
)
|
|
|
# m3u8 = '{uid}/vod{channel}/{time}/{time}.m3u8'. \
|
|
|
# format(uid=uid, channel=channel, time=vod['time'])
|