|
@@ -346,54 +346,54 @@ class CloudVodView(View):
|
|
|
OssCrdModel.objects.create(uid=UID, channel=channel, data=json.dumps(res), addTime=now_time_stamp)
|
|
|
return JsonResponse(status=200, data=res)
|
|
|
|
|
|
- # 获取设备回放列表
|
|
|
- def do_get_hls_list(self, request_dict, userID, response):
|
|
|
- did = request_dict.get('did', None)
|
|
|
- channel = request_dict.get('channel', None)
|
|
|
- # 目录开始第一个
|
|
|
- # 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, isShare=False).values("UID")
|
|
|
- if not qs.exists():
|
|
|
- return response.json(12)
|
|
|
- uid = qs[0]['UID']
|
|
|
- now_time = CommonService.get_utc()
|
|
|
- ubqs = UID_Bucket.objects.filter(uid=uid, channel=channel, endTime__gte=now_time) \
|
|
|
- .values('endTime', 'bucket__bucket', 'bucket__endpoint')
|
|
|
- if not ubqs.exists():
|
|
|
- return response.json(10, '未购买或过期')
|
|
|
- if not ubqs.exists():
|
|
|
- return response.json(10, '未开通云存储')
|
|
|
- bucket_name = ubqs[0]["bucket__bucket"]
|
|
|
- endpoint = ubqs[0]["bucket__endpoint"]
|
|
|
- auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
|
- bucket = oss2.Bucket(auth, endpoint, bucket_name)
|
|
|
- vod_play_list = []
|
|
|
- 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)
|
|
|
- ptime = obj.key.split('/')[3]
|
|
|
- url = bucket.sign_url('GET', '{prefix}{name}.m3u8'.format(prefix=obj.key, name=ptime), 3600,
|
|
|
- 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)
|
|
|
- thumb_key = '{prefix}ts0.ts'.format(prefix=obj.key)
|
|
|
- print(thumb_key)
|
|
|
- thumb = bucket.sign_url('GET', thumb_key, 3600,
|
|
|
- params={'x-oss-process': 'video/snapshot,t_10000,m_fast,w_300'})
|
|
|
- vod_play_list.append({'name': ptime, 'sign_url': vod_play_url, 'thumb': thumb, 'sec': 0})
|
|
|
- else: # 文件
|
|
|
- pass
|
|
|
- # print('file: ' + obj.key)
|
|
|
- return response.json(0, vod_play_list)
|
|
|
+ # # 获取设备回放列表
|
|
|
+ # def do_get_hls_list(self, request_dict, userID, response):
|
|
|
+ # did = request_dict.get('did', None)
|
|
|
+ # channel = request_dict.get('channel', None)
|
|
|
+ # # 目录开始第一个
|
|
|
+ # # 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, isShare=False).values("UID")
|
|
|
+ # if not qs.exists():
|
|
|
+ # return response.json(12)
|
|
|
+ # uid = qs[0]['UID']
|
|
|
+ # now_time = CommonService.get_utc()
|
|
|
+ # ubqs = UID_Bucket.objects.filter(uid=uid, channel=channel, endTime__gte=now_time) \
|
|
|
+ # .values('endTime', 'bucket__bucket', 'bucket__endpoint')
|
|
|
+ # if not ubqs.exists():
|
|
|
+ # return response.json(10, '未购买或过期')
|
|
|
+ # if not ubqs.exists():
|
|
|
+ # return response.json(10, '未开通云存储')
|
|
|
+ # bucket_name = ubqs[0]["bucket__bucket"]
|
|
|
+ # endpoint = ubqs[0]["bucket__endpoint"]
|
|
|
+ # auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
|
+ # bucket = oss2.Bucket(auth, endpoint, bucket_name)
|
|
|
+ # vod_play_list = []
|
|
|
+ # 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)
|
|
|
+ # ptime = obj.key.split('/')[3]
|
|
|
+ # url = bucket.sign_url('GET', '{prefix}{name}.m3u8'.format(prefix=obj.key, name=ptime), 3600,
|
|
|
+ # 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)
|
|
|
+ # thumb_key = '{prefix}ts0.ts'.format(prefix=obj.key)
|
|
|
+ # print(thumb_key)
|
|
|
+ # thumb = bucket.sign_url('GET', thumb_key, 3600,
|
|
|
+ # params={'x-oss-process': 'video/snapshot,t_10000,m_fast,w_300'})
|
|
|
+ # vod_play_list.append({'name': ptime, 'sign_url': vod_play_url, 'thumb': thumb, 'sec': 0})
|
|
|
+ # else: # 文件
|
|
|
+ # pass
|
|
|
+ # # print('file: ' + obj.key)
|
|
|
+ # return response.json(0, vod_play_list)
|
|
|
|
|
|
def do_paypal_execute(self, request_dict, response):
|
|
|
paymentId = request_dict.get('paymentId', None)
|