lang 4 年 前
コミット
2357528d4e
1 ファイル変更6 行追加6 行削除
  1. 6 6
      Controller/CloudStorage.py

+ 6 - 6
Controller/CloudStorage.py

@@ -18,6 +18,7 @@ import urllib
 import boto3
 import oss2
 import paypalrestsdk
+import threading
 from aliyunsdkcore import client
 from aliyunsdksts.request.v20150401 import AssumeRoleRequest
 from boto3.session import Session
@@ -433,17 +434,14 @@ 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")
         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'])
@@ -488,12 +487,13 @@ class CloudStorageView(View):
                 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):