feishu_form.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. pz_sheet = row[6]
  23. number = {"mark": mark, "name": name, "feishu_id": feishu_id, "feishu_sheet": feishu_sheet, "pw_sheet": pw_sheet, "pz_sheet": pz_sheet}
  24. if mark:
  25. list.append(number)
  26. else:
  27. return list
  28. return list
  29. """
  30. 获取对应负责人任务明细
  31. """
  32. @classmethod
  33. def get_task_data(cls, feishu_id, feishu_sheet):
  34. data = Feishu.get_values_batch(feishu_id, feishu_sheet)
  35. processed_list = []
  36. for row in data[1:]:
  37. old_id = row[1]
  38. video_id = row[2]
  39. new_id = row[3]
  40. number = row[4]
  41. video_share = row[5]
  42. video_ending = row[6]
  43. crop_tool = row[7]
  44. gg_duration = row[8]
  45. title = row[9]
  46. def count_items(item, separator):
  47. if item and item not in {'None', ''}:
  48. return len(item.split(separator))
  49. return 0
  50. old_id_total = count_items(str(old_id), ',')
  51. video_id_total = count_items(str(video_id), ',')
  52. new_id_total = count_items(str(new_id), ',')
  53. title_total = count_items(str(title), '/')
  54. values = [old_id_total, video_id_total, new_id_total, video_share, video_ending, crop_tool, gg_duration, title_total]
  55. filtered_values = [str(value) for value in values if value is not None and value != "None"]
  56. task_mark = "_".join(map(str, filtered_values))
  57. if new_id and new_id not in {'None', ''}:
  58. number_dict = {
  59. "task_mark": task_mark,
  60. "old_id": old_id,
  61. "video_id": video_id,
  62. "new_id": new_id,
  63. "number": number,
  64. "title": title,
  65. "video_share": video_share,
  66. "video_ending": video_ending,
  67. "crop_total": crop_tool,
  68. "gg_duration_total": gg_duration,
  69. }
  70. processed_list.append(number_dict)
  71. else:
  72. return processed_list
  73. return processed_list
  74. """
  75. 获取对应片尾+srt
  76. """
  77. @classmethod
  78. def get_pwsrt_data(cls, feishu_id, feishu_sheet, video_ending):
  79. data = Feishu.get_values_batch(feishu_id, feishu_sheet)
  80. for row in data[1:]:
  81. pw_mark = row[0]
  82. pw_id = row[1]
  83. pw_srt = row[2]
  84. if pw_id != 'None' and pw_id != '' and pw_id != None:
  85. if pw_mark == video_ending:
  86. number = {"pw_id": pw_id, "pw_srt": pw_srt}
  87. return number
  88. return ''
  89. """
  90. 获取对应固定字幕
  91. """
  92. @classmethod
  93. def get_pzsrt_data(cls, feishu_id, feishu_sheet, video_share_name):
  94. data = Feishu.get_values_batch(feishu_id, feishu_sheet)
  95. for row in data[1:]:
  96. pz_mark = row[0]
  97. pz_zm = row[1]
  98. if pz_zm != 'None' and pz_zm != '' and pz_zm != None:
  99. if pz_mark == video_share_name:
  100. return pz_zm
  101. return ''