|
@@ -204,14 +204,16 @@ class CloudStorageView(View):
|
|
channel = request_dict.get('channel', None)
|
|
channel = request_dict.get('channel', None)
|
|
storeTime = request_dict.get('time', None)
|
|
storeTime = request_dict.get('time', None)
|
|
now_time = int(time.time())
|
|
now_time = int(time.time())
|
|
- vh_qs = VodHlsModel.objects.filter(uid=uid, channel=channel, time=int(storeTime), endTime__gte=now_time). \
|
|
|
|
|
|
+ vh_qs = VodHlsModel.objects.filter(uid=uid, channel=channel, time=storeTime, endTime__gte=now_time). \
|
|
values("sec", "fg", "bucket__bucket", "bucket__endpoint", "bucket__region", "bucket__mold")
|
|
values("sec", "fg", "bucket__bucket", "bucket__endpoint", "bucket__region", "bucket__mold")
|
|
if not vh_qs.exists():
|
|
if not vh_qs.exists():
|
|
- return response.json()
|
|
|
|
|
|
+ return response.json(11,'不存在')
|
|
sec = vh_qs[0]['sec']
|
|
sec = vh_qs[0]['sec']
|
|
fg = vh_qs[0]['fg']
|
|
fg = vh_qs[0]['fg']
|
|
bucket__region = vh_qs[0]['bucket__region']
|
|
bucket__region = vh_qs[0]['bucket__region']
|
|
bucket_name = vh_qs[0]['bucket__bucket']
|
|
bucket_name = vh_qs[0]['bucket__bucket']
|
|
|
|
+ print(bucket__region)
|
|
|
|
+ print(bucket_name)
|
|
aws_access_key_id = 'AKIA2E67UIMD45Y3HL53'
|
|
aws_access_key_id = 'AKIA2E67UIMD45Y3HL53'
|
|
aws_secret_access_key = 'ckYLg4Lo9ZXJIcJEAKkzf2rWvs8Xth1FCjqiAqUw'
|
|
aws_secret_access_key = 'ckYLg4Lo9ZXJIcJEAKkzf2rWvs8Xth1FCjqiAqUw'
|
|
session = Session(
|
|
session = Session(
|
|
@@ -225,7 +227,7 @@ class CloudStorageView(View):
|
|
conn = session.client('s3')
|
|
conn = session.client('s3')
|
|
playlist_entries = []
|
|
playlist_entries = []
|
|
for i in range(fg):
|
|
for i in range(fg):
|
|
- thumbspng = '{uid}/vod{channel}/{time}/{i}.ts'. \
|
|
|
|
|
|
+ thumbspng = '{uid}/vod{channel}/{time}/ts{i}.ts'. \
|
|
format(uid=uid, channel=channel, time=storeTime, i=i)
|
|
format(uid=uid, channel=channel, time=storeTime, i=i)
|
|
response_url = conn.generate_presigned_url(
|
|
response_url = conn.generate_presigned_url(
|
|
'get_object',
|
|
'get_object',
|
|
@@ -242,10 +244,14 @@ class CloudStorageView(View):
|
|
'duration': 10,
|
|
'duration': 10,
|
|
})
|
|
})
|
|
playlist = PlaylistGenerator(playlist_entries).generate()
|
|
playlist = PlaylistGenerator(playlist_entries).generate()
|
|
- response = HttpResponse(playlist, content_type="application/vnd.apple.mpegurl")
|
|
|
|
- # response = HttpResponse(playlist, content_type="application/octet-stream")
|
|
|
|
|
|
+ response = HttpResponse(playlist)
|
|
|
|
+ response['Content-Type'] = 'application/octet-stream'
|
|
|
|
+ response['Content-Disposition'] = 'attachment;filename="play.m3u8"'
|
|
return response
|
|
return response
|
|
- return HttpResponse(status=200, content=playlist)
|
|
|
|
|
|
+
|
|
|
|
+ # response = HttpResponse(playlist, content_type="application/vnd.apple.mpegurl")
|
|
|
|
+ # response = HttpResponse(playlist, content_type="application/octet-stream")
|
|
|
|
+ # return response
|
|
|
|
|
|
def do_get_sign_sts(self, request_dict, ip, response):
|
|
def do_get_sign_sts(self, request_dict, ip, response):
|
|
uidToken = request_dict.get('uidToken', None)
|
|
uidToken = request_dict.get('uidToken', None)
|
|
@@ -342,7 +348,7 @@ class CloudStorageView(View):
|
|
res = json.loads(sts_qs[0]["data"])
|
|
res = json.loads(sts_qs[0]["data"])
|
|
return JsonResponse(status=200, data=res)
|
|
return JsonResponse(status=200, data=res)
|
|
# 套餐id
|
|
# 套餐id
|
|
- # storage = '{uid}/vod{channel}/'.format(uid=uid, channel=channel)
|
|
|
|
|
|
+ storage = '{uid}/vod{channel}/'.format(uid=uid, channel=channel)
|
|
bucket_name = ubqs[0]['bucket__bucket']
|
|
bucket_name = ubqs[0]['bucket__bucket']
|
|
endpoint = ubqs[0]['bucket__endpoint']
|
|
endpoint = ubqs[0]['bucket__endpoint']
|
|
region_id = ubqs[0]['bucket__region']
|
|
region_id = ubqs[0]['bucket__region']
|
|
@@ -355,7 +361,7 @@ class CloudStorageView(View):
|
|
aws_secret_access_key='ckYLg4Lo9ZXJIcJEAKkzf2rWvs8Xth1FCjqiAqUw',
|
|
aws_secret_access_key='ckYLg4Lo9ZXJIcJEAKkzf2rWvs8Xth1FCjqiAqUw',
|
|
region_name=REGION_NAME
|
|
region_name=REGION_NAME
|
|
)
|
|
)
|
|
- print('----------test')
|
|
|
|
|
|
+ print('--------2--test')
|
|
print(REGION_NAME)
|
|
print(REGION_NAME)
|
|
Policy = {
|
|
Policy = {
|
|
"Version": "2012-10-17",
|
|
"Version": "2012-10-17",
|
|
@@ -363,8 +369,8 @@ class CloudStorageView(View):
|
|
{
|
|
{
|
|
"Effect": "Allow",
|
|
"Effect": "Allow",
|
|
"Action": "s3:*",
|
|
"Action": "s3:*",
|
|
- "Resource": ["arn:aws:s3:::{bucket_name}/{uid}/*".
|
|
|
|
- format(bucket_name=bucket_name,uid=uid)]
|
|
|
|
|
|
+ "Resource": ["arn:aws:s3:::{bucket_name}/{uid_channel}*".
|
|
|
|
+ format(bucket_name=bucket_name,uid_channel=storage)]
|
|
}
|
|
}
|
|
]
|
|
]
|
|
}
|
|
}
|
|
@@ -385,7 +391,7 @@ class CloudStorageView(View):
|
|
'bucket_name': bucket_name,
|
|
'bucket_name': bucket_name,
|
|
'arn': response['FederatedUser']['Arn'],
|
|
'arn': response['FederatedUser']['Arn'],
|
|
'code': 0,
|
|
'code': 0,
|
|
- 'storage': uid,
|
|
|
|
|
|
+ 'storage': storage,
|
|
'endTime': ubqs[0]['endTime'],
|
|
'endTime': ubqs[0]['endTime'],
|
|
'ip': ip,
|
|
'ip': ip,
|
|
}
|
|
}
|
|
@@ -413,9 +419,11 @@ class CloudStorageView(View):
|
|
(uid=uid, channel=channel, time__range=(startTime, endTime), endTime__gte=now_time). \
|
|
(uid=uid, channel=channel, time__range=(startTime, endTime), endTime__gte=now_time). \
|
|
values("time", "sec", "bucket__bucket", "bucket__endpoint", "bucket__region", "bucket__mold")
|
|
values("time", "sec", "bucket__bucket", "bucket__endpoint", "bucket__region", "bucket__mold")
|
|
vod_play_list = []
|
|
vod_play_list = []
|
|
- print("---")
|
|
|
|
|
|
+ print("-------------vh_qs")
|
|
print(vh_qs)
|
|
print(vh_qs)
|
|
auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
|
|
+ print('--------------bigin')
|
|
|
|
+ print(int(time.time()))
|
|
for vod in vh_qs:
|
|
for vod in vh_qs:
|
|
bucket__mold = vod["bucket__mold"]
|
|
bucket__mold = vod["bucket__mold"]
|
|
bucket_name = vod["bucket__bucket"]
|
|
bucket_name = vod["bucket__bucket"]
|
|
@@ -437,35 +445,37 @@ class CloudStorageView(View):
|
|
params={'x-oss-process': 'video/snapshot,t_10000,m_fast,w_300'})
|
|
params={'x-oss-process': 'video/snapshot,t_10000,m_fast,w_300'})
|
|
vod_play_list.append({'name': vod['time'], 'sign_url': vod_play_url, 'thumb': thumb, 'sec': vod['sec']})
|
|
vod_play_list.append({'name': vod['time'], 'sign_url': vod_play_url, 'thumb': thumb, 'sec': vod['sec']})
|
|
elif bucket__mold == 1:
|
|
elif bucket__mold == 1:
|
|
- aws_access_key_id = 'AKIA2E67UIMD45Y3HL53'
|
|
|
|
- aws_secret_access_key = 'ckYLg4Lo9ZXJIcJEAKkzf2rWvs8Xth1FCjqiAqUw'
|
|
|
|
- session = Session(
|
|
|
|
- aws_access_key_id=aws_access_key_id,
|
|
|
|
- aws_secret_access_key=aws_secret_access_key,
|
|
|
|
- region_name=bucket__region
|
|
|
|
- )
|
|
|
|
- conn = session.client('s3')
|
|
|
|
- thumbspng = '{uid}/vod{channel}/{time}/thumbs.png'. \
|
|
|
|
- format(uid=uid, channel=channel, time=vod['time'])
|
|
|
|
- response_url = conn.generate_presigned_url(
|
|
|
|
- 'get_object',
|
|
|
|
- Params={
|
|
|
|
- 'Bucket': bucket_name,
|
|
|
|
- 'Key': thumbspng
|
|
|
|
- },
|
|
|
|
- ExpiresIn=3600
|
|
|
|
- )
|
|
|
|
|
|
+ # aws_access_key_id = 'AKIA2E67UIMD45Y3HL53'
|
|
|
|
+ # aws_secret_access_key = 'ckYLg4Lo9ZXJIcJEAKkzf2rWvs8Xth1FCjqiAqUw'
|
|
|
|
+ # session = Session(
|
|
|
|
+ # aws_access_key_id=aws_access_key_id,
|
|
|
|
+ # aws_secret_access_key=aws_secret_access_key,
|
|
|
|
+ # region_name=bucket__region
|
|
|
|
+ # )
|
|
|
|
+ # conn = session.client('s3')
|
|
|
|
+ # thumbspng = '{uid}/vod{channel}/{time}/thumbs.jpg'. \
|
|
|
|
+ # format(uid=uid, channel=channel, time=vod['time'])
|
|
|
|
+ # response_url = conn.generate_presigned_url(
|
|
|
|
+ # 'get_object',
|
|
|
|
+ # Params={
|
|
|
|
+ # 'Bucket': bucket_name,
|
|
|
|
+ # 'Key': thumbspng
|
|
|
|
+ # },
|
|
|
|
+ # ExpiresIn=3600
|
|
|
|
+ # )
|
|
|
|
+ # thumb_url = response_url
|
|
# m3u8 = '{uid}/vod{channel}/{time}/{time}.m3u8'. \
|
|
# m3u8 = '{uid}/vod{channel}/{time}/{time}.m3u8'. \
|
|
# format(uid=uid, channel=channel, time=vod['time'])
|
|
# format(uid=uid, channel=channel, time=vod['time'])
|
|
- thumb_url = response_url
|
|
|
|
- vod_url = 'http://cloudstroage.dvema.com/cloudstorage/signplaym3u8?' \
|
|
|
|
|
|
+ vod_url = 'http://test.dvema.com/cloudstorage/signplaym3u8?' \
|
|
'uid={uid}&channel={channel}&time={time}&sign=tktktktk'. \
|
|
'uid={uid}&channel={channel}&time={time}&sign=tktktktk'. \
|
|
format(uid=uid, channel=channel, time=vod['time'])
|
|
format(uid=uid, channel=channel, time=vod['time'])
|
|
vod_play_list.append({
|
|
vod_play_list.append({
|
|
'name': vod['time'],
|
|
'name': vod['time'],
|
|
'sign_url': vod_url,
|
|
'sign_url': vod_url,
|
|
- 'thumb': thumb_url,
|
|
|
|
|
|
+ # 'thumb': thumb_url,
|
|
'sec': vod['sec']})
|
|
'sec': vod['sec']})
|
|
|
|
+ print('--------------end')
|
|
|
|
+ print(int(time.time()))
|
|
return response.json(0, vod_play_list)
|
|
return response.json(0, vod_play_list)
|
|
|
|
|
|
def do_store_playlist(self, request_dict, response):
|
|
def do_store_playlist(self, request_dict, response):
|
|
@@ -667,7 +677,7 @@ class CloudStorageView(View):
|
|
function payOKButton() {
|
|
function payOKButton() {
|
|
// 复杂数据
|
|
// 复杂数据
|
|
console.log('success')
|
|
console.log('success')
|
|
- window.webkit.messageHandlers.jsCallOC.postMessage({"status": 0});
|
|
|
|
|
|
+ window.location.href="https://www.baidu.com?page=closePage";
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
</body>
|
|
</body>
|
|
@@ -747,7 +757,7 @@ class CloudStorageView(View):
|
|
function payOKButton() {
|
|
function payOKButton() {
|
|
// 复杂数据
|
|
// 复杂数据
|
|
console.log('success')
|
|
console.log('success')
|
|
- window.webkit.messageHandlers.jsCallOC.postMessage({"status": 1});
|
|
|
|
|
|
+ window.location.href="https://www.baidu.com?page=closePage"
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
</body>
|
|
</body>
|
|
@@ -865,6 +875,8 @@ class CloudStorageView(View):
|
|
pay_type = int(request_dict.get('pay_type', None))
|
|
pay_type = int(request_dict.get('pay_type', None))
|
|
rank = request_dict.get('rank', None)
|
|
rank = request_dict.get('rank', None)
|
|
|
|
|
|
|
|
+ if uid == None or channel == None or commodity_code == None or pay_type == None or rank == None:
|
|
|
|
+ return response.json(13, '参数有误.')
|
|
dv_qs = Device_Info.objects.filter(userID_id=userID, UID=uid, isShare=False, isExist=1)
|
|
dv_qs = Device_Info.objects.filter(userID_id=userID, UID=uid, isShare=False, isExist=1)
|
|
if not dv_qs.exists():
|
|
if not dv_qs.exists():
|
|
return response.json(12)
|
|
return response.json(12)
|