Browse Source

修改片中字幕位置

zhangyong 8 months ago
parent
commit
601194fa6e

+ 3 - 1
common/feishu_utils.py

@@ -321,7 +321,9 @@ class Feishu:
             if crawler == "机器自动改造消息通知":
                 sheet_url = "https://w42nne6hzg.feishu.cn/sheets/KsoMsyP2ghleM9tzBfmcEEXBnXg?sheet=bc154d"
                 users = f"<at id=" + str(cls.get_userid(log_type)) + f">{mark_name}</at>"
-
+            else:
+                sheet_url = "https://w42nne6hzg.feishu.cn/sheets/KsoMsyP2ghleM9tzBfmcEEXBnXg?sheet=bc154d"
+                users = f"<at id=" + str(cls.get_userid(log_type)) + f">{mark_name}</at>"
             data = json.dumps({
                 "msg_type": "interactive",
                 "card": {

+ 8 - 4
common/ffmpeg.py

@@ -302,7 +302,7 @@ class FFmpeg():
         single_video_srt = video_path_url + 'single_video.srt'
         # 获取时长
         duration = cls.get_video_duration(new_video_path)
-        start_time = cls.seconds_to_srt_time(5)
+        start_time = cls.seconds_to_srt_time(2)
         end_time = cls.seconds_to_srt_time(duration)
         single_video_txt = video_path_url + 'single_video.txt'
         with open(single_video_txt, 'w') as f:
@@ -311,12 +311,16 @@ class FFmpeg():
         box_height = int(int(height) / 4)  # 框的高度为视频高度的四分之一
         # background_cmd = f"drawbox=y=ih-{70 + box_height}-{int(box_height / 20)}:color=yellow@1.0:width=iw:height={box_height}:t=fill"
         if zm:
+            # with open(single_video_srt, 'w') as f:
+            #     # f.write(f"1\n{start_time} --> {end_time}\n{zm}\n\n")
+            #     f.write(f"1\n{start_time} --> {end_time}\n<font color=\"red\">\u2764\uFE0F</font>{zm}\n\n")
+            # subtitle_cmd = f"subtitles={single_video_srt}:force_style='Fontsize=12,Fontname=wqy-zenhei,Outline=2,PrimaryColour=&H00FFFF,SecondaryColour=&H000000,Bold=1,MarginV=10'"
             with open(single_video_srt, 'w') as f:
-                # f.write(f"1\n{start_time} --> {end_time}\n{zm}\n\n")
+                # f.write(f"1\n{start_time} --> {end_time}\n\u2764\uFE0F{zm}\n\n")
                 f.write(f"1\n{start_time} --> {end_time}\n<font color=\"red\">\u2764\uFE0F</font>{zm}\n\n")
-            subtitle_cmd = f"subtitles={single_video_srt}:force_style='Fontsize=12,Fontname=wqy-zenhei,Outline=2,PrimaryColour=&H00FFFF,SecondaryColour=&H000000,Bold=1,MarginV=10'"
+            subtitle_cmd = f"subtitles={single_video_srt}:force_style='Fontsize=14,Fontname=wqy-zenhei,Outline=2,PrimaryColour=&H00FFFF,SecondaryColour=&H000000,Bold=1,MarginV=20'"
         else:
-            subtitle_cmd = f"force_style='Fontsize=12,Fontname=wqy-zenhei,Outline=2,PrimaryColour=&H00FFFF,SecondaryColour=&H000000,Bold=1,MarginV=10'"
+            subtitle_cmd = f"force_style='Fontsize=14,Fontname=wqy-zenhei,Outline=2,PrimaryColour=&H00FFFF,SecondaryColour=&H000000,Bold=1,MarginV=20'"
         draw = f"{subtitle_cmd}"
         # 多线程数
         num_threads = 5

+ 0 - 0
xssy_channel/__init__.py


+ 0 - 0
data_channel/cljx_nrxs.py → xssy_channel/cljx_nrxs.py


+ 0 - 0
data_channel/dy_nrxs.py → xssy_channel/dy_nrxs.py


+ 0 - 0
data_channel/ks_nrxs.py → xssy_channel/ks_nrxs.py


+ 130 - 0
xssy_channel/sph_nrxs.py

@@ -0,0 +1,130 @@
+import random
+import time
+
+import requests
+import json
+import re
+
+from common import Material, Feishu, Common
+from common.sql_help import sqlCollect
+
+class SphNrxs:
+
+
+    @classmethod
+    def get_sph_data(cls, user):
+        url = "http://61.48.133.26:30001/FinderGetUpMasterNextPage"
+        count = 1
+        headers = {
+            'Content-Type': 'application/json'
+        }
+        payload = json.dumps({
+            "username": user,
+            "last_buffer": ""
+        })
+
+        response = requests.request("POST", url, headers=headers, data=payload)
+        time.sleep(random.randint(1, 5))
+        Common.logger("sph_nrxs").info(f"{user}获取第{count}页视频")
+        count += 1
+        if response.text == "" or response.text == None:
+            return
+        res_json = response.json()
+        try:
+            if len(res_json["DownloadAddress"]) == 0 or res_json["DownloadAddress"] == "" or res_json[
+                "DownloadAddress"] == None:
+                return
+        except:
+            pass
+        if "objectId" not in response.text or response.status_code != 200:
+            return
+        if len(res_json["UpMasterHomePage"]) == 0:
+            return
+        if not res_json["UpMasterHomePage"]:
+            return
+        try:
+            for obj in res_json["UpMasterHomePage"]:
+                Common.logger("sph_crawling").info(f"{user}扫描到一条数据")
+                objectId = obj['objectId']
+                object_id = sqlCollect.sph_data_info_v_id(objectId, "视频号")
+                if object_id:
+                    continue
+                objectNonceId = obj['objectNonceId']
+                url1 = "http://61.48.133.26:30001/GetFinderDownloadAddress"
+                payload = json.dumps({
+                    "objectId": objectId,
+                    "objectNonceId": objectNonceId
+                })
+                headers = {
+                    'Content-Type': 'text/plain'
+                }
+                response = requests.request("POST", url1, headers=headers, data=payload)
+                time.sleep(random.randint(0, 1))
+                video_obj = response.json()
+                video_url = video_obj.get('DownloadAddress')
+                duration = video_obj.get('play_len')
+                cover = video_obj.get('thumb_url')
+                if len(video_url) == 0:
+                    continue
+
+                share_cnt = int(obj['forward_count'])  # 分享
+                like_cnt = int(obj['like_count'])  # 点赞
+                user_name = obj['username']  # 用户名标示
+                nick_name = obj['nickname']  # 用户名
+                comment_count = obj['comment_count']  # 评论数
+                fav_count = obj['fav_count']  # 大拇指点赞数
+                Common.logger("sph_nrxs").info(f"{nick_name}符合规则")
+        except Exception as e:
+            Common.logger("sph_nrxs").info(f"{user}异常,异常信息{e}")
+            return
+
+    @classmethod
+    def get_nrxs_list(cls):
+        list = []
+        cookie = Material.get_cookie_data("KsoMsyP2ghleM9tzBfmcEEXBnXg", "U1gySe", "视频号加热")
+        url = "http://8.217.190.241:8888/crawler/wei_xin/shi_pin_hao/jia_re"
+
+        payload = json.dumps({
+            "account_name": "央视新闻",
+            "category": "推荐",
+            "cookie": cookie
+        })
+        headers = {
+          'Content-Type': 'application/json'
+        }
+        try:
+            response = requests.request("POST", url, headers=headers, data=payload)
+            response = response.json()
+            code = response['code']
+            if code == 0:
+                data_list = response['data']['data']
+                if data_list:
+                    for data in data_list:
+                        nick_name = data['nickName']  # 用户名
+                        user_name = data['username']  # 用户v2
+                        data_dict = {"nick_name": nick_name, "user_name": user_name}
+                        list.append(data_dict)
+                else:
+                    Feishu.bot("xinxin", '视频号加热提醒', f'cookie 失效了,请即使更换', 'xinxin')
+                    return None
+        except Exception as e:
+            Feishu.bot("xinxin", '视频号加热提醒', f'cookie 失效了,请即使更换', 'xinxin')
+            Common.logger("feishu").error(f"视频号加热bot异常:{e}\n")
+            return None
+
+    @classmethod
+    def sph_nrxs_data(cls):
+        user = sqlCollect.get_machine_making_reflux("视频号", "单点视频")
+        if user == None:
+            return
+        user = [item[0] for item in user]
+        for uid in user:
+            if re.match(r'^[A-Za-z0-9]+$', uid):
+                # 匹配成功,进行下一次循环
+                continue
+            print(uid)
+
+
+
+if __name__ == '__main__':
+  SphNrxs.get_nrxs_list()