浏览代码

视频号单点增加完成通知

zhangyong 8 月之前
父节点
当前提交
72750aa026
共有 3 个文件被更改,包括 70 次插入8 次删除
  1. 49 0
      common/feishu_utils.py
  2. 6 6
      data_channel/shipinhaodandian.py
  3. 15 2
      video_rewriting/video_processor.py

+ 49 - 0
common/feishu_utils.py

@@ -362,6 +362,55 @@ class Feishu:
         except Exception as e:
             Common.logger("feishu").error(f"bot异常:{e}\n")
 
+    # 飞书机器人-改造计划完成通知
+    @classmethod
+    def finish_bot(cls, text):
+        try:
+            url = "https://open.feishu.cn/open-apis/bot/v2/hook/0553124e-7fc1-4f9b-8976-9db4218d25e2"
+            headers = {'Content-Type': 'application/json'}
+            sheet_url = "https://w42nne6hzg.feishu.cn/sheets/ILb4sa0LahddRktnRipcu2vQnLb?sheet=ptgCXW"
+                # users = f"<at id=" + str(cls.get_userid(log_type)) + f">{mark_name}</at>"
+
+            data = json.dumps({
+                "msg_type": "interactive",
+                "card": {
+                    "config": {
+                        "wide_screen_mode": True,
+                        "enable_forward": True
+                    },
+                    "elements": [{
+                        "tag": "div",
+                        "text": {
+                            "content": text,
+                            "tag": "lark_md"
+                        }
+                    }, {
+                        "actions": [{
+                            "tag": "button",
+                            "text": {
+                                "content": "**改造内容详情**",
+                                "tag": "lark_md"
+                            },
+                            "url": sheet_url,
+                            "type": "default",
+                            "value": {}
+                        }],
+                        "tag": "action"
+                    }],
+                    "header": {
+                        "title": {
+                            "content": "**【 有一条新的视频号内容改造成功 】**",
+                            "tag": "plain_text"
+                        }
+                    }
+                }
+            })
+            urllib3.disable_warnings()
+            r = requests.post(url, headers=headers, data=data, verify=False, proxies=proxies)
+            Common.logger("feishu").info(f'触发机器人消息:{r.status_code}, {text}')
+        except Exception as e:
+            Common.logger("feishu").error(f"bot异常:{e}\n")
+
 
 if __name__ == "__main__":
     Feishu.bot('recommend', '抖音', '测试: 抖音cookie失效,请及时更换')

+ 6 - 6
data_channel/shipinhaodandian.py

@@ -16,13 +16,13 @@ class SPHDD:
                 cover_url = data[4]
                 video_url = data[5]
                 if video_url and cover_url:
-                    # video_duration = data[6]
-                    # from_user_id = data[7]
-                    # from_user_name = data[8]
-                    # from_group_id = data[9]
-                    # from_group_name = data[10]
+                    video_duration = data[6]
+                    from_user_id = data[7]
+                    from_user_name = data[8]
+                    from_group_id = data[9]
+                    from_group_name = data[10]
                     all_data = {"video_id": video_id, "cover": cover_url, "video_url": video_url, "rule": author_name,
-                                "old_title": old_title}
+                                "old_title": old_title, "from_user_name": from_user_name, "from_group_name": from_group_name}
                     list.append(all_data)
             return list
         return list

+ 15 - 2
video_rewriting/video_processor.py

@@ -129,13 +129,26 @@ class VideoProcessor:
                             cls.remove_files(video_path_url)
                             continue
                         # 上传视频和封面,并更新数据库
-                        values = cls.upload_video_and_thumbnail(new_video_path, cover, v_id, new_title, task_mark, name, piaoquan_id,
+                        values, code = cls.upload_video_and_thumbnail(new_video_path, cover, v_id, new_title, task_mark, name, piaoquan_id,
                                                        video_path_url, mark, channel_id, url, old_title, title, rule)
                         # 更新已使用的视频号状态
                         if name == "视频号单视频":
                             sphdd_status = sqlCollect.update_shp_dd_vid(v_id)
                             if sphdd_status == 1:
                                 Common.logger("log").info(f"{name}的{task_mark}下的ID{url} 视频修改已使用,状态已修改")
+                                pq_url = f'https://admin.piaoquantv.com/cms/post-detail/{code}/detail' # 站内视频链接
+                                from_user_name = video['from_user_name']  # 来源用户
+                                from_group_name = video['from_group_name']  # 来源群组
+                                text = (
+                                    f"**站内视频链接**: {pq_url}\n"
+                                    f"**来源用户**: {from_user_name}\n"
+                                    f"**来源群组**: {from_group_name}\n"
+                                    f"**原视频链接**: {video['video_url']}\n"
+                                    f"**原视频封面**: {video['cover']}\n"
+                                    f"**原视频标题**: {video['old_title']}\n"
+                                )
+                                Feishu.finish_bot(text)
+
                         if values:
                             if name == "王雪珂":
                                 sheet = "vfhHwj"
@@ -353,7 +366,7 @@ class VideoProcessor:
                         str(rule)
                     ]
                 ]
-                return values
+                return values, code
         except Exception as e:
             cls.remove_files(video_path_url)
             Common.logger("error").warning(f"{name}的{task_mark}上传视频和封面到OSS,并更新数据库失败:{e}\n")