|
@@ -24,6 +24,7 @@ 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_BUCKET_ENDPOINT, OSS_BUCKET_VOD_LIST, OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, \
|
|
|
OSS_REGION_ID, OSS_ROLE_ARN, SERVER_DOMAIN
|
|
@@ -103,7 +104,7 @@ class CloudVodView(View):
|
|
|
# call_sub_url = "{SERVER_DOMAIN}cloudVod/payExecute?orderID={orderID}".format(SERVER_DOMAIN=SERVER_DOMAIN,orderID=orderID)
|
|
|
call_sub_url = "http://192.168.136.40:8077/cloudVod/payExecute?orderID={orderID}".format(
|
|
|
SERVER_DOMAIN=SERVER_DOMAIN, orderID=orderID)
|
|
|
- call_clc_url = "http://localhost:3000/"
|
|
|
+ call_clc_url = "http://192.168.136.40:8077/cloudVod/order/cancle"
|
|
|
paypalrestsdk.configure({
|
|
|
"mode": "sandbox", # sandbox or live
|
|
|
"client_id": "AfnfDqezODOoWGS-W2Itu-Zl1ay1R95IsGlMqPghPA3KGhkPndNMnQT0bdEewvSv92XAFIfLiinmyhBL",
|
|
@@ -115,15 +116,8 @@ class CloudVodView(View):
|
|
|
"redirect_urls": {"return_url": call_sub_url, "cancel_url": call_clc_url},
|
|
|
"transactions": [{
|
|
|
"item_list": {
|
|
|
- "items": [{
|
|
|
- "name": "Cloud video",
|
|
|
- "sku": "1",
|
|
|
- "price": price,
|
|
|
- "currency": "USD",
|
|
|
- "quantity": 1}]},
|
|
|
- "amount": {
|
|
|
- "total": price,
|
|
|
- "currency": "USD"},
|
|
|
+ "items": [{"name": "Cloud video", "sku": "1", "price": price, "currency": "USD", "quantity": 1}]},
|
|
|
+ "amount": {"total": price, "currency": "USD"},
|
|
|
"description": "7 days mobile detection storage event 1 month charge"
|
|
|
}]})
|
|
|
|
|
@@ -238,7 +232,11 @@ class CloudVodView(View):
|
|
|
def do_get_hls_list(self, request_dict, userID, response):
|
|
|
did = request_dict.get('did', None)
|
|
|
channel = request_dict.get('channel', None)
|
|
|
- if not did or not channel:
|
|
|
+ # 目录开始第一个
|
|
|
+ # marker = request_dict.get('marker', '')
|
|
|
+ daytime = request_dict.get('daytime', None)
|
|
|
+ hour = request_dict.get('hour', None)
|
|
|
+ if not did or not channel or not daytime:
|
|
|
return response.json(444, 'did,channel')
|
|
|
qs = Device_Info.objects.filter(userID_id=userID, id=did).values("UID")
|
|
|
if not qs.exists():
|
|
@@ -252,11 +250,23 @@ class CloudVodView(View):
|
|
|
auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
|
bucket = oss2.Bucket(auth, OSS_BUCKET_ENDPOINT, bucket_name)
|
|
|
vod_play_list = []
|
|
|
- for obj in oss2.ObjectIterator(bucket=bucket, prefix='FTSLL8HM437Z38WU111A/vod4/', delimiter='/', max_keys=1):
|
|
|
+ prefix = '{uid}/vod{channel}/{daytime}/'.format(uid=uid, channel=channel, daytime=daytime, hour=hour)
|
|
|
+
|
|
|
+ for obj in oss2.ObjectIterator(bucket=bucket, prefix=prefix, delimiter='/', max_keys=2):
|
|
|
# 通过is_prefix方法判断obj是否为文件夹。
|
|
|
if obj.is_prefix(): # 文件夹
|
|
|
print('directory: ' + obj.key)
|
|
|
- vod_play_list.append(obj.key)
|
|
|
+ ptime = obj.key.split('/')[3]
|
|
|
+ url = bucket.sign_url('GET', '{prefix}{name}.m3u8'.format(prefix=obj.key, name=ptime), 60 * 60,params={'x-oss-process': 'hls/sign'})
|
|
|
+ # url = bucket.sign_url('GET', obj.key, 60 * 60,params={'x-oss-process': 'hls/sign'})
|
|
|
+ urllst = url.split('?')
|
|
|
+ url_start = urllib.parse.unquote(urllst[0])
|
|
|
+ url_end = urllst[1]
|
|
|
+ vod_play_url = '{url_start}?{url_end}'.format(url_start=url_start, url_end=url_end)
|
|
|
+ vod_play_list.append({
|
|
|
+ 'name': ptime,
|
|
|
+ 'sign_url': vod_play_url
|
|
|
+ })
|
|
|
else: # 文件
|
|
|
pass
|
|
|
print('file: ' + obj.key)
|