|
@@ -11,24 +11,22 @@
|
|
|
@file: CloudVod.py
|
|
|
@Contact: chanjunkai@163.com
|
|
|
"""
|
|
|
-import datetime
|
|
|
import json
|
|
|
-import time
|
|
|
import math
|
|
|
+import time
|
|
|
+import urllib
|
|
|
|
|
|
import oss2
|
|
|
import paypalrestsdk
|
|
|
from aliyunsdkcore import client
|
|
|
from aliyunsdksts.request.v20150401 import AssumeRoleRequest
|
|
|
from django.http import JsonResponse
|
|
|
-from django.utils import timezone
|
|
|
from django.utils.decorators import method_decorator
|
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
|
from django.views.generic.base import View
|
|
|
-import urllib
|
|
|
|
|
|
from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, OSS_ROLE_ARN, SERVER_DOMAIN
|
|
|
-from Model.models import Device_Meal, Device_Info, Order_Model, Store_Meal, VodHlsModel, OssCrdModel, UID_Bucket
|
|
|
+from Model.models import Device_Info, Order_Model, Store_Meal, VodHlsModel, OssCrdModel, UID_Bucket
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
|
from Object.UidTokenObject import UidTokenObject
|
|
@@ -119,12 +117,13 @@ class CloudVodView(View):
|
|
|
if not did or not channel or not rank:
|
|
|
return response.json(444, 'did,channel,rank')
|
|
|
smqs = Store_Meal.objects.filter(id=rank).values("currency", "price", "content", "day", "bucket__storeDay")
|
|
|
+ if not smqs.exists():
|
|
|
+ return response.json(10, '套餐不存在')
|
|
|
currency = smqs[0]['currency']
|
|
|
price = smqs[0]['price']
|
|
|
content = smqs[0]['content']
|
|
|
day = smqs[0]['day']
|
|
|
- if not smqs.exists():
|
|
|
- return response.json(10, '套餐不存在')
|
|
|
+
|
|
|
qs = Device_Info.objects.filter(userID_id=userID, id=did).values("UID")
|
|
|
if not qs.exists():
|
|
|
return response.json(13)
|
|
@@ -188,7 +187,9 @@ class CloudVodView(View):
|
|
|
channel = utko.channel
|
|
|
print(channel)
|
|
|
print(UID)
|
|
|
- ubqs = UID_Bucket.objects.filter(uid=UID, channel=channel, status=1).values('channel','bucket__bucket','bucket__endpoint','bucket__region','endTime')
|
|
|
+ ubqs = UID_Bucket.objects.filter(uid=UID, channel=channel, status=1).values('channel', 'bucket__bucket',
|
|
|
+ 'bucket__endpoint',
|
|
|
+ 'bucket__region', 'endTime')
|
|
|
if not ubqs.exists():
|
|
|
res = {'code': 403}
|
|
|
return JsonResponse(status=200, data=res)
|
|
@@ -228,10 +229,7 @@ class CloudVodView(View):
|
|
|
"Version": "1",
|
|
|
"Statement": [
|
|
|
{
|
|
|
- "Action": [
|
|
|
- "oss:PutObject",
|
|
|
- "oss:DeleteObject",
|
|
|
- ],
|
|
|
+ "Action": ["oss:PutObject", "oss:DeleteObject", ],
|
|
|
"Resource": [Resource_access],
|
|
|
"Effect": "Allow",
|
|
|
"Condition": {
|
|
@@ -258,8 +256,7 @@ class CloudVodView(View):
|
|
|
'arn': token['AssumedRoleUser']['Arn'],
|
|
|
'code': 0,
|
|
|
'storage': storage,
|
|
|
- 'ip': ip
|
|
|
- }
|
|
|
+ 'ip': ip}
|
|
|
if oc_qs.exists():
|
|
|
oc_qs.update(data=json.dumps(res), addTime=now_time_stamp)
|
|
|
else:
|
|
@@ -342,7 +339,7 @@ class CloudVodView(View):
|
|
|
rank_id = order_list[0]['rank_id']
|
|
|
UID = order_list[0]['UID']
|
|
|
channel = order_list[0]['channel']
|
|
|
- smqs = Store_Meal.objects.filter(id=rank_id).values("day", "bucket_id")
|
|
|
+ smqs = Store_Meal.objects.filter(id=rank_id).values("day", "bucket_id","bucket__storeDay")
|
|
|
bucketId = smqs[0]['bucket_id']
|
|
|
if not smqs.exists():
|
|
|
return response.json(0, '套餐已删除')
|
|
@@ -429,20 +426,21 @@ class CloudVodView(View):
|
|
|
if utko.flag is False:
|
|
|
return response.json(444, 'uidToken')
|
|
|
if not uidToken or not storeTime or not sec:
|
|
|
- return response.json(444,'uidToken,time,sec')
|
|
|
+ return response.json(444, 'uidToken,time,sec')
|
|
|
UID = utko.UID
|
|
|
channel = utko.channel
|
|
|
print(channel)
|
|
|
print(UID)
|
|
|
qs = UID_Bucket.objects.filter(uid=UID, channel=channel, status=1).values("channel", "bucket__storeDay",
|
|
|
- "bucket_id")
|
|
|
+ "bucket_id")
|
|
|
if not qs.exists():
|
|
|
return response.json(10, '设备未购买')
|
|
|
# nowTime = time.time()
|
|
|
storeDay = qs[0]['bucket__storeDay']
|
|
|
bucketID = qs[0]['bucket_id']
|
|
|
endTime = int(storeTime) + storeDay * 86400
|
|
|
- VodHlsModel.objects.create(uid=UID, channel=channel, time=storeTime, endTime=endTime, bucket_id=bucketID, sec=sec)
|
|
|
+ VodHlsModel.objects.create(uid=UID, channel=channel, time=storeTime, endTime=endTime, bucket_id=bucketID,
|
|
|
+ sec=sec)
|
|
|
return response.json(0)
|
|
|
|
|
|
def do_get_playlist(self, request_dict, userID, response):
|