Pārlūkot izejas kodu

更新播放列表缩略图

lang 4 gadi atpakaļ
vecāks
revīzija
45fcb6ae8f
1 mainītis faili ar 24 papildinājumiem un 15 dzēšanām
  1. 24 15
      Controller/CloudStorage.py

+ 24 - 15
Controller/CloudStorage.py

@@ -488,12 +488,21 @@ class CloudStorageView(View):
             ( uid=uid, channel=channel, time__range=(startTime, endTime), endTime__gte=now_time). \
             values("id", "time", "sec", "bucket__bucket", "fg", "bucket__endpoint", "bucket__region", "bucket__mold")
         vod_play_list = []
-        print(int(time.time()))
+
+        aws_access_key_id = 'AKIA2E67UIMD45Y3HL53'
+        aws_secret_access_key = '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'
+        session = Session(
+            aws_access_key_id=aws_access_key_id,
+            aws_secret_access_key=aws_secret_access_key,
+            region_name=vh_qs[0]["bucket__region"]
+        )
+        conn = session.client('s3')
+
         for vod in vh_qs:
             bucket__mold = vod["bucket__mold"]
             bucket_name = vod["bucket__bucket"]
             endpoint = vod["bucket__endpoint"]
-            bucket__region = vod["bucket__region"]
+            # 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)
@@ -521,18 +530,18 @@ 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(
-                #     'get_object',
-                #     Params={
-                #         'Bucket': bucket_name,
-                #         'Key': thumbspng
-                #     },
-                #     ExpiresIn=3600
-                # )
-                # thumb_url = response_url
+
+                thumbspng = '{uid}/vod{channel}/{time}/Thumb.jpeg'. \
+                    format(uid=uid, channel=channel, time=vod['time'])
+                response_url = conn.generate_presigned_url(
+                    'get_object',
+                    Params={
+                        'Bucket': bucket_name,
+                        'Key': thumbspng
+                    },
+                    ExpiresIn=3600
+                )
+                thumb_url = response_url
 
                 vod_url = '{server_domain}/cloudstorage/signplaym3u8?' \
                           'uid={uid}&channel={channel}&time={time}&sign=tktktktk'. \
@@ -541,7 +550,7 @@ class CloudStorageView(View):
                 vod_play_list.append({
                     'name': vod['time'],
                     'sign_url': vod_url,
-                    # 'thumb': thumb_url,
+                    'thumb': thumb_url,
                     'sec': vod['sec'],
                     'ts_num' : ts_num,
                     'vod_id': vod['id']