Explorar o código

增加异常处理

zhangyong hai 8 meses
pai
achega
a539e5c413
Modificáronse 1 ficheiros con 55 adicións e 53 borrados
  1. 55 53
      common/feishu_form.py

+ 55 - 53
common/feishu_form.py

@@ -37,59 +37,41 @@ class Material():
     def get_task_data(cls, feishu_id, feishu_sheet):
         data = Feishu.get_values_batch(feishu_id, feishu_sheet)
         processed_list = []
-
-        for row in data[1:]:
-            channel_id = row[1]
-            channel_url = row[2]
-            piaoquan_id = row[3]
-            number = row[4]
-            video_share = row[5]
-            video_ending = row[6]
-            crop_tool = row[7]
-            gg_duration = row[8]
-            title = row[9]
-            try:
-                ls_number = int(row[10])
-            except:
-                ls_number = None
-            def count_items(item, separator):
-                if item and item not in {'None', ''}:
-                    return len(item.split(separator))
-                return 0
-
-            video_id_total = count_items(str(channel_url), ',')
-            title_total = count_items(str(title), '/')
-            video_ending_total = count_items(str(video_ending), ',')
-
-            values = [channel_id, video_id_total, piaoquan_id, video_share, video_ending_total, crop_tool, gg_duration, title_total]
-            filtered_values = [str(value) for value in values if value is not None and value != "None"]
-            task_mark = "_".join(map(str, filtered_values))
-
-            if piaoquan_id and piaoquan_id not in {'None', ''}:
-                number_dict = {
-                    "task_mark": task_mark,
-                    "channel_id": channel_id,
-                    "channel_url": channel_url,
-                    "piaoquan_id": piaoquan_id,
-                    "number": number,
-                    "title": title,
-                    "video_share": video_share,
-                    "video_ending": video_ending,
-                    "crop_total": crop_tool,
-                    "gg_duration_total": gg_duration,
-                }
-                processed_list.append(number_dict)
-                if ls_number and ls_number not in {'None', ''}:
-                    if channel_id == "抖音":
-                        new_channel_id = "抖音历史"
-                    if channel_id == "快手":
-                        new_channel_id = "快手历史"
+        try:
+            for row in data[1:]:
+                channel_id = row[1]
+                channel_url = row[2]
+                piaoquan_id = row[3]
+                number = row[4]
+                video_share = row[5]
+                video_ending = row[6]
+                crop_tool = row[7]
+                gg_duration = row[8]
+                title = row[9]
+                try:
+                    ls_number = int(row[10])
+                except:
+                    ls_number = None
+                def count_items(item, separator):
+                    if item and item not in {'None', ''}:
+                        return len(item.split(separator))
+                    return 0
+
+                video_id_total = count_items(str(channel_url), ',')
+                title_total = count_items(str(title), '/')
+                video_ending_total = count_items(str(video_ending), ',')
+
+                values = [channel_id, video_id_total, piaoquan_id, video_share, video_ending_total, crop_tool, gg_duration, title_total]
+                filtered_values = [str(value) for value in values if value is not None and value != "None"]
+                task_mark = "_".join(map(str, filtered_values))
+
+                if piaoquan_id and piaoquan_id not in {'None', ''}:
                     number_dict = {
                         "task_mark": task_mark,
-                        "channel_id": new_channel_id,
+                        "channel_id": channel_id,
                         "channel_url": channel_url,
                         "piaoquan_id": piaoquan_id,
-                        "number": ls_number,
+                        "number": number,
                         "title": title,
                         "video_share": video_share,
                         "video_ending": video_ending,
@@ -97,10 +79,30 @@ class Material():
                         "gg_duration_total": gg_duration,
                     }
                     processed_list.append(number_dict)
-            else:
-                return processed_list
-
-        return processed_list
+                    if ls_number and ls_number not in {'None', ''}:
+                        if channel_id == "抖音":
+                            new_channel_id = "抖音历史"
+                        if channel_id == "快手":
+                            new_channel_id = "快手历史"
+                        number_dict = {
+                            "task_mark": task_mark,
+                            "channel_id": new_channel_id,
+                            "channel_url": channel_url,
+                            "piaoquan_id": piaoquan_id,
+                            "number": ls_number,
+                            "title": title,
+                            "video_share": video_share,
+                            "video_ending": video_ending,
+                            "crop_total": crop_tool,
+                            "gg_duration_total": gg_duration,
+                        }
+                        processed_list.append(number_dict)
+                else:
+                    return processed_list
+
+            return processed_list
+        except:
+            processed_list
 
     """
     获取对应片尾+srt