feishu_form.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. number_dict = {
  80. "task_mark": task_mark,
  81. "channel_id": new_channel_id,
  82. "channel_url": channel_url,
  83. "piaoquan_id": piaoquan_id,
  84. "number": ls_number,
  85. "title": title,
  86. "video_share": video_share,
  87. "video_ending": video_ending,
  88. "crop_total": crop_tool,
  89. "gg_duration_total": gg_duration,
  90. }
  91. processed_list.append(number_dict)
  92. else:
  93. return processed_list
  94. return processed_list
  95. except:
  96. processed_list
  97. """
  98. 获取对应片尾+srt
  99. """
  100. @classmethod
  101. def get_pwsrt_data(cls, feishu_id, feishu_sheet, video_ending):
  102. data = Feishu.get_values_batch(feishu_id, feishu_sheet)
  103. for row in data[1:]:
  104. pw_mark = row[0]
  105. pw_id = row[1]
  106. pw_srt = row[2]
  107. if pw_id != 'None' and pw_id != '' and pw_id != None:
  108. if pw_mark == video_ending:
  109. number = {"pw_id": pw_id, "pw_srt": pw_srt}
  110. return number
  111. return ''
  112. """
  113. 获取对应固定字幕
  114. """
  115. @classmethod
  116. def get_pzsrt_data(cls, feishu_id, feishu_sheet, video_share_name):
  117. data = Feishu.get_values_batch(feishu_id, feishu_sheet)
  118. for row in data[1:]:
  119. pz_mark = row[0]
  120. pz_zm = row[1]
  121. if pz_zm != 'None' and pz_zm != '' and pz_zm != None:
  122. if pz_mark == video_share_name:
  123. return pz_zm
  124. return ''
  125. """
  126. 获取 cookie 信息
  127. """
  128. @classmethod
  129. def get_cookie_data(cls, feishu_id, cookie_sheet, channel):
  130. data = Feishu.get_values_batch(feishu_id, cookie_sheet)
  131. for row in data[1:]:
  132. channel_mask = row[0]
  133. cookie = row[1]
  134. if channel_mask == channel:
  135. return cookie