|
@@ -107,7 +107,7 @@ class CloudVodView(View):
|
|
elif operation == 'details':
|
|
elif operation == 'details':
|
|
return self.do_meal_details(request_dict, userID, response)
|
|
return self.do_meal_details(request_dict, userID, response)
|
|
elif operation == 'playlist':
|
|
elif operation == 'playlist':
|
|
- return self.do_get_playlist(request_dict,userID,response)
|
|
|
|
|
|
+ return self.do_get_playlist(request_dict, userID, response)
|
|
else:
|
|
else:
|
|
return response.json(414)
|
|
return response.json(414)
|
|
|
|
|
|
@@ -134,7 +134,7 @@ class CloudVodView(View):
|
|
orderID = CommonService.createID()
|
|
orderID = CommonService.createID()
|
|
smqs = Store_Meal.objects.filter(id=rank).values("currency", "price", "content")
|
|
smqs = Store_Meal.objects.filter(id=rank).values("currency", "price", "content")
|
|
if not smqs.exists():
|
|
if not smqs.exists():
|
|
- return response.json(10,'套餐不存在')
|
|
|
|
|
|
+ return response.json(10, '套餐不存在')
|
|
currency = smqs[0]['currency']
|
|
currency = smqs[0]['currency']
|
|
price = smqs[0]['price']
|
|
price = smqs[0]['price']
|
|
content = smqs[0]['content']
|
|
content = smqs[0]['content']
|
|
@@ -294,10 +294,10 @@ class CloudVodView(View):
|
|
if not qs.exists():
|
|
if not qs.exists():
|
|
return response.json(13)
|
|
return response.json(13)
|
|
uid = qs[0]['UID']
|
|
uid = qs[0]['UID']
|
|
- dm_qs = Device_Meal.objects.filter(uid=uid, channel=channel)\
|
|
|
|
- .values('rank__bucket__bucket', 'end_time','rank__bucket__endpoint')
|
|
|
|
|
|
+ dm_qs = Device_Meal.objects.filter(uid=uid, channel=channel) \
|
|
|
|
+ .values('rank__bucket__bucket', 'end_time', 'rank__bucket__endpoint')
|
|
if not dm_qs.exists():
|
|
if not dm_qs.exists():
|
|
- return response.json(10,'未购买')
|
|
|
|
|
|
+ return response.json(10, '未购买')
|
|
now_time = timezone.localtime(timezone.now())
|
|
now_time = timezone.localtime(timezone.now())
|
|
if now_time > dm_qs[0]['end_time']:
|
|
if now_time > dm_qs[0]['end_time']:
|
|
return response.json(10, '已过期')
|
|
return response.json(10, '已过期')
|
|
@@ -323,9 +323,9 @@ class CloudVodView(View):
|
|
vod_play_url = '{url_start}?{url_end}'.format(url_start=url_start, url_end=url_end)
|
|
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)
|
|
thumb_key = '{prefix}ts0.ts'.format(prefix=obj.key)
|
|
print(thumb_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})
|
|
|
|
|
|
+ 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})
|
|
else: # 文件
|
|
else: # 文件
|
|
pass
|
|
pass
|
|
# print('file: ' + obj.key)
|
|
# print('file: ' + obj.key)
|
|
@@ -429,7 +429,10 @@ class CloudVodView(View):
|
|
# stime = request_dict.get('stime', None)
|
|
# stime = request_dict.get('stime', None)
|
|
# etime = request_dict.get('etime', None)
|
|
# etime = request_dict.get('etime', None)
|
|
daytime = request_dict.get('daytime', None)
|
|
daytime = request_dict.get('daytime', None)
|
|
- daytime = int(daytime)
|
|
|
|
|
|
+
|
|
|
|
+ timeArray = time.strptime(daytime, "%Y%m%d%H")
|
|
|
|
+ startTime = time.mktime(timeArray)
|
|
|
|
+ endTime = startTime + 3600
|
|
|
|
|
|
did = request_dict.get('did', None)
|
|
did = request_dict.get('did', None)
|
|
channel = request_dict.get('channel', None)
|
|
channel = request_dict.get('channel', None)
|
|
@@ -440,4 +443,26 @@ class CloudVodView(View):
|
|
qs = Device_Meal.objects.filter(uid=UID, channel=channel, status=1).values("rank", "channel")
|
|
qs = Device_Meal.objects.filter(uid=UID, channel=channel, status=1).values("rank", "channel")
|
|
if not qs.exists():
|
|
if not qs.exists():
|
|
return response.json(10, '设备未购买')
|
|
return response.json(10, '设备未购买')
|
|
- return response.json(0)
|
|
|
|
|
|
+ nowTime = time.time()
|
|
|
|
+ vodqs = VodHlsModel.objects.filter(uid=UID, channel=channel, time__range=(startTime, endTime),
|
|
|
|
+ endTime__gte=nowTime) \
|
|
|
|
+ .values("time", "sec", "bucket__bucket", "bucket__endpoint", "bucket__region")
|
|
|
|
+ vod_play_list = []
|
|
|
|
+ print(vodqs)
|
|
|
|
+ for vod in vodqs:
|
|
|
|
+ bucket_name = vod["bucket__bucket"]
|
|
|
|
+ endpoint = vod["bucket__endpoint"]
|
|
|
|
+ auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
|
|
+ bucket = oss2.Bucket(auth, endpoint, bucket_name)
|
|
|
|
+ m3u8 = '{uid}/vod{channel}/{daytime}/{time}/{time}.m3u8'. \
|
|
|
|
+ format(uid=UID, channel=channel, daytime=daytime, time=vod['time'])
|
|
|
|
+ ts = '{uid}/vod{channel}/{daytime}/{time}/ts0.ts'.format(uid=UID, channel=channel, daytime=daytime,time=vod['time'])
|
|
|
|
+ url = bucket.sign_url('GET', m3u8, 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 = bucket.sign_url('GET', ts, 3600,
|
|
|
|
+ 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})
|
|
|
|
+ return response.json(0, vod_play_list)
|