|
@@ -207,7 +207,7 @@ class CloudStorageView(View):
|
|
|
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")
|
|
|
if not vh_qs.exists():
|
|
|
- return response.json(11,'不存在')
|
|
|
+ return response.json(11,'不存在.')
|
|
|
sec = vh_qs[0]['sec']
|
|
|
fg = vh_qs[0]['fg']
|
|
|
bucket__region = vh_qs[0]['bucket__region']
|
|
@@ -226,23 +226,44 @@ class CloudStorageView(View):
|
|
|
'''
|
|
|
conn = session.client('s3')
|
|
|
playlist_entries = []
|
|
|
- for i in range(fg):
|
|
|
- thumbspng = '{uid}/vod{channel}/{time}/ts{i}.ts'. \
|
|
|
- format(uid=uid, channel=channel, time=storeTime, i=i)
|
|
|
- response_url = conn.generate_presigned_url(
|
|
|
- 'get_object',
|
|
|
- Params={
|
|
|
- 'Bucket': bucket_name,
|
|
|
- 'Key': thumbspng
|
|
|
- },
|
|
|
- ExpiresIn=3600
|
|
|
- )
|
|
|
- # m3u8 = '{uid}/vod{channel}/{time}/{time}.m3u8'. \
|
|
|
- # format(uid=uid, channel=channel, time=vod['time'])
|
|
|
- playlist_entries.append({
|
|
|
- 'name': response_url,
|
|
|
- 'duration': 10,
|
|
|
- })
|
|
|
+ # for i in range(fg):
|
|
|
+ # thumbspng = '{uid}/vod{channel}/{time}/ts{i}.ts'. \
|
|
|
+ # format(uid=uid, channel=channel, time=storeTime, i=i)
|
|
|
+ # response_url = conn.generate_presigned_url(
|
|
|
+ # 'get_object',
|
|
|
+ # Params={
|
|
|
+ # 'Bucket': bucket_name,
|
|
|
+ # 'Key': thumbspng
|
|
|
+ # },
|
|
|
+ # ExpiresIn=3600
|
|
|
+ # )
|
|
|
+ # # m3u8 = '{uid}/vod{channel}/{time}/{time}.m3u8'. \
|
|
|
+ # # format(uid=uid, channel=channel, time=vod['time'])
|
|
|
+ # playlist_entries.append({
|
|
|
+ # 'name': response_url,
|
|
|
+ # 'duration': sec,
|
|
|
+ # })
|
|
|
+ for i in range(7):
|
|
|
+ shift = (i+1)*4
|
|
|
+ duration = (fg >> shift) & 0xf
|
|
|
+ if duration > 0:
|
|
|
+ tsFile = '{uid}/vod{channel}/{time}/ts{i}.ts'. \
|
|
|
+ format(uid=uid, channel=channel, time=storeTime, i=i)
|
|
|
+ response_url = conn.generate_presigned_url(
|
|
|
+ 'get_object',
|
|
|
+ Params={
|
|
|
+ 'Bucket': bucket_name,
|
|
|
+ 'Key': tsFile
|
|
|
+ },
|
|
|
+ ExpiresIn=3600
|
|
|
+ )
|
|
|
+ # m3u8 = '{uid}/vod{channel}/{time}/{time}.m3u8'. \
|
|
|
+ # format(uid=uid, channel=channel, time=vod['time'])
|
|
|
+ playlist_entries.append({
|
|
|
+ 'name': response_url,
|
|
|
+ 'duration': duration,
|
|
|
+ })
|
|
|
+
|
|
|
playlist = PlaylistGenerator(playlist_entries).generate()
|
|
|
response = HttpResponse(playlist)
|
|
|
response['Content-Type'] = 'application/octet-stream'
|
|
@@ -411,18 +432,18 @@ class CloudStorageView(View):
|
|
|
endTime = int(request_dict.get('endTime', None))
|
|
|
uid = request_dict.get('uid', None)
|
|
|
channel = request_dict.get('channel', None)
|
|
|
+
|
|
|
+ print('开始时间--%d' %(time.time()*1000))
|
|
|
dv_qs = Device_Info.objects.filter(UID=uid, userID_id=userID, isShare=False)
|
|
|
if not dv_qs.exists():
|
|
|
return response.json(12)
|
|
|
now_time = int(time.time())
|
|
|
+
|
|
|
vh_qs = VodHlsModel.objects.filter\
|
|
|
- (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")
|
|
|
vod_play_list = []
|
|
|
- print("-------------vh_qs")
|
|
|
- print(vh_qs)
|
|
|
auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
|
- print('--------------bigin')
|
|
|
print(int(time.time()))
|
|
|
for vod in vh_qs:
|
|
|
bucket__mold = vod["bucket__mold"]
|
|
@@ -453,7 +474,7 @@ class CloudStorageView(View):
|
|
|
# region_name=bucket__region
|
|
|
# )
|
|
|
# conn = session.client('s3')
|
|
|
- # thumbspng = '{uid}/vod{channel}/{time}/thumbs.jpg'. \
|
|
|
+ # thumbspng = '{uid}/vod{channel}/{time}/Thumb.jpeg'. \
|
|
|
# format(uid=uid, channel=channel, time=vod['time'])
|
|
|
# response_url = conn.generate_presigned_url(
|
|
|
# 'get_object',
|
|
@@ -464,18 +485,15 @@ class CloudStorageView(View):
|
|
|
# ExpiresIn=3600
|
|
|
# )
|
|
|
# thumb_url = response_url
|
|
|
- # m3u8 = '{uid}/vod{channel}/{time}/{time}.m3u8'. \
|
|
|
- # format(uid=uid, channel=channel, time=vod['time'])
|
|
|
- vod_url = 'http://test.dvema.com/cloudstorage/signplaym3u8?' \
|
|
|
+ vod_url = '{server_domain}/cloudstorage/signplaym3u8?' \
|
|
|
'uid={uid}&channel={channel}&time={time}&sign=tktktktk'. \
|
|
|
- format(uid=uid, channel=channel, time=vod['time'])
|
|
|
+ format(server_domain=SERVER_DOMAIN,uid=uid, channel=channel, time=vod['time'])
|
|
|
vod_play_list.append({
|
|
|
'name': vod['time'],
|
|
|
'sign_url': vod_url,
|
|
|
# 'thumb': thumb_url,
|
|
|
'sec': vod['sec']})
|
|
|
- print('--------------end')
|
|
|
- print(int(time.time()))
|
|
|
+ print('结束时间--%d' %(time.time()*1000))
|
|
|
return response.json(0, vod_play_list)
|
|
|
|
|
|
def do_store_playlist(self, request_dict, response):
|
|
@@ -875,7 +893,7 @@ class CloudStorageView(View):
|
|
|
pay_type = int(request_dict.get('pay_type', None))
|
|
|
rank = request_dict.get('rank', None)
|
|
|
|
|
|
- if uid == None or channel == None or commodity_code == None or pay_type == None or rank == None:
|
|
|
+ if not uid or not channel or not commodity_code or not rank:
|
|
|
return response.json(13, '参数有误.')
|
|
|
dv_qs = Device_Info.objects.filter(userID_id=userID, UID=uid, isShare=False, isExist=1)
|
|
|
if not dv_qs.exists():
|