Kaynağa Gözat

增加生产春节视频逻辑

zhangyong 1 yıl önce
ebeveyn
işleme
9214ae38d6
3 değiştirilmiş dosya ile 131 ekleme ve 54 silme
  1. 12 0
      common/material.py
  2. 18 11
      main.py
  3. 101 43
      video_stitching/video_stitching.py

+ 12 - 0
common/material.py

@@ -147,6 +147,18 @@ class Material():
             audio_id = list['audio_id']
             srt = list['text']
             return audio_id, srt, title_list
+        elif video_type == "自制--春节":
+            zizhi_chunjie = Feishu.get_values_batch("prod", "succinct", "7EB9WK")
+            for row in zizhi_chunjie[2:]:
+                audio_id = row[2]
+                text = row[3]
+                title = row[4]
+                number = {"audio_id": audio_id, "text": text}
+                list.append(number)
+                title_list.append(title)
+            audio_id = list[count]['audio_id']
+            srt = list[count]['text']
+            return audio_id, srt, title_list
         else:
             if channel_type == "douyin":
                 if count == 0 or count == 1:

+ 18 - 11
main.py

@@ -21,11 +21,7 @@ def job_video_stitching():
     jieri_count = sql.get_jieri_account_id()
     chunjie_zizhi_count = sql.get_chunjie_zizhi_account_id()
     ks_yinmei_count = sql.get_ks_yinmei_account_id()
-    # elif int(jieri_count) < 10:
-    #     Common.logger("video").info("开始执行-口播-春节")
-    #     video_type = "口播--美文类"
-    #     channel_type = "jieri"
-    #     VideoStitching.video_stitching(video_type, koubo_count, channel_type)
+
     if int(ks_yinmei_count) < 10:
         Common.logger("video").info("开始执行-快手")
         video_type = "音画美文"
@@ -37,27 +33,38 @@ def job_video_stitching():
         video_type = "音画美文"
         channel_type = "douyin"
         VideoStitching.video_stitching(video_type, dy_yinmei_count, channel_type)
+    elif int(chunjie_zizhi_count) < 10:
+        Common.logger("video").info("开始执行-自制-春节")
+        video_type = "自制--春节"
+        channel_type = "kschunjie"
+        VideoStitching.video_stitching(video_type, dy_yinmei_count, channel_type)
+    elif int(jieri_count) < 5:
+        Common.logger("video").info("开始执行-口播-春节")
+        video_type = "口播--美文类"
+        channel_type = "jieri"
+        VideoStitching.video_stitching(video_type, koubo_count, channel_type)
     elif int(koubo_count) < 10:
         Common.logger("video").info("开始执行-口播")
         video_type = "口播--美文类"
         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 == 45:
         if flag:
-            Feishu.bot('recommend', '拼接视频', '自制视频拼接完成啦,共计30条~')
+            Feishu.bot('recommend', '拼接视频', '自制视频拼接完成啦,共计45条~')
             flag = False
     if count == 0:
         flag = True
 
 def job_feishu_bot():
-    # jieri_count = sql.get_jieri_account_id()
+    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}条')
+    chunjie_zizhi_count = sql.get_chunjie_zizhi_account_id()
+    count = int(dy_yinmei_count + koubo_count + ks_yinmei_count+chunjie_zizhi_count+jieri_count)
+    if count < 45:
+        Feishu.bot('recommend', '拼接视频', f'视频生成异常,不符合预期,请检查\n目前生成数量如下:\n春节自制:{chunjie_zizhi_count}条\n抖音视频拼接:{dy_yinmei_count}条 \n快手视频拼接:{ks_yinmei_count}条\n春节-口播:{jieri_count}条\n口播视频拼接:{koubo_count}条')
 
 
 # 每15分钟执行一次

+ 101 - 43
video_stitching/video_stitching.py

@@ -58,6 +58,8 @@ class VideoStitching():
         formatted_time = current_time.strftime("%Y-%m-%d")
         if channel_type == "douyin":
             video_type = 0
+        elif channel_type == "kschunjie":
+            video_type = 4
         else:
             video_type = 2
         for j in audio_url:
@@ -119,6 +121,12 @@ class VideoStitching():
         url_list = MysqlHelper.get_values(url_list, "prod")
         return url_list
 
+    @classmethod
+    def get_zizhi_url_list(cls, account):
+        url_list = f"""SELECT video_id,account_id,oss_object_key FROM video_url where account_id = {account}  limit 35;"""
+        url_list = MysqlHelper.get_values(url_list, "prod")
+        return url_list
+
     @classmethod
     def get_audio_url_list(cls, videos, audio_id):
         url_list = f"""SELECT audio FROM  video_audio where audio = {audio_id} and oss_object_key = '{videos}';"""
