Forráskód Böngészése

Merge branch 'dev' into test

# Conflicts:
#	Controller/CloudStorage.py
Ansjer 4 éve
szülő
commit
2df9c1b283
1 módosított fájl, 12 hozzáadás és 9 törlés
  1. 12 9
      Controller/CloudStorage.py

+ 12 - 9
Controller/CloudStorage.py

@@ -206,8 +206,7 @@ class CloudStorageView(View):
         now_time = int(time.time())
         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,'不存在.')
+        if not vh_qs.exists():            return response.json(11,'不存在.')
         sec = vh_qs[0]['sec']
         fg = vh_qs[0]['fg']
         bucket__region = vh_qs[0]['bucket__region']
@@ -433,17 +432,16 @@ class CloudStorageView(View):
         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\
+        vh_qs = VodHlsModel.objects.filter \
             ( uid=uid, channel=channel, time__range=(startTime, endTime), endTime__gte=now_time). \
-            values("time", "sec", "bucket__bucket", "bucket__endpoint", "bucket__region", "bucket__mold")
+            values("time", "sec", "bucket__bucket", "fg", "bucket__endpoint", "bucket__region", "bucket__mold")
         vod_play_list = []
-        auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
+
+
         print(int(time.time()))
         for vod in vh_qs:
             bucket__mold = vod["bucket__mold"]
@@ -451,6 +449,7 @@ class CloudStorageView(View):
             endpoint = vod["bucket__endpoint"]
             bucket__region = vod["bucket__region"]
             if bucket__mold == 0:
+                auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
                 bucket = oss2.Bucket(auth, endpoint, bucket_name)
                 m3u8 = '{uid}/vod{channel}/{time}/{time}.m3u8'. \
                     format(uid=uid, channel=channel, time=vod['time'])
@@ -474,6 +473,7 @@ class CloudStorageView(View):
                 #     region_name=bucket__region
                 # )
                 # conn = session.client('s3')
+
                 # thumbspng = '{uid}/vod{channel}/{time}/Thumb.jpeg'. \
                 #     format(uid=uid, channel=channel, time=vod['time'])
                 # response_url = conn.generate_presigned_url(
@@ -485,15 +485,18 @@ class CloudStorageView(View):
                 #     ExpiresIn=3600
                 # )
                 # thumb_url = response_url
+                #     format(uid=uid, channel=channel, time=vod['time'])
+
                 vod_url = '{server_domain}/cloudstorage/signplaym3u8?' \
                           'uid={uid}&channel={channel}&time={time}&sign=tktktktk'. \
                     format(server_domain=SERVER_DOMAIN,uid=uid, channel=channel, time=vod['time'])
+                ts_num = vod['fg'] & 0xf
                 vod_play_list.append({
                     'name': vod['time'],
                     'sign_url': vod_url,
                     # 'thumb': thumb_url,
-                    'sec': vod['sec']})
-        print('结束时间--%d' %(time.time()*1000))
+                    'sec': vod['sec'],
+                    'ts_num' : ts_num}),
         return response.json(0, vod_play_list)
 
     def do_store_playlist(self, request_dict, response):