From 5072295eb35a306d5cd0587979d16d7b85a04241 Mon Sep 17 00:00:00 2001 From: SwimmingLiu Date: Mon, 16 Sep 2024 20:22:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9C=AA=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E8=AF=B4=E8=AF=B4=E5=90=88=E5=B9=B6=E8=87=B3=E4=B8=BB=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 7 +------ util/ToolsUtil.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 3cbe256..3662c25 100644 --- a/main.py +++ b/main.py @@ -221,11 +221,6 @@ def open_file(file_path): print(f"Unsupported OS: {platform.system()}") -def get_content_from_split(content): - content_split = str(content).split(":") - return content_split[1].strip() if len(content_split) > 1 else content.strip() - - if __name__ == '__main__': try: user_info = Request.get_login_user_info() @@ -277,7 +272,7 @@ if __name__ == '__main__': if user_moments and len(user_moments) > 0: # 如果可见说说的内容是从消息列表恢复的说说内容子集,则不添加到消息列表中 texts = [t for t in texts if - not any(get_content_from_split(u[1]) in get_content_from_split(t[1]) for u in user_moments)] + not any(Tools.is_any_mutual_exist(t[1], u[1]) for u in user_moments)] texts.extend(user_moments) except Exception as err: print(f"获取未删除QQ空间记录发生异常: {str(err)}") diff --git a/util/ToolsUtil.py b/util/ToolsUtil.py index 2fe7f14..93ac55a 100644 --- a/util/ToolsUtil.py +++ b/util/ToolsUtil.py @@ -237,3 +237,14 @@ def replace_em_to_img(match): emoji_code = match.group(1) return f'{emoji_code}' + +def get_content_from_split(content): + content_split = str(content).split(":") + return content_split[1].strip() if len(content_split) > 1 else content.strip() + + +# 判断两个字符串是否存在互相包含的情况 +def is_any_mutual_exist(str1, str2): + str1 = get_content_from_split(str1) + str2 = get_content_from_split(str2) + return str1 in str2 or str2 in str1