@@ -129,50 +137,88 @@ class VideoStitching():
     @classmethod
     def insert_piaoquantv(cls, oss_object_key, title_list, video_type, channel_type):
         #list = ["66481136", "66481137", "66481140", "66481141", "66481142"] 老用户id
-        if video_type == "口播--美文类":
-            list = ["67231152", "67231153", "67231154", "67231155", "67231157"]
+        if video_type == "自制--春节":
+            list = ['15924999', '50322241', '50322258', '57463797', '50322235', '57463790', '50322234', '6605563', '18981907', '50322198', '50322239', '57463838', '14500202']
+            code = 1
+            for i in range(len(list)):
+                title_list = [item for item in title_list if item is not None]
+                title = random.choice(title_list)
+                # title = title[0].strip("[]'")
+                url = "https://vlogapi.piaoquantv.com/longvideoapi/crawler/video/send"
+                payload = dict(pageSource='vlog-pages/post/post-video-post', videoPath=oss_object_key, width='720',
+                               height='1280', fileExtensions='mp4', viewStatus='1', title=title, careModelStatus='1',
+                               token='f04f58d6e664cbc9902660a1e8d20ce6cd7fdb0f', loginUid=list[i], versionCode='719',
+                               machineCode='weixin_openid_o0w175aZ4FJtqVsA1tcozJDJHdDU', appId='wx89e7eb06478361d7',
+                               clientTimestamp='1703337579331',
+                               machineInfo='{"sdkVersion":"3.2.5","brand":"iPhone","language":"zh_CN","model":"iPhone 12 Pro<iPhone13,3>","platform":"ios","system":"iOS 15.6.1","weChatVersion":"8.0.44","screenHeight":844,"screenWidth":390,"pixelRatio":3,"windowHeight":762,"windowWidth":390,"softVersion":"4.1.719"}',
+                               sessionId='1703337560040-27bfe208-a389-f476-db1d-840681e04b32',
+                               subSessionId='1703337569952-8f56d53c-b36d-760e-8abe-0b4a027cd5bd', senceType='1089',
+                               hotSenceType='1089', id='1050', channel='pq')
+
+                payload['videoPath'] = oss_object_key
+                payload['title'] = title
+
+                data = urllib.parse.urlencode(payload)
+
+                headers = {
+                    'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.44(0x18002c2d) NetType/WIFI Language/zh_CN',
+                    'Accept-Encoding': 'gzip,compress,br,deflate',
+                    'Referer': 'https://servicewechat.com/wx89e7eb06478361d7/726/page-frame.html',
+                    'Content-Type': 'application/x-www-form-urlencoded',
+                    'Cookie': 'JSESSIONID=A60D96E7A300A25EA05425B069C8B459'
+                }
+
+                response = requests.post(url, data=data, headers=headers)
+                data = response.json()
+                code = data["code"]
+            if code == 0:
+                return True
+            else:
+                return False
         else:
-            if channel_type == "douyin":
+            if video_type == "口播--美文类":
+                list = ["67231152", "67231153", "67231154", "67231155", "67231157"]
+            elif channel_type == "douyin":
                 list = ["67231113", "67231112", "67231111", "67231110", "67231109"]
             else:
                 list = ["67413406", "67413407", "67413408", "67413409", "67413410"]
