Przeglądaj źródła

增加口播类-小年

zhangyong 1 rok temu
rodzic
commit
e618a4449a
4 zmienionych plików z 34 dodań i 8 usunięć
  1. 4 1
      common/material.py
  2. 12 0
      common/sql_help.py
  3. 11 4
      main.py
  4. 7 3
      video_stitching/video_stitching.py

+ 4 - 1
common/material.py

@@ -104,7 +104,10 @@ class Material():
         list = []
         title_list = []
         if video_type == "口播--美文类":
-            audio_type = Feishu.get_values_batch("prod", "succinct", "Sed8gy")
+            if channel_type == "xiaonian":
+                audio_type = Feishu.get_values_batch("prod", "succinct", "djrml0")
+            else:
+                audio_type = Feishu.get_values_batch("prod", "succinct", "Sed8gy")
             for row in audio_type[1:]:
                 audio_id = row[2]
                 text = row[3]

+ 12 - 0
common/sql_help.py

@@ -46,3 +46,15 @@ class sql():
             count = 0
         count = str(count).replace('(', '').replace(')', '').replace(',', '')
         return int(count)
+
+    #  获取口播类-节日数量
+    @classmethod
+    def get_jieri_account_id(cls):
+        current_time = datetime.now()
+        formatted_time = current_time.strftime("%Y-%m-%d")
+        count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM video_audio WHERE time = '{formatted_time}' AND video_type = 3 GROUP BY audio, account_id) AS subquery;"""
+        count = MysqlHelper.get_values(count, "prod")
+        if count == None:
+            count = 0
+        count = str(count).replace('(', '').replace(')', '').replace(',', '')
+        return int(count)

+ 11 - 4
main.py

@@ -19,8 +19,14 @@ def job_video_stitching():
     global flag
     dy_yinmei_count = sql.get_dy_yinmei_account_id()
     koubo_count = sql.get_koubo_account_id()
+    jieri_count = sql.get_jieri_account_id()
     ks_yinmei_count = sql.get_ks_yinmei_account_id()
-    if int(ks_yinmei_count) < 10:
+    if int(jieri_count) < 20:
+        Common.logger("video").info("开始执行-口播")
+        video_type = "口播--节日类"
+        channel_type = "xiaonian"
+        VideoStitching.video_stitching(video_type, koubo_count, channel_type)
+    elif int(ks_yinmei_count) < 10:
         Common.logger("video").info("开始执行-快手")
         video_type = "音画美文"
         channel_type = "kuaishou"
@@ -36,7 +42,7 @@ def job_video_stitching():
         channel_type = "koubo"
         VideoStitching.video_stitching(video_type, koubo_count, channel_type)
     count = int(dy_yinmei_count + koubo_count + ks_yinmei_count)
-    if count == 30:
+    if count == 50:
         if flag:
             Feishu.bot('recommend', '拼接视频', '自制视频拼接完成啦,共计30条~')
             flag = False
@@ -44,12 +50,13 @@ def job_video_stitching():
         flag = True
 
 def job_feishu_bot():
+    jieri_count = sql.get_jieri_account_id()
     dy_yinmei_count = sql.get_dy_yinmei_account_id()
     koubo_count = sql.get_koubo_account_id()
     ks_yinmei_count = sql.get_ks_yinmei_account_id()
     count = int(dy_yinmei_count + koubo_count + ks_yinmei_count)
-    if count < 30:
-        Feishu.bot('recommend', '拼接视频', f'视频生成异常,不符合预期,请检查\n目前生成数量如下:\n抖音视频拼接:{dy_yinmei_count}条 \n快手视频拼接:{ks_yinmei_count}条\n口播视频拼接:{koubo_count}条')
+    if count < 50:
+        Feishu.bot('recommend', '拼接视频', f'视频生成异常,不符合预期,请检查\n目前生成数量如下:\n小年类视频拼接:{jieri_count}条\n抖音视频拼接:{dy_yinmei_count}条 \n快手视频拼接:{ks_yinmei_count}条\n口播视频拼接:{koubo_count}条')
 
 def job_douyin_data():
     douyinAuthor.get_videoList()

+ 7 - 3
video_stitching/video_stitching.py

@@ -71,10 +71,14 @@ class VideoStitching():
 
 
     @classmethod
-    def insert_video_typeAudio(cls, video, audio_id):
+    def insert_video_typeAudio(cls, video, audio_id, channel_type):
         current_time = datetime.now()
         formatted_time = current_time.strftime("%Y-%m-%d")
-        insert_sql = f"""INSERT INTO video_audio (audio, account_id, oss_object_key, time, video_type) values ('{audio_id}', '{video}', '{video}', '{formatted_time}', 1)"""
+        if channel_type == "xiaonian":
+            video_type = 3
+        else:
+            video_type = 1
+        insert_sql = f"""INSERT INTO video_audio (audio, account_id, oss_object_key, time, video_type) values ('{audio_id}', '{video}', '{video}', '{formatted_time}', {video_type})"""
         MysqlHelper.update_values(
             sql=insert_sql,
             env="prod",
@@ -384,7 +388,7 @@ class VideoStitching():
                 time.sleep(10)
                 # 发送成功 已使用视频存入数据库
                 if video_type == "口播--美文类":
-                    cls.insert_video_typeAudio(videos, audio_id)
+                    cls.insert_video_typeAudio(videos, audio_id, channel_type)
                 else:
                     cls.insert_videoAudio(audio_url, audio_id, channel_type)
                 Common.logger("video").info(f"发送成功 已使用视频存入数据库完成")