|
@@ -195,17 +195,16 @@ class CloudVodView(View):
|
|
|
channel = utko.channel
|
|
|
print(channel)
|
|
|
print(UID)
|
|
|
- qs = Device_Meal.objects.filter(uid=UID, channel=channel, status=1).values("rank", "channel", "end_time")
|
|
|
+ qs = Device_Meal.objects.filter(uid=UID, channel=channel, status=1).values("channel", "end_time","rank__bucket__bucket")
|
|
|
if not qs.exists():
|
|
|
res = {'code': 403}
|
|
|
- return JsonResponse(status=200,data=res)
|
|
|
+ return JsonResponse(status=200, data=res)
|
|
|
# return response.json(10, '设备未购买')
|
|
|
now_time = timezone.localtime(timezone.now())
|
|
|
if now_time > qs[0]['end_time']:
|
|
|
res = {'code': 403}
|
|
|
return JsonResponse(status=200, data=res)
|
|
|
|
|
|
-
|
|
|
now_time_stamp = int(time.time())
|
|
|
oc_qs = OssCrdModel.objects.filter(uid=UID, channel=channel).values("addTime", "data")
|
|
|
if oc_qs.exists():
|
|
@@ -216,18 +215,8 @@ class CloudVodView(View):
|
|
|
res = json.loads(oc_qs[0]["data"])
|
|
|
return JsonResponse(status=200, data=res)
|
|
|
# 套餐id
|
|
|
- rank = qs[0]['rank']
|
|
|
storage = '{uid}/vod{channel}/'.format(uid=UID, channel=channel)
|
|
|
-
|
|
|
- # bucket_vod_list = {1: 'cloudvod1', 2: 'cloudvod2', 3: 'cloudvod3'}
|
|
|
- # bucket_name = bucket_vod_list[rank]
|
|
|
- # endpoint = 'oss-cn-shenzhen.aliyuncs.com'
|
|
|
- # access_key_id = 'LTAIyMkGfEdogyL9'
|
|
|
- # access_key_secret = '71uIjpsqVOmF7DAITRyRuc259jHOjO'
|
|
|
- # region_id = 'cn-shenzhen'
|
|
|
- # role_arn = 'acs:ram::1901342792446414:role/stsoss'
|
|
|
- bucket_vod_list = OSS_BUCKET_VOD_LIST
|
|
|
- bucket_name = bucket_vod_list[rank]
|
|
|
+ bucket_name = qs[0]['rank__bucket__bucket']
|
|
|
endpoint = OSS_BUCKET_ENDPOINT
|
|
|
access_key_id = OSS_STS_ACCESS_KEY
|
|
|
access_key_secret = OSS_STS_ACCESS_SECRET
|
|
@@ -299,14 +288,13 @@ class CloudVodView(View):
|
|
|
if not qs.exists():
|
|
|
return response.json(13)
|
|
|
uid = qs[0]['UID']
|
|
|
- dm_qs = Device_Meal.objects.filter(uid=uid, channel=channel).values('rank', 'end_time')
|
|
|
+ dm_qs = Device_Meal.objects.filter(uid=uid, channel=channel).values('rank__bucket__bucket','end_time')
|
|
|
now_time = timezone.localtime(timezone.now())
|
|
|
if now_time > dm_qs[0]['end_time']:
|
|
|
return response.json(10, '已过期')
|
|
|
if not dm_qs.exists():
|
|
|
return response.json(10, '未开通云存储')
|
|
|
- rank = dm_qs[0]["rank"]
|
|
|
- bucket_name = OSS_BUCKET_VOD_LIST[rank]
|
|
|
+ bucket_name = dm_qs[0]["rank__bucket__bucket"]
|
|
|
auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
|
bucket = oss2.Bucket(auth, OSS_BUCKET_ENDPOINT, bucket_name)
|
|
|
vod_play_list = []
|
|
@@ -405,6 +393,7 @@ class CloudVodView(View):
|
|
|
def do_store_palylist(self, request_dict, response):
|
|
|
uidToken = request_dict.get('uidToken', None)
|
|
|
time = request_dict.get('time', None)
|
|
|
+ sec = request_dict.get('sec',None)
|
|
|
utko = UidTokenObject(uidToken)
|
|
|
if utko.flag is False:
|
|
|
return response.json(444, 'uidToken')
|
|
@@ -412,12 +401,15 @@ class CloudVodView(View):
|
|
|
channel = utko.channel
|
|
|
print(channel)
|
|
|
print(UID)
|
|
|
- qs = Device_Meal.objects.filter(uid=UID, channel=channel, status=1).values("rank", "channel")
|
|
|
+ qs = Device_Meal.objects.filter(uid=UID, channel=channel, status=1).values("channel", "rank__bucket__storeDay",
|
|
|
+ "rank__bucket_id")
|
|
|
if not qs.exists():
|
|
|
return response.json(10, '设备未购买')
|
|
|
nowTime = int(time)
|
|
|
- # endTime = int(time)+
|
|
|
- VodHlsModel.objects.create(uid=UID, channel=channel, time=nowTime)
|
|
|
+ storeDay = qs[0]['rank__bucket__storeDay']
|
|
|
+ bucketID = qs[0]['rank__bucket_id']
|
|
|
+ endTime = nowTime + storeDay * 86400
|
|
|
+ VodHlsModel.objects.create(uid=UID, channel=channel, time=nowTime, endTime=endTime, bucket_id=bucketID,sec=sec)
|
|
|
return response.json(0)
|
|
|
|
|
|
def do_get_playlist(self, request_dict, userID, response):
|