feishu_form.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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", "bc154d")
  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. cookie_sheet = row[5]
  22. number = {"mark": mark, "name": name, "feishu_id": feishu_id, "feishu_sheet": feishu_sheet, "cookie_sheet": cookie_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. try:
  36. for row in data[1:]:
  37. channel_id = row[1]
  38. channel_url = row[2]
  39. piaoquan_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. try:
  47. ls_number = int(row[10])
  48. except:
  49. ls_number = None
  50. def count_items(item, separator):
  51. if item and item not in {'None', ''}:
  52. return len(item.split(separator))
  53. return 0
  54. video_id_total = count_items(str(channel_url), ',')
  55. title_total = count_items(str(title), '/')
  56. video_ending_total = count_items(str(video_ending), ',')
  57. values = [channel_id, video_id_total, piaoquan_id, video_share, video_ending_total, crop_tool, gg_duration, title_total]
  58. filtered_values = [str(value) for value in values if value is not None and value != "None"]
  59. task_mark = "_".join(map(str, filtered_values))
  60. if piaoquan_id and piaoquan_id not in {'None', ''}:
  61. number_dict = {
  62. "task_mark": task_mark,
  63. "channel_id": channel_id,
  64. "channel_url": channel_url,
  65. "piaoquan_id": piaoquan_id,
  66. "number": number,
  67. "title": title,
  68. "video_share": video_share,
  69. "video_ending": video_ending,
  70. "crop_total": crop_tool,
  71. "gg_duration_total": gg_duration,
  72. }
  73. processed_list.append(number_dict)
  74. if ls_number and ls_number not in {'None', ''}:
  75. if channel_id == "抖音":
  76. new_channel_id = "抖音历史"
  77. if channel_id == "快手":
  78. new_channel_id = "快手历史"
  79. values = [new_channel_id, video_id_total, piaoquan_id, video_share, video_ending_total, crop_tool,
  80. gg_duration, title_total]
  81. filtered_values = [str(value) for value in values if value is not None and value != "None"]
  82. task_mark = "_".join(map(str, filtered_values))
  83. number_dict = {
  84. "task_mark": task_mark,
  85. "channel_id": new_channel_id,
  86. "channel_url": channel_url,
  87. "piaoquan_id": piaoquan_id,
  88. "number": ls_number,
  89. "title": title,
  90. "video_share": video_share,
  91. "video_ending": video_ending,
  92. "crop_total": crop_tool,
  93. "gg_duration_total": gg_duration,
  94. }
  95. processed_list.append(number_dict)
  96. else:
  97. return processed_list
  98. return processed_list
  99. except:
  100. processed_list
  101. """
  102. 获取对应片尾+srt
  103. """
  104. @classmethod
  105. def get_pwsrt_data(cls, feishu_id, feishu_sheet, video_ending):
  106. data = Feishu.get_values_batch(feishu_id, feishu_sheet)
  107. for row in data[1:]:
  108. pw_mark = row[0]
  109. pw_id = row[1]
  110. pw_srt = row[2]
  111. if pw_id != 'None' and pw_id != '' and pw_id != None:
  112. if pw_mark == video_ending:
  113. number = {"pw_id": pw_id, "pw_srt": pw_srt}
  114. return number
  115. return ''
  116. """
  117. 获取对应固定字幕
  118. """
  119. @classmethod
  120. def get_pzsrt_data(cls, feishu_id, feishu_sheet, video_share_name):
  121. data = Feishu.get_values_batch(feishu_id, feishu_sheet)
  122. for row in data[1:]:
  123. pz_mark = row[0]
  124. pz_zm = row[1]
  125. if pz_zm != 'None' and pz_zm != '' and pz_zm != None:
  126. if pz_mark == video_share_name:
  127. return pz_zm
  128. return ''
  129. """
  130. 获取 cookie 信息
  131. """
  132. @classmethod
  133. def get_cookie_data(cls, feishu_id, cookie_sheet, channel):
  134. data = Feishu.get_values_batch(feishu_id, cookie_sheet)
  135. for row in data[1:]:
  136. channel_mask = row[0]
  137. cookie = row[1]
  138. if channel_mask == channel:
  139. return cookie