chenjunkai 6 年之前
父節點
當前提交
1e0051dd7c
共有 2 個文件被更改,包括 4 次插入56 次删除
  1. 3 54
      Controller/CloudVod.py
  2. 1 2
      Service/TemplateService.py

+ 3 - 54
Controller/CloudVod.py

@@ -101,19 +101,16 @@ class CloudVodView(View):
             if tko.code != 0:
                 return response.json(tko.code)
             userID = tko.userID
-            if operation == 'getHlsList':
-                return self.do_get_playlist(request_dict, userID, response)
-                # return self.do_get_hls_list(request_dict, userID, response)
-            elif operation == 'createOrder':
+            if operation == 'createOrder':
                 return self.do_create_order(request_dict, userID, response)
             elif operation == 'status':
                 return self.do_change_status(request_dict, userID, response)
-            elif operation == 'playlist':
-                return self.do_get_playlist(request_dict, userID, response)
             elif operation == 'details':
                 return self.do_get_details(request_dict, response)
             elif operation == 'filterVod':
                 return self.do_filter_playlist(request_dict, userID, response)
+            elif operation == 'findVod':
+                return self.do_find_playlist(request_dict,userID,response)
             else:
                 return response.json(414)
 
@@ -508,54 +505,6 @@ class CloudVodView(View):
                                    sec=sec)
         return response.json(0)
 
-    def do_get_playlist(self, request_dict, userID, response):
-        # stime = request_dict.get('stime', None)
-        # etime = request_dict.get('etime', None)
-        daytime = request_dict.get('daytime', None)
-        # timeArray = time.strptime(str(int(daytime) - 8), "%Y%m%d%H")
-        timeArray = time.strptime(daytime, "%Y%m%d%H")
-        startTime = time.mktime(timeArray)
-        endTime = startTime + 3600
-
-        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 = int(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'])
-            m3u8 = '{uid}/vod{channel}/{time}/{time}.m3u8'. \
-                format(uid=UID, channel=channel, time=vod['time'])
-            ts = '{uid}/vod{channel}/{time}/ts0.ts'. \
-                format(uid=UID, channel=channel, 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)
-
     # http://test.dvema.com/cloudVod/filterVod?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySUQiOiIxNTIzNDE5MDcwMDY3ODUzMTM1MjcyNjA3MDciLCJ1c2VyIjoiMTM1MjcyNjA3MDciLCJsYW5nIjoiZW4iLCJleHAiOjE1NDg2NTU5NjR9.vuvgEJUyWA3mjVVBt2R5P9weqRmRNjWwAf_wsEG8sPk&did=138001380001548053701910104&channel=1&startTime=1&endTime=156489745645
     def do_filter_playlist(self, request_dict, userID, response):
         startTime = int(request_dict.get('startTime', None))

+ 1 - 2
Service/TemplateService.py

@@ -59,11 +59,10 @@ class TemplateService:
             'v2/account/resetPwdByCode',
             'cloudVod/createOrder',
             'cloudVod/payExecute',
-            'cloudVod/getHlsList',
             'cloudVod/status',
             'cloudVod/details',
-            'cloudVod/playlist',
             'cloudVod/filterVod',
+            'cloudVod/findVod',
         ]
         return apiList