feishu_form.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. # -*- coding: utf-8 -*-
  2. import os
  3. import random
  4. import sys
  5. import datetime
  6. sys.path.append(os.getcwd())
  7. from common.feishu_utils import Feishu
  8. class Material():
  9. """
  10. 获取汇总表所有负责人列表
  11. """
  12. @classmethod
  13. def feishu_list(cls):
  14. summary = Feishu.get_values_batch("summary", "3e1295")
  15. list = []
  16. for row in summary[1:]:
  17. mark = row[0]
  18. name = row[1]
  19. feishu_id = row[3]
  20. feishu_sheet = row[4]
  21. pw_sheet = row[5]
  22. number = {"mark": mark, "name": name, "feishu_id": feishu_id, "feishu_sheet": feishu_sheet, "pw_sheet": pw_sheet}
  23. if mark:
  24. list.append(number)
  25. else:
  26. return list
  27. return list
  28. """
  29. 获取对应负责人任务明细
  30. """
  31. @classmethod
  32. def get_task_data(cls, feishu_id, feishu_sheet):
  33. data = Feishu.get_values_batch(feishu_id, feishu_sheet)
  34. processed_list = []
  35. for row in data[1:]:
  36. old_id = row[1]
  37. video_id = row[2]
  38. new_id = row[3]
  39. number = row[4]
  40. video_share = row[5]
  41. video_ending = row[6]
  42. crop_tool = row[7]
  43. gg_duration = row[8]
  44. title = row[9]
  45. def count_items(item, separator):
  46. if item and item not in {'None', ''}:
  47. return len(item.split(separator))
  48. return 0
  49. old_id_total = count_items(str(old_id), ',')
  50. video_id_total = count_items(str(video_id), ',')
  51. new_id_total = count_items(str(new_id), ',')
  52. title_total = count_items(str(title), '/')
  53. values = [old_id_total, video_id_total, new_id_total, video_share, video_ending, crop_tool, gg_duration, title_total]
  54. filtered_values = [str(value) for value in values if value is not None and value != "None"]
  55. task_mark = "_".join(map(str, filtered_values))
  56. if new_id and new_id not in {'None', ''}:
  57. number_dict = {
  58. "task_mark": task_mark,
  59. "old_id": old_id,
  60. "video_id": video_id,
  61. "new_id": new_id,
  62. "number": number,
  63. "title": title,
  64. "video_share": video_share,
  65. "video_ending": video_ending,
  66. "crop_total": crop_tool,
  67. "gg_duration_total": gg_duration,
  68. }
  69. processed_list.append(number_dict)
  70. else:
  71. return processed_list
  72. return processed_list
  73. """
  74. 获取对应负责人下的片尾+固定字幕
  75. """
  76. @classmethod
  77. def get_pwsrt_data(cls, feishu_id, feishu_sheet):
  78. data = Feishu.get_values_batch(feishu_id, feishu_sheet)
  79. list = []
  80. zm_list = []
  81. for row in data[1:]:
  82. pw_id = row[0]
  83. pw_srt = row[1]
  84. zm_video = row[2]
  85. if pw_id != 'None' and pw_id != '' and pw_id != None:
  86. number = {"pw_id": pw_id, "pw_srt": pw_srt}
  87. list.append(number)
  88. if zm_video != 'None' and zm_video != '' and zm_video != None:
  89. zm_list.append(zm_video)
  90. return list, zm_list