feishu_form.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. crop_total = count_items(str(crop_tool))
  54. gg_duration_total = count_items(str(gg_duration))
  55. values = [old_id_total, video_id_total, new_id_total, video_share, video_ending, title_total]
  56. task_mark = "_".join(map(str, 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_total,
  68. "gg_duration_total": gg_duration_total,
  69. }
  70. processed_list.append(number_dict)
  71. else:
  72. return processed_list
  73. return processed_list
  74. """
  75. 获取对应负责人下的片尾+固定字幕
  76. """
  77. @classmethod
  78. def get_pwsrt_data(cls, feishu_id, feishu_sheet):
  79. data = Feishu.get_values_batch(feishu_id, feishu_sheet)
  80. list = []
  81. zm_list = []
  82. for row in data[1:]:
  83. pw_id = row[0]
  84. pw_srt = row[1]
  85. zm_video = row[2]
  86. if pw_id != 'None' and pw_id != '' and pw_id != None:
  87. number = {"pw_id": pw_id, "pw_srt": pw_srt}
  88. list.append(number)
  89. if zm_video != 'None' and zm_video != '' and zm_video != None:
  90. zm_list.append(zm_video)
  91. return list, zm_list