|
@@ -111,6 +111,8 @@ class CloudVodView(View):
|
|
return self.do_get_playlist(request_dict, userID, response)
|
|
return self.do_get_playlist(request_dict, userID, response)
|
|
elif operation == 'details':
|
|
elif operation == 'details':
|
|
return self.do_get_details(request_dict, response)
|
|
return self.do_get_details(request_dict, response)
|
|
|
|
+ elif operation == 'queryVod':
|
|
|
|
+ return self.do_query_vod(request_dict,userID, response)
|
|
else:
|
|
else:
|
|
return response.json(414)
|
|
return response.json(414)
|
|
|
|
|
|
@@ -560,3 +562,43 @@ class CloudVodView(View):
|
|
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)
|
|
return response.json(0, vod_play_list)
|
|
|
|
+
|
|
|
|
+ def do_query_vod(self, request_dict, userID, response):
|
|
|
|
+ page = request_dict.get('page', None)
|
|
|
|
+ line = request_dict.get('line', None)
|
|
|
|
+ did = request_dict.get('did', None)
|
|
|
|
+ channel = request_dict.get('channel', None)
|
|
|
|
+ dvqs = Device_Info.objects.filter(id=did, userID_id=userID, isShare=False).values("UID")
|
|
|
|
+ if not dvqs.exists():
|
|
|
|
+ return response.json(12)
|
|
|
|
+ UID = dvqs[0]["UID"]
|
|
|
|
+ ubqs = UID_Bucket.objects.filter(uid=UID, channel=channel).values('status')
|
|
|
|
+ if not ubqs.exists():
|
|
|
|
+ return response.json(10, '设备未购买')
|
|
|
|
+ nowTime = CommonService.get_utc()
|
|
|
|
+ vodqs = VodHlsModel.objects.filter(uid=UID, channel=channel, endTime__gte=nowTime) \
|
|
|
|
+ .values("time", "sec", "bucket__bucket", "bucket__endpoint", "bucket__region")
|
|
|
|
+ vod_play_list = []
|
|
|
|
+ # print(vodqs)
|
|
|
|
+ page = int(page)
|
|
|
|
+ line = int(line)
|
|
|
|
+ for vod in vodqs[(page - 1) * line:page * line]:
|
|
|
|
+ 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)
|
|
|
|
+ daytime = time.strftime("%Y%m%d%H", time.localtime(vod['time']))
|
|
|
|
+ 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, 'sec': vod['sec']})
|
|
|
|
+ return response.json(0, vod_play_list)
|