feishu_form.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. title = row[7]
  43. def count_items(item, separator):
  44. if item and item not in {'None', ''}:
  45. return len(item.split(separator))
  46. return 0
  47. old_id_total = count_items(str(old_id), ',')
  48. video_id_total = count_items(str(video_id), ',')
  49. new_id_total = count_items(str(new_id), ',')
  50. title_total = count_items(str(title), '/')
  51. values = [old_id_total, video_id_total, new_id_total, video_share, video_ending, title_total]
  52. task_mark = "_".join(map(str, values))
  53. if new_id and new_id not in {'None', ''}:
  54. number_dict = {
  55. "task_mark": task_mark,
  56. "old_id": old_id,
  57. "video_id": video_id,
  58. "new_id": new_id,
  59. "number": number,
  60. "title": title,
  61. "video_share": video_share,
  62. "video_ending": video_ending
  63. }
  64. processed_list.append(number_dict)
  65. else:
  66. return processed_list
  67. return processed_list
  68. """
  69. 获取对应负责人下的片尾+固定字幕
  70. """
  71. @classmethod
  72. def get_pwsrt_data(cls, feishu_id, feishu_sheet):
  73. data = Feishu.get_values_batch(feishu_id, feishu_sheet)
  74. list = []
  75. zm_list = []
  76. for row in data[1:]:
  77. pw_id = row[0]
  78. pw_srt = row[1]
  79. zm_video = row[2]
  80. if pw_id != 'None' and pw_id != '' and pw_id != None:
  81. number = {"pw_id": pw_id, "pw_srt": pw_srt}
  82. list.append(number)
  83. if zm_video != 'None' and zm_video != '' and zm_video != None:
  84. zm_list.append(zm_video)
  85. return list, zm_list