|
@@ -51,7 +51,7 @@ from Object.UidTokenObject import UidTokenObject
|
|
|
from Service.CommonService import CommonService
|
|
|
from Object.m3u8generate import PlaylistGenerator
|
|
|
from Object.WechatPayObject import WechatPayObject
|
|
|
-from django.db.models import Q, F
|
|
|
+from django.db.models import Q, F, Count
|
|
|
|
|
|
from Service.ModelService import ModelService
|
|
|
|
|
@@ -139,6 +139,8 @@ class CloudStorageView(View):
|
|
|
return self.device_commodity(request_dict, userID, response)
|
|
|
elif operation == 'switchdevicecommodity': # 提前使用设备关联套餐
|
|
|
return self.switch_device_commodity(request_dict, userID, response)
|
|
|
+ elif operation == 'hasvod': #APP的回放界面,日历表显示当天有无录像
|
|
|
+ return self.has_vod(request_dict, userID, response)
|
|
|
else:
|
|
|
return response.json(414)
|
|
|
|
|
@@ -415,12 +417,12 @@ class CloudStorageView(View):
|
|
|
region_name=vh_qs[0]["bucket__region"]
|
|
|
)
|
|
|
conn = session.client('s3')
|
|
|
-
|
|
|
+ uidToken = TokenObject().encryption(data={'uid': uid})
|
|
|
for vod in vh_qs:
|
|
|
- bucket__mold = vod["bucket__mold"]
|
|
|
+ # bucket__mold = vod["bucket__mold"]
|
|
|
bucket_name = vod["bucket__bucket"]
|
|
|
- endpoint = vod["bucket__endpoint"]
|
|
|
- bucket__region = vod["bucket__region"]
|
|
|
+ # endpoint = vod["bucket__endpoint"]
|
|
|
+ # bucket__region = vod["bucket__region"]
|
|
|
thumbspng = '{uid}/vod{channel}/{time}/Thumb.jpeg'. \
|
|
|
format(uid=uid, channel=channel, time=vod['time'])
|
|
|
response_url = conn.generate_presigned_url(
|
|
@@ -433,7 +435,7 @@ class CloudStorageView(View):
|
|
|
)
|
|
|
vod_url = '{server_domain}/cloudstorage/signplaym3u8?' \
|
|
|
'uid={uid}&channel={channel}&time={time}&sign=tktktktk'. \
|
|
|
- format(server_domain=SERVER_DOMAIN_SSL, uid=TokenObject().encryption(data={'uid': uid}), channel=channel, time=vod['time'])
|
|
|
+ format(server_domain=SERVER_DOMAIN_SSL, uid=uidToken, channel=channel, time=vod['time'])
|
|
|
ts_num = int(vod['fg']) & 0xf
|
|
|
vod_play_list.append({
|
|
|
'start_time': vod['time'],
|
|
@@ -472,25 +474,18 @@ class CloudStorageView(View):
|
|
|
bucket_id = ub_qs_data['bucket__id']
|
|
|
end_time = int(storeTime) + store_day * 86400
|
|
|
if ub_qs_data['status'] == 1:
|
|
|
- sts_qs = StsCrdModel.objects.filter(uid=UID, channel=channel, type=1). \
|
|
|
- values("addTime", "data")
|
|
|
- if sts_qs.exists():
|
|
|
- VodHlsModel.objects.create(
|
|
|
- uid=UID,
|
|
|
- channel=channel,
|
|
|
- time=storeTime,
|
|
|
- endTime=end_time,
|
|
|
- bucket_id=bucket_id,
|
|
|
- fg=fg,
|
|
|
- sec=sec,
|
|
|
- )
|
|
|
- res = {'code': 0, 'msg': '存储成功'}
|
|
|
- return HttpResponse(json.dumps(res, ensure_ascii=False),
|
|
|
- content_type="application/json,charset=utf-8")
|
|
|
- else:
|
|
|
- res = {'code': 404, 'msg': '设备未购买'}
|
|
|
- return HttpResponse(json.dumps(res, ensure_ascii=False),
|
|
|
- content_type="application/json,charset=utf-8")
|
|
|
+ VodHlsModel.objects.create(
|
|
|
+ uid=UID,
|
|
|
+ channel=channel,
|
|
|
+ time=storeTime,
|
|
|
+ endTime=end_time,
|
|
|
+ bucket_id=bucket_id,
|
|
|
+ fg=fg,
|
|
|
+ sec=sec,
|
|
|
+ )
|
|
|
+ res = {'code': 0, 'msg': '存储成功'}
|
|
|
+ return HttpResponse(json.dumps(res, ensure_ascii=False),
|
|
|
+ content_type="application/json,charset=utf-8")
|
|
|
else:
|
|
|
res = {'code': 404, 'msg': '设备未开启'}
|
|
|
return HttpResponse(json.dumps(res, ensure_ascii=False), content_type="application/json,charset=utf-8")
|
|
@@ -1433,6 +1428,33 @@ class CloudStorageView(View):
|
|
|
return response.json(0)
|
|
|
return response.json(444)
|
|
|
|
|
|
+ def has_vod(self, request_dict, userID, response):
|
|
|
+ uid = request_dict.get('uid', None)
|
|
|
+ channel = request_dict.get('channel', 1)
|
|
|
+ dv_qs = Device_Info.objects.filter(userID_id=userID, UID=uid, isShare=False).values('vodPrimaryUserID',
|
|
|
+ 'vodPrimaryMaster')
|
|
|
+ if not dv_qs.exists():
|
|
|
+ return response.json(12)
|
|
|
+ if dv_qs[0]['vodPrimaryUserID'] != userID:
|
|
|
+ return response.json(10034)
|
|
|
+ now_time = int(time.time())
|
|
|
+ bv_qs = UID_Bucket.objects.filter(uid=uid, endTime__gte=now_time ,channel=channel).values('bucket_id').order_by('addTime')
|
|
|
+ if not bv_qs.exists():
|
|
|
+ return response.json(10030)
|
|
|
+
|
|
|
+ had_vod_query = VodHlsModel.objects.extra(select={'date': "FROM_UNIXTIME(time,'%%Y-%%m-%%d')"}).values(
|
|
|
+ 'date').filter(uid=uid,endTime__gte=now_time,channel=channel).annotate(count=Count('time')).order_by('-date')[:31]
|
|
|
+
|
|
|
+ had_vod_list = []
|
|
|
+ for vod in had_vod_query:
|
|
|
+ had_vod_list.append({
|
|
|
+ 'timestamp': CommonService.str_to_timestamp(vod['date'], '%Y-%m-%d'),
|
|
|
+ 'vod_count': vod['count'],
|
|
|
+ 'date_format': vod['date'],
|
|
|
+ })
|
|
|
+
|
|
|
+ return response.json(0, had_vod_list)
|
|
|
+
|
|
|
# 云存操作系统消息
|
|
|
def do_vod_msg_Notice(self, uid, channel, userID, lang, sys_msg_text_list, sms):
|
|
|
try:
|