Browse Source

推送列表不显示无图片

peng 1 year ago
parent
commit
ece9ad0dbf
1 changed files with 56 additions and 32 deletions
  1. 56 32
      Controller/DetectControllerV2.py

+ 56 - 32
Controller/DetectControllerV2.py

@@ -376,19 +376,27 @@ class DetectControllerViewV2(View):
                         else:
                             continue
                     elif region == 2 and storage_location == 2:  # 2:国内,aws
-                        response_url = aws_s3_guonei.generate_presigned_url('get_object',
-                                                                            Params={'Bucket': 'push', 'Key': thumbspng},
-                                                                            ExpiresIn=300)
-                        p['img'] = response_url
-                        p['img_list'] = [response_url]
+                        try:
+                            aws_s3_guonei.get_object(Bucket='push', Key=thumbspng)
+                            response_url = aws_s3_guonei.generate_presigned_url('get_object',
+                                                                                Params={'Bucket': 'push',
+                                                                                        'Key': thumbspng},
+                                                                                ExpiresIn=300)
+                            p['img'] = response_url
+                            p['img_list'] = [response_url]
+                        except aws_s3_guonei.exceptions.NoSuchKey:
+                            continue
                     elif region == 1 and storage_location == 2:  # 1:国外,aws
-                        response_url = aws_s3_guowai.generate_presigned_url('get_object',
-                                                                            Params={'Bucket': 'foreignpush',
-                                                                                    'Key': thumbspng},
-                                                                            ExpiresIn=300)
-                        p['img'] = response_url
-                        p['img_list'] = [response_url]
-
+                        try:
+                            aws_s3_guowai.get_object(Bucket='foreignpush', Key=thumbspng)
+                            response_url = aws_s3_guowai.generate_presigned_url('get_object',
+                                                                                Params={'Bucket': 'foreignpush',
+                                                                                        'Key': thumbspng},
+                                                                                ExpiresIn=300)
+                            p['img'] = response_url
+                            p['img_list'] = [response_url]
+                        except aws_s3_guowai.exceptions.NoSuchKey:
+                            continue
                 elif p['is_st'] == 2:
                     # 列表装载回放时间戳标记
                     split_vod_hls_obj = SplitVodHlsObject()
@@ -418,15 +426,23 @@ class DetectControllerViewV2(View):
                         else:
                             continue
                     elif region == 2 and storage_location == 2:  # 2:国内,aws
-                        thumb = aws_s3_guonei.generate_presigned_url('get_object',
-                                                                     Params={'Bucket': 'push', 'Key': ts},
-                                                                     ExpiresIn=3600)
-                        p['img_list'] = [thumb]
+                        try:
+                            aws_s3_guonei.get_object(Bucket='push', Key=ts)
+                            thumb = aws_s3_guonei.generate_presigned_url('get_object',
+                                                                         Params={'Bucket': 'push', 'Key': ts},
+                                                                         ExpiresIn=3600)
+                            p['img_list'] = [thumb]
+                        except aws_s3_guonei.exceptions.NoSuchKey:
+                            continue
                     elif region == 1 and storage_location == 2:  # 1:国外,aws
-                        thumb = aws_s3_guowai.generate_presigned_url('get_object',
-                                                                     Params={'Bucket': 'foreignpush', 'Key': ts},
-                                                                     ExpiresIn=3600)
-                        p['img_list'] = [thumb]
+                        try:
+                            aws_s3_guowai.get_object(Bucket='foreignpush', Key=ts)
+                            thumb = aws_s3_guowai.generate_presigned_url('get_object',
+                                                                         Params={'Bucket': 'foreignpush', 'Key': ts},
+                                                                         ExpiresIn=3600)
+                            p['img_list'] = [thumb]
+                        except aws_s3_guowai.exceptions.NoSuchKey:
+                            continue
                 elif p['is_st'] == 3 or p['is_st'] == 4:
                     # 列表装载回放时间戳标记
                     p['img_list'] = []
@@ -441,19 +457,27 @@ class DetectControllerViewV2(View):
                             else:
                                 break
                         elif region == 2 and storage_location == 2:  # 2:国内,aws
-                            response_url = aws_s3_guonei.generate_presigned_url('get_object',
-                                                                                Params={'Bucket': 'push',
-                                                                                        'Key': thumbspng},
-                                                                                ExpiresIn=300)
-                            img = response_url
-                            p['img_list'].append(img)
+                            try:
+                                aws_s3_guonei.get_object(Bucket='push', Key=thumbspng)
+                                response_url = aws_s3_guonei.generate_presigned_url('get_object',
+                                                                                    Params={'Bucket': 'push',
+                                                                                            'Key': thumbspng},
+                                                                                    ExpiresIn=300)
+                                img = response_url
+                                p['img_list'].append(img)
+                            except aws_s3_guonei.exceptions.NoSuchKey:
+                                break
                         elif region == 1 and storage_location == 2:  # 1:国外,aws
-                            response_url = aws_s3_guowai.generate_presigned_url('get_object',
-                                                                                Params={'Bucket': 'foreignpush',
-                                                                                        'Key': thumbspng},
-                                                                                ExpiresIn=300)
-                            img = response_url
-                            p['img_list'].append(img)
+                            try:
+                                aws_s3_guowai.get_object(Bucket='foreignpush', Key=thumbspng)
+                                response_url = aws_s3_guowai.generate_presigned_url('get_object',
+                                                                                    Params={'Bucket': 'foreignpush',
+                                                                                            'Key': thumbspng},
+                                                                                    ExpiresIn=300)
+                                img = response_url
+                                p['img_list'].append(img)
+                            except aws_s3_guowai.exceptions.NoSuchKey:
+                                break
                     if not p['img_list']:
                         continue
                 if devUid in uid_type_dict.keys():