From 206dbc88f818d1da28658f4a2ed372dddb58e3b7 Mon Sep 17 00:00:00 2001 From: STDquantum <405720329@qq.com> Date: Fri, 22 Dec 2023 19:22:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86404=20emoji?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/output_pc.py | 6 +----- app/util/emoji.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/DataBase/output_pc.py b/app/DataBase/output_pc.py index c34e8aa..d322546 100644 --- a/app/DataBase/output_pc.py +++ b/app/DataBase/output_pc.py @@ -336,11 +336,7 @@ class ChildThread(QThread): displayname = escape_js_and_html(displayname) if self.output_type == Output.HTML: emoji_path = get_emoji(str_content, thumb=True, output_path=origin_docx_path + '/emoji') - if emoji_path == "": - # todo 改为网络404图片 - emoji_path = "./emoji/404.png" - else: - emoji_path = './emoji/' + os.path.basename(emoji_path) + emoji_path = './emoji/' + os.path.basename(emoji_path) if self.is_5_min(timestamp): doc.write( f'''{{ type:0, text: '{str_time}',is_send:0,avatar_path:'',timestamp:{timestamp},is_chatroom:{is_chatroom},displayname:'{displayname}'}},''' diff --git a/app/util/emoji.py b/app/util/emoji.py index 31b63ba..ddafc5f 100644 --- a/app/util/emoji.py +++ b/app/util/emoji.py @@ -13,7 +13,7 @@ import traceback import xml.etree.ElementTree as ET import sqlite3 import threading - +from PyQt5.QtGui import QPixmap import requests from app.log import log, logger @@ -144,8 +144,6 @@ class Emotion: @log def download(url, output_dir, name, thumb=False): - if not url: - return ':/icons/icons/404.png' resp = requests.get(url) byte = resp.content image_format = get_image_format(byte[:8]) @@ -221,10 +219,16 @@ def get_emoji(xml_string, thumb=True, output_path=root_path) -> str: return output_path else: print("!!!未知表情包数据,信息:", xml_string, emoji_info, url) - return "" + output_path = os.path.join(output_path, '404.png') + if not os.path.exists(output_path): + QPixmap(':/icons/icons/404.png').save(output_path) + return output_path except: logger.error(traceback.format_exc()) - return "" + output_path = os.path.join(output_path, "404.png") + if not os.path.exists(output_path): + QPixmap(':/icons/icons/404.png').save(output_path) + return output_path if __name__ == '__main__':