-        code = 1
-        for i in range(2):
-            item = random.choice(list)
-            title_list = [item for item in title_list if item is not None]
-            title = random.choice(title_list)
-            # title = title[0].strip("[]'")
-            url = "https://vlogapi.piaoquantv.com/longvideoapi/crawler/video/send"
-            payload = dict(pageSource='vlog-pages/post/post-video-post', videoPath=oss_object_key, width='720',
-                           height='1280', fileExtensions='mp4', viewStatus='1', title=title, careModelStatus='1',
-                           token='f04f58d6e664cbc9902660a1e8d20ce6cd7fdb0f', loginUid=item, versionCode='719',
-                           machineCode='weixin_openid_o0w175aZ4FJtqVsA1tcozJDJHdDU', appId='wx89e7eb06478361d7',
-                           clientTimestamp='1703337579331',
-                           machineInfo='{"sdkVersion":"3.2.5","brand":"iPhone","language":"zh_CN","model":"iPhone 12 Pro<iPhone13,3>","platform":"ios","system":"iOS 15.6.1","weChatVersion":"8.0.44","screenHeight":844,"screenWidth":390,"pixelRatio":3,"windowHeight":762,"windowWidth":390,"softVersion":"4.1.719"}',
-                           sessionId='1703337560040-27bfe208-a389-f476-db1d-840681e04b32',
-                           subSessionId='1703337569952-8f56d53c-b36d-760e-8abe-0b4a027cd5bd', senceType='1089',
-                           hotSenceType='1089', id='1050', channel='pq')
-
-            payload['videoPath'] = oss_object_key
-            payload['title'] = title
-
-            data = urllib.parse.urlencode(payload)
-
-            headers = {
-                'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.44(0x18002c2d) NetType/WIFI Language/zh_CN',
-                'Accept-Encoding': 'gzip,compress,br,deflate',
-                'Referer': 'https://servicewechat.com/wx89e7eb06478361d7/726/page-frame.html',
-                'Content-Type': 'application/x-www-form-urlencoded',
-                'Cookie': 'JSESSIONID=A60D96E7A300A25EA05425B069C8B459'
-            }
-
-            response = requests.post(url, data=data, headers=headers)
-            data = response.json()
-            code = data["code"]
-        if code == 0:
-            return True
-        else:
-            return False
+            code = 1
+            for i in range(2):
+                item = random.choice(list)
+                title_list = [item for item in title_list if item is not None]
+                title = random.choice(title_list)
+                # title = title[0].strip("[]'")
+                url = "https://vlogapi.piaoquantv.com/longvideoapi/crawler/video/send"
+                payload = dict(pageSource='vlog-pages/post/post-video-post', videoPath=oss_object_key, width='720',
+                               height='1280', fileExtensions='mp4', viewStatus='1', title=title, careModelStatus='1',
+                               token='f04f58d6e664cbc9902660a1e8d20ce6cd7fdb0f', loginUid=item, versionCode='719',
+                               machineCode='weixin_openid_o0w175aZ4FJtqVsA1tcozJDJHdDU', appId='wx89e7eb06478361d7',
+                               clientTimestamp='1703337579331',
+                               machineInfo='{"sdkVersion":"3.2.5","brand":"iPhone","language":"zh_CN","model":"iPhone 12 Pro<iPhone13,3>","platform":"ios","system":"iOS 15.6.1","weChatVersion":"8.0.44","screenHeight":844,"screenWidth":390,"pixelRatio":3,"windowHeight":762,"windowWidth":390,"softVersion":"4.1.719"}',
+                               sessionId='1703337560040-27bfe208-a389-f476-db1d-840681e04b32',
+                               subSessionId='1703337569952-8f56d53c-b36d-760e-8abe-0b4a027cd5bd', senceType='1089',
+                               hotSenceType='1089', id='1050', channel='pq')
+
+                payload['videoPath'] = oss_object_key
+                payload['title'] = title
+
+                data = urllib.parse.urlencode(payload)
+
+                headers = {
+                    'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.44(0x18002c2d) NetType/WIFI Language/zh_CN',
+                    'Accept-Encoding': 'gzip,compress,br,deflate',
+                    'Referer': 'https://servicewechat.com/wx89e7eb06478361d7/726/page-frame.html',
+                    'Content-Type': 'application/x-www-form-urlencoded',
+                    'Cookie': 'JSESSIONID=A60D96E7A300A25EA05425B069C8B459'
+                }
+
+                response = requests.post(url, data=data, headers=headers)
+                data = response.json()
+                code = data["code"]
+            if code == 0:
+                return True
+            else:
+                return False
 
 
     # 视频拼接
@@ -361,10 +407,22 @@ class VideoStitching():
             videos = [list(item) for item in audio_list]
             videos = random.choice(videos) #随机选择视频
             # 判断该视频+音频是否生成过视频
-            video = VideoStitching.get_audio_url_list(videos, audio_id)
-            if video:
-                Common.logger("video").info(f"该视频+音频已经生成过视频,不做视频拼接")
+            # video = VideoStitching.get_audio_url_list(videos, audio_id)
+            # if video:
+            #     Common.logger("video").info(f"该视频+音频已经生成过视频,不做视频拼接")
+            #     return
+        elif video_type == "自制--春节":
+            # 获取已入库的用户id
+            account_id = cls.get_account_id(channel_type)
+            account = random.choice(account_id)
+            account = str(account).replace('(', '').replace(')', '').replace(',', '')
+            Common.logger("video").info(f"获取用户ID:{account}")
+            # 获取视频链接
+            url_list = cls.get_zizhi_url_list(account)
+            if url_list == None:
+                Common.logger("video").info(f"未使用视频链接为空:{url_list}")
                 return
+            videos = [list(item) for item in url_list]
         else:
             # 获取已入库的用户id
             account_id = cls.get_account_id(channel_type)