|
@@ -430,13 +430,13 @@ 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']
|
|
- ubqs = UID_Bucket.objects.filter(uid=uid, channel=channel) \
|
|
|
|
|
|
+ now_time = CommonService.get_utc()
|
|
|
|
+ ubqs = UID_Bucket.objects.filter(uid=uid, channel=channel, endTime__gte=now_time) \
|
|
.values('endTime', 'bucket__bucket', 'bucket__endpoint')
|
|
.values('endTime', 'bucket__bucket', 'bucket__endpoint')
|
|
if not ubqs.exists():
|
|
if not ubqs.exists():
|
|
- return response.json(10, '未购买')
|
|
|
|
- now_time = time.time()
|
|
|
|
- if now_time > ubqs[0]['endTime']:
|
|
|
|
- return response.json(10, '已过期')
|
|
|
|
|
|
+ return response.json(10, '未购买或过期')
|
|
|
|
+ # if now_time > ubqs[0]['endTime']:
|
|
|
|
+ # return response.json(10, '已过期')
|
|
if not ubqs.exists():
|
|
if not ubqs.exists():
|
|
return response.json(10, '未开通云存储')
|
|
return response.json(10, '未开通云存储')
|
|
bucket_name = ubqs[0]["bucket__bucket"]
|
|
bucket_name = ubqs[0]["bucket__bucket"]
|
|
@@ -461,7 +461,7 @@ class CloudVodView(View):
|
|
print(thumb_key)
|
|
print(thumb_key)
|
|
thumb = bucket.sign_url('GET', thumb_key, 3600,
|
|
thumb = bucket.sign_url('GET', thumb_key, 3600,
|
|
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': ptime, 'sign_url': vod_play_url, 'thumb': thumb,'sec':0})
|
|
|
|
|
|
+ vod_play_list.append({'name': ptime, 'sign_url': vod_play_url, 'thumb': thumb, 'sec': 0})
|
|
else: # 文件
|
|
else: # 文件
|
|
pass
|
|
pass
|
|
# print('file: ' + obj.key)
|
|
# print('file: ' + obj.key)
|
|
@@ -520,7 +520,7 @@ class CloudVodView(View):
|
|
upgrade_storeDay = int(smqs[0]['bucket__storeDay'])
|
|
upgrade_storeDay = int(smqs[0]['bucket__storeDay'])
|
|
ctcTime = ubqs[0]['endTime'] - nowTime
|
|
ctcTime = ubqs[0]['endTime'] - nowTime
|
|
multiple = math.ceil(upgrade_storeDay / origin_storeDay)
|
|
multiple = math.ceil(upgrade_storeDay / origin_storeDay)
|
|
- ubqs.update(endTime=ctcTime / multiple + addTime + ubqs[0]['endTime'],bucket_id=bucketId)
|
|
|
|
|
|
+ ubqs.update(endTime=ctcTime / multiple + addTime + ubqs[0]['endTime'], bucket_id=bucketId)
|
|
# 新增模式
|
|
# 新增模式
|
|
else:
|
|
else:
|
|
print('create')
|
|
print('create')
|
|
@@ -574,11 +574,12 @@ class CloudVodView(View):
|
|
channel = utko.channel
|
|
channel = utko.channel
|
|
print(channel)
|
|
print(channel)
|
|
print(UID)
|
|
print(UID)
|
|
- qs = UID_Bucket.objects.filter(uid=UID, channel=channel, status=1).values("channel", "bucket__storeDay",
|
|
|
|
- "bucket_id")
|
|
|
|
|
|
+ nowTime = CommonService.get_utc()
|
|
|
|
+ qs = UID_Bucket.objects.filter(uid=UID, channel=channel, status=1, endTime__gte=nowTime). \
|
|
|
|
+ values("channel", "bucket__storeDay", "bucket_id")
|
|
if not qs.exists():
|
|
if not qs.exists():
|
|
- return response.json(10, '设备未购买')
|
|
|
|
- # nowTime = time.time()
|
|
|
|
|
|
+ res = {'code': 404, 'msg': '设备未购买'}
|
|
|
|
+ return HttpResponse(json.dumps(res, ensure_ascii=False), content_type="application/json,charset=utf-8")
|
|
storeDay = qs[0]['bucket__storeDay']
|
|
storeDay = qs[0]['bucket__storeDay']
|
|
bucketID = qs[0]['bucket_id']
|
|
bucketID = qs[0]['bucket_id']
|
|
endTime = int(storeTime) + storeDay * 86400
|
|
endTime = int(storeTime) + storeDay * 86400
|
|
@@ -604,7 +605,7 @@ class CloudVodView(View):
|
|
ubqs = UID_Bucket.objects.filter(uid=UID, channel=channel).values('status')
|
|
ubqs = UID_Bucket.objects.filter(uid=UID, channel=channel).values('status')
|
|
if not ubqs.exists():
|
|
if not ubqs.exists():
|
|
return response.json(10, '设备未购买')
|
|
return response.json(10, '设备未购买')
|
|
- nowTime = time.time()
|
|
|
|
|
|
+ nowTime = CommonService.get_utc()
|
|
vodqs = VodHlsModel.objects.filter(uid=UID, channel=channel, time__range=(startTime, endTime),
|
|
vodqs = VodHlsModel.objects.filter(uid=UID, channel=channel, time__range=(startTime, endTime),
|
|
endTime__gte=nowTime) \
|
|
endTime__gte=nowTime) \
|
|
.values("time", "sec", "bucket__bucket", "bucket__endpoint", "bucket__region")
|
|
.values("time", "sec", "bucket__bucket", "bucket__endpoint", "bucket__region")
|
|
@@ -617,19 +618,15 @@ class CloudVodView(View):
|
|
bucket = oss2.Bucket(auth, endpoint, bucket_name)
|
|
bucket = oss2.Bucket(auth, endpoint, bucket_name)
|
|
m3u8 = '{uid}/vod{channel}/{daytime}/{time}/{time}.m3u8'. \
|
|
m3u8 = '{uid}/vod{channel}/{daytime}/{time}/{time}.m3u8'. \
|
|
format(uid=UID, channel=channel, daytime=daytime, time=vod['time'])
|
|
format(uid=UID, channel=channel, daytime=daytime, time=vod['time'])
|
|
- ts = '{uid}/vod{channel}/{daytime}/{time}/ts0.ts'.\
|
|
|
|
|
|
+ ts = '{uid}/vod{channel}/{daytime}/{time}/ts0.ts'. \
|
|
format(uid=UID, channel=channel, daytime=daytime, time=vod['time'])
|
|
format(uid=UID, channel=channel, daytime=daytime, time=vod['time'])
|
|
url = bucket.sign_url('GET', m3u8, 3600, params={'x-oss-process': 'hls/sign'})
|
|
url = bucket.sign_url('GET', m3u8, 3600, params={'x-oss-process': 'hls/sign'})
|
|
urllst = url.split('?')
|
|
urllst = url.split('?')
|
|
url_start = urllib.parse.unquote(urllst[0])
|
|
url_start = urllib.parse.unquote(urllst[0])
|
|
url_end = urllst[1]
|
|
url_end = urllst[1]
|
|
- vod_play_url = '{url_start}?{url_end}'.\
|
|
|
|
|
|
+ vod_play_url = '{url_start}?{url_end}'. \
|
|
format(url_start=url_start, url_end=url_end)
|
|
format(url_start=url_start, url_end=url_end)
|
|
thumb = bucket.sign_url('GET', ts, 3600,
|
|
thumb = bucket.sign_url('GET', ts, 3600,
|
|
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']})
|
|
- return response.json(0, vod_play_list)
|
|
|
|
-
|
|
|
|
- def do_filter_playlist(self,request_dict,userID,response):
|
|
|
|
-
|
|
|
|
- return
|
|
|
|
|
|
+ return response.json(0, vod_play_list)